bunotel

package module
v1.2.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2026 License: BSD-2-Clause Imports: 17 Imported by: 49

README

OpenTelemetry instrumentation for Bun

See example for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option added in v1.0.12

type Option func(h *QueryHook)

func WithAttributes added in v1.0.12

func WithAttributes(attrs ...attribute.KeyValue) Option

WithAttributes configures attributes that are used to create a span.

func WithDBName added in v1.0.12

func WithDBName(name string) Option

WithDBName configures a db.name attribute.

func WithFormattedQueries added in v1.1.6

func WithFormattedQueries(format bool) Option

WithFormattedQueries enables formatting of the query that is added as the statement attribute to the trace. This means that all placeholders and arguments will be filled first and the query will contain all information as sent to the database.

func WithMeterProvider added in v1.1.15

func WithMeterProvider(mp metric.MeterProvider) Option

WithMeterProvider returns an Option to use the MeterProvider when creating a Meter.

func WithSpanNameQueryGen added in v1.2.16

func WithSpanNameQueryGen(f func(*bun.QueryEvent) string) Option

WithSpanNameQueryGen takes a function that determines the span name for a given query event.

func WithTracerProvider added in v1.1.15

func WithTracerProvider(tp trace.TracerProvider) Option

WithTracerProvider returns an Option to use the TracerProvider when creating a Tracer.

type QueryHook

type QueryHook struct {
	// contains filtered or unexported fields
}

QueryHook is a bun.QueryHook that reports query timing via OpenTelemetry.

func NewQueryHook

func NewQueryHook(opts ...Option) *QueryHook

NewQueryHook creates a new QueryHook with the given options.

func (*QueryHook) AfterQuery

func (h *QueryHook) AfterQuery(ctx context.Context, event *bun.QueryEvent)

func (*QueryHook) BeforeQuery

func (h *QueryHook) BeforeQuery(ctx context.Context, event *bun.QueryEvent) context.Context

func (*QueryHook) Init added in v1.0.12

func (h *QueryHook) Init(db *bun.DB)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL