bunobs

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package bunobs configures Bun query logging and telemetry.

Index

Constants

View Source
const (
	Local = "local"
	Dev   = "dev"
)

Variables

This section is empty.

Functions

func Configure

func Configure(db *bun.DB, env string, opts ...Option)

Configure attaches the query logger selected by env and Bun telemetry. Full SQL is visible locally and in dev when DEBUG logging is enabled. Other environments omit the query attribute unless WithQueryText enables it.

Types

type Option

type Option func(*options)

Option configures Bun observability.

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger sends structured query logs to logger. Configure uses slog.Default when logger is nil or this option is omitted.

func WithOTelOptions

func WithOTelOptions(opts ...bunotel.Option) Option

WithOTelOptions configures the Bun OpenTelemetry query hook. Multiple calls append options in order.

func WithQueryText

func WithQueryText(enabled bool) Option

WithQueryText allows full SQL in structured query logs when enabled. The logger's level still determines which query events are emitted.

Jump to

Keyboard shortcuts

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