hooks

package
v0.0.0-...-d28b152 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package hooks provides observability hooks for dbkit

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OperationType

func OperationType(query string) string

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

func NewLoggerHook(logger *slog.Logger, logAll bool, slowThreshold time.Duration) *LoggerHook

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

Jump to

Keyboard shortcuts

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