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()Exporters per signal
Section titled “Exporters per signal”exporters selects otlp or none per signal and replaces signals. Traces and metrics always get an SDK provider (spans record and trace IDs reach logs without a collector); logs get a provider only for otlp. Metrics are always readable through the private *prometheus.Registry the module provides in DI, which the management server exposes on /metrics.
modules: otel: otel: default: exporters: { traces: otlp, metrics: none, logs: none }Configuration Reference
Section titled “Configuration Reference”Config path: modules.otel.otel.<name>
service_nameserviceName specifies the OpenTelemetry service name
LAKTA_MODULES__OTEL__OTEL__<NAME>__SERVICE_NAMEservice_versionserviceVersion is included as semconv.ServiceVersionKey in the resource
LAKTA_MODULES__OTEL__OTEL__<NAME>__SERVICE_VERSIONservice_namespaceserviceNamespace is included as semconv.ServiceNamespaceKey in the resource
LAKTA_MODULES__OTEL__OTEL__<NAME>__SERVICE_NAMESPACEenvironmentenvironment is the deployment environment (e.g. "production", "staging")
LAKTA_MODULES__OTEL__OTEL__<NAME>__ENVIRONMENTendpointendpoint overrides the OTLP exporter endpoint. Empty uses the SDK default (env vars)
LAKTA_MODULES__OTEL__OTEL__<NAME>__ENDPOINTprotocolprotocol sets the OTLP transport: "grpc" (default), "http/protobuf", or "http/json"
LAKTA_MODULES__OTEL__OTEL__<NAME>__PROTOCOLinsecureinsecure disables TLS on the OTLP connection — useful for local collectors
LAKTA_MODULES__OTEL__OTEL__<NAME>__INSECUREheadersheaders are additional headers sent with every OTLP export (e.g. auth tokens)
LAKTA_MODULES__OTEL__OTEL__<NAME>__HEADERSsample_ratesampleRate sets the trace sampling ratio. 1.0 = always sample, 0.0 = never sample
LAKTA_MODULES__OTEL__OTEL__<NAME>__SAMPLE_RATEmetric_intervalmetricInterval sets the periodic metric export interval
LAKTA_MODULES__OTEL__OTEL__<NAME>__METRIC_INTERVALruntime_intervalruntimeInterval sets the minimum Go runtime stats collection interval
LAKTA_MODULES__OTEL__OTEL__<NAME>__RUNTIME_INTERVALenabledenabled controls whether OTEL is set up. When false, noop providers are registered
LAKTA_MODULES__OTEL__OTEL__<NAME>__ENABLEDrequiredrequired makes telemetry setup failures fatal. When false (default), setup
LAKTA_MODULES__OTEL__OTEL__<NAME>__REQUIREDsignalssignals lists which telemetry signals to enable: "traces", "metrics", "logs"
LAKTA_MODULES__OTEL__OTEL__<NAME>__SIGNALSexportersexporters selects the exporter per signal ("traces", "metrics", "logs"):
LAKTA_MODULES__OTEL__OTEL__<NAME>__EXPORTERS