observability

package
v0.30.2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RecordDBPoolRejection

func RecordDBPoolRejection(ctx context.Context)

RecordDBPoolRejection increments the pool rejection counter when requests are rejected before acquiring a connection.

func RecordDBPoolStats

func RecordDBPoolStats(ctx context.Context, snapshot DBPoolSnapshot)

RecordDBPoolStats records database pool utilisation metrics.

func RecordJobConcurrencySnapshot

func RecordJobConcurrencySnapshot(ctx context.Context, jobID string, runningTasks int64, concurrencyLimit int64, unlimited bool)

RecordJobConcurrencySnapshot captures the running task count and concurrency limit for a job.

func RecordJobInfoCacheHit

func RecordJobInfoCacheHit(ctx context.Context, jobID string)

func RecordJobInfoCacheInvalidation

func RecordJobInfoCacheInvalidation(ctx context.Context, jobID, reason string)

func RecordJobInfoCacheMiss

func RecordJobInfoCacheMiss(ctx context.Context, jobID string)

func RecordJobInfoCacheSize

func RecordJobInfoCacheSize(ctx context.Context, size int)

func RecordTaskClaimAttempt

func RecordTaskClaimAttempt(ctx context.Context, jobID string, latency time.Duration, status string)

RecordTaskClaimAttempt records the latency of claiming a task from the queue.

func RecordTaskWaiting

func RecordTaskWaiting(ctx context.Context, jobID string, reason string, count int)

RecordTaskWaiting records when tasks move into the waiting queue along with the reason.

func RecordWorkerConcurrency

func RecordWorkerConcurrency(ctx context.Context, workerID int, delta int64, capacity int64)

RecordWorkerConcurrency records the change in concurrent tasks for a worker. delta: +1 when starting a task, -1 when completing capacity: the worker's concurrency limit (only recorded once per worker on startup)

func RecordWorkerTask

func RecordWorkerTask(ctx context.Context, metrics WorkerTaskMetrics)

RecordWorkerTask emits worker task metrics when instrumentation is initialised.

func RecordWorkerTaskFailure

func RecordWorkerTaskFailure(ctx context.Context, jobID string, reason string)

RecordWorkerTaskFailure records a permanently failed task.

func RecordWorkerTaskRetry

func RecordWorkerTaskRetry(ctx context.Context, jobID string, reason string)

RecordWorkerTaskRetry records a retry attempt for a task.

func StartWorkerTaskSpan

func StartWorkerTaskSpan(ctx context.Context, info WorkerTaskSpanInfo) (context.Context, trace.Span)

StartWorkerTaskSpan starts a span for an individual worker task.

func WrapHandler

func WrapHandler(handler http.Handler, prov *Providers) http.Handler

WrapHandler applies OpenTelemetry instrumentation to an http.Handler when the providers are active.

Types

type Config

type Config struct {
	Enabled        bool
	ServiceName    string
	Environment    string
	OTLPEndpoint   string
	OTLPHeaders    map[string]string
	OTLPInsecure   bool
	MetricsAddress string
}

Config controls observability initialisation.

type DBPoolSnapshot

type DBPoolSnapshot struct {
	InUse        int
	Idle         int
	WaitCount    int64
	WaitDuration time.Duration
	MaxOpen      int
	Reserved     int
	Usage        float64
}

DBPoolSnapshot describes a database connection pool state.

type Providers

type Providers struct {
	TracerProvider *sdktrace.TracerProvider
	MeterProvider  *sdkmetric.MeterProvider
	Propagator     propagation.TextMapPropagator
	MetricsHandler http.Handler
	Shutdown       func(ctx context.Context) error
	Config         Config
}

Providers exposes configured telemetry providers.

func Init

func Init(ctx context.Context, cfg Config) (*Providers, error)

Init configures tracing and metrics exporters. When cfg.Enabled is false the function is a no-op.

type WorkerTaskMetrics

type WorkerTaskMetrics struct {
	JobID         string
	Status        string
	Duration      time.Duration
	QueueWait     time.Duration
	TotalDuration time.Duration
}

WorkerTaskMetrics describes a processed task for metric recording.

type WorkerTaskSpanInfo

type WorkerTaskSpanInfo struct {
	JobID     string
	TaskID    string
	Domain    string
	Path      string
	FindLinks bool
}

WorkerTaskSpanInfo describes the attributes used when starting a worker task span.

Jump to

Keyboard shortcuts

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