Documentation
¶
Overview ¶
Package otelsetup wires an OpenTelemetry OTLP pipeline for gopheragent with a single call. It is the ONLY package in the repository that imports the OpenTelemetry SDK and OTLP exporters, so a library consumer that does not need export pays nothing: the core (pkg/agent, pkg/telemetry/otelllm, pkg/telemetry/oteltools) depends only on the OTel API.
Usage:
tel, shutdown, err := otelsetup.Setup(ctx, otelsetup.Config{ServiceName: "my-agent"})
if err != nil { ... }
defer shutdown(context.Background())
llm := otelllm.NewProvider(p, otelllm.WithTracer(tel.Tracer), otelllm.WithMeter(tel.Meter), ...)
loop := agent.New(sm, reg, llm, agent.WithTracer(tel.Tracer), agent.WithMeter(tel.Meter))
Endpoint and credentials follow the standard OTEL_* environment variables honored by the OTLP exporters (e.g. OTEL_EXPORTER_OTLP_ENDPOINT). Config fields, when set, take precedence over the environment.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// ServiceName sets service.name on emitted telemetry. Empty falls back to
// "gopheragent" (OTEL_SERVICE_NAME still overrides via the SDK if set).
ServiceName string
// Endpoint overrides OTEL_EXPORTER_OTLP_ENDPOINT, e.g. "localhost:4317".
// Empty defers entirely to the environment.
Endpoint string
// Insecure disables transport security (plaintext gRPC). Use for local
// collectors; leave false in production.
Insecure bool
}
Config controls the OTLP pipeline. The zero value is usable: it names the service "gopheragent" and reads the endpoint from the standard OTEL_* environment variables.
type Providers ¶
Providers holds the ready-to-use Tracer and Meter handles for the gopheragent instrumentation scope.
func Setup ¶
Setup builds an OTLP TracerProvider and MeterProvider, registers them as the global OpenTelemetry providers, and returns Tracer/Meter handles plus a shutdown function that flushes and closes both exporters. Callers should defer the shutdown function so buffered spans and metrics are exported on exit.