Documentation
¶
Overview ¶
Package telemetry owns all OpenTelemetry provider construction and is the single place in the binary that imports otel/sdk/* packages. Application packages import only the API packages (otel/trace, otel/metric, otel/log) or use the global accessors via otel.Tracer(), otel.Meter().
Index ¶
Constants ¶
const ( // TracerRoot is the root instrumentation scope for the scafctl binary. TracerRoot = "github.com/oakwood-commons/scafctl" // TracerHTTPClient is the instrumentation scope for the HTTP client. TracerHTTPClient = TracerRoot + "/httpc" // TracerProvider is the instrumentation scope for provider execution. TracerProvider = TracerRoot + "/provider" // TracerResolver is the instrumentation scope for resolver evaluation. TracerResolver = TracerRoot + "/resolver" // TracerSolution is the instrumentation scope for solution runs. TracerSolution = TracerRoot + "/solution" // TracerAction is the instrumentation scope for action execution. TracerAction = TracerRoot + "/action" // TracerMCP is the instrumentation scope for MCP server handling. TracerMCP = TracerRoot + "/mcp" )
Tracer name constants. Each subsystem uses its own named tracer so spans are grouped by instrumentation scope in backend UIs like Jaeger.
Variables ¶
This section is empty.
Functions ¶
func Setup ¶
Setup initializes the OTel TracerProvider and LoggerProvider and registers them globally. It must be called before logger.GetWithOptions so that the otellogr bridge picks up the real SDK provider rather than the noop default.
The returned shutdown function flushes buffered telemetry and must be called before process exit. Typical usage:
shutdown, err := telemetry.Setup(ctx, opts)
if err != nil { /* handle */ }
defer func() { _ = shutdown(ctx) }()
Types ¶
type Options ¶
type Options struct {
// ServiceName is the OTel resource service.name attribute.
// Defaults to settings.CliBinaryName when empty.
ServiceName string
// ServiceVersion is the OTel resource service.version attribute.
// Defaults to settings.VersionInformation.BuildVersion when empty.
ServiceVersion string
// ExporterEndpoint is the OTLP gRPC endpoint (e.g. "localhost:4317").
// Overrides the OTEL_EXPORTER_OTLP_ENDPOINT environment variable.
// When empty and the env var is also unset, tracing is disabled (noop).
ExporterEndpoint string
// ExporterInsecure disables TLS for the OTLP gRPC connection.
// Useful for local development against an OTel collector without TLS.
ExporterInsecure bool
// SamplerType controls the trace sampler. Supported values:
// always_on — sample every span (default)
// always_off — drop all spans
// traceidratio — sample a fraction of spans (controlled by SamplerArg)
SamplerType string
// SamplerArg is the argument passed to the sampler.
// For traceidratio this is the sampling ratio (0.0–1.0). Defaults to 1.0.
SamplerArg float64
}
Options configures the OTel SDK setup.