otelx

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package otelx wraps OpenTelemetry trace setup with configuration from config so the rest of the service doesn't need to know about OTel's surface area.

Settings are loaded via config.GetConfig().OpenTelemetry (or config.Setup). Tracing is disabled when OTEL_TRACES_EXPORTER=otlp and OTLP endpoint is empty. Set OTEL_TRACES_EXPORTER=gcp to export directly to Google Cloud Trace via ADC.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GORMEnabled

func GORMEnabled(cfg config.OpenTelemetryConfiguration) bool

GORMEnabled reports whether GORM instrumentation should be registered from config.

func Init

Init configures the global OpenTelemetry TracerProvider. Returns a shutdown function and a boolean (enabled). When tracing is not configured we report "off" and proceed silently; when configured but invalid we log and treat as "off".

func LoadConfig

LoadConfig returns OpenTelemetry settings from the global config package.

func RegisterGORM

func RegisterGORM(db *gorm.DB, opts GORMOptions) error

RegisterGORM installs the official GORM OpenTelemetry plugin on db. Call after otelx.Init so spans use the configured TracerProvider.

func TracingEnabled

func TracingEnabled(cfg config.OpenTelemetryConfiguration) bool

TracingEnabled reports whether tracing export is configured.

Types

type GORMOptions

type GORMOptions struct {
	// DBSystem sets the db.system semantic convention (e.g. mysql, postgresql).
	DBSystem string
	// Metrics enables DB pool metrics from the plugin. Default false (tracing only).
	Metrics bool
}

GORMOptions configures OpenTelemetry instrumentation for a *gorm.DB instance.

Jump to

Keyboard shortcuts

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