Documentation
¶
Overview ¶
Package hooks provides observability hooks for dbkit
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OperationType ¶
OperationType extracts the operation type from a query
Types ¶
type LoggerHook ¶
type LoggerHook struct {
// contains filtered or unexported fields
}
LoggerHook implements query logging
func NewLoggerHook ¶
NewLoggerHook creates a new logger hook
func (*LoggerHook) AfterQuery ¶
func (h *LoggerHook) AfterQuery(ctx context.Context, event *bun.QueryEvent)
AfterQuery is called after a query is executed
func (*LoggerHook) BeforeQuery ¶
func (h *LoggerHook) BeforeQuery(ctx context.Context, event *bun.QueryEvent) context.Context
BeforeQuery is called before a query is executed
type MetricsHook ¶
type MetricsHook struct {
// contains filtered or unexported fields
}
MetricsHook implements Prometheus metrics collection
func NewMetricsHook ¶
func NewMetricsHook(registry prometheus.Registerer) (*MetricsHook, error)
NewMetricsHook creates a new metrics hook and registers collectors
func (*MetricsHook) AfterQuery ¶
func (h *MetricsHook) AfterQuery(ctx context.Context, event *bun.QueryEvent)
AfterQuery is called after a query is executed
func (*MetricsHook) BeforeQuery ¶
func (h *MetricsHook) BeforeQuery(ctx context.Context, event *bun.QueryEvent) context.Context
BeforeQuery is called before a query is executed
type TracingHook ¶
type TracingHook struct {
// contains filtered or unexported fields
}
TracingHook implements OpenTelemetry tracing
func NewTracingHook ¶
func NewTracingHook(tracer trace.Tracer) *TracingHook
NewTracingHook creates a new tracing hook
func (*TracingHook) AfterQuery ¶
func (h *TracingHook) AfterQuery(ctx context.Context, event *bun.QueryEvent)
AfterQuery is called after a query is executed
func (*TracingHook) BeforeQuery ¶
func (h *TracingHook) BeforeQuery(ctx context.Context, event *bun.QueryEvent) context.Context
BeforeQuery is called before a query is executed