OpenTelemetry
pkg/otel manages the OpenTelemetry SDK lifecycle — initializing trace, metric, and log providers on startup and flushing them on shutdown.
lakta.NewRuntime( config.NewModule( config.WithConfigDirs(".", "./config"), config.WithArgs(os.Args[1:]), ), tint.NewModule(), slog.NewModule(), otel.NewModule(), // after logger, before app modules)What gets registered
Section titled “What gets registered”| DI type | Description |
|---|---|
trace.TracerProvider | OTLP trace exporter |
metric.MeterProvider | OTLP metric exporter |
*slog.Logger | OTel log bridge (wraps the existing logger) |
Using traces
Section titled “Using traces”tracer := do.MustInvoke[trace.TracerProvider](injector).Tracer("my-service")
ctx, span := tracer.Start(ctx, "operation-name")defer span.End()Configuration Reference
Section titled “Configuration Reference”Config path: modules.otel.otel.<name>
service_name serviceName specifies the OpenTelemetry service name
LAKTA_MODULES_OTEL_OTEL_<NAME>_SERVICE_NAME service_version serviceVersion is included as semconv.ServiceVersionKey in the resource
LAKTA_MODULES_OTEL_OTEL_<NAME>_SERVICE_VERSION service_namespace serviceNamespace is included as semconv.ServiceNamespaceKey in the resource
LAKTA_MODULES_OTEL_OTEL_<NAME>_SERVICE_NAMESPACE environment environment is the deployment environment (e.g. "production", "staging")
LAKTA_MODULES_OTEL_OTEL_<NAME>_ENVIRONMENT endpoint endpoint overrides the OTLP exporter endpoint. Empty uses the SDK default (env vars)
LAKTA_MODULES_OTEL_OTEL_<NAME>_ENDPOINT protocol protocol sets the OTLP transport: "grpc" (default), "http/protobuf", or "http/json"
LAKTA_MODULES_OTEL_OTEL_<NAME>_PROTOCOL insecure insecure disables TLS on the OTLP connection — useful for local collectors
LAKTA_MODULES_OTEL_OTEL_<NAME>_INSECURE headers headers are additional headers sent with every OTLP export (e.g. auth tokens)
LAKTA_MODULES_OTEL_OTEL_<NAME>_HEADERS sample_rate sampleRate sets the trace sampling ratio. 1.0 = always sample, 0.0 = never sample
LAKTA_MODULES_OTEL_OTEL_<NAME>_SAMPLE_RATE metric_interval metricInterval sets the periodic metric export interval
LAKTA_MODULES_OTEL_OTEL_<NAME>_METRIC_INTERVAL runtime_interval runtimeInterval sets the minimum Go runtime stats collection interval
LAKTA_MODULES_OTEL_OTEL_<NAME>_RUNTIME_INTERVAL enabled enabled controls whether OTEL is set up. When false, noop providers are registered
LAKTA_MODULES_OTEL_OTEL_<NAME>_ENABLED signals signals lists which telemetry signals to enable: "traces", "metrics", "logs"
LAKTA_MODULES_OTEL_OTEL_<NAME>_SIGNALS