Documentation
¶
Overview ¶
Package otel provides lightweight OpenTelemetry setup for pi-go, driven entirely by environment variables sourced from ~/.pi-go/.env so secrets never appear in the process environment.
The following env vars are consumed:
OTEL_SERVICE_NAME defaults to "pi-go" OTEL_EXPORTER_OTLP_ENDPOINT collector endpoint (e.g. https://collector:4317) OTEL_EXPORTER_OTLP_PROTOCOL "grpc" or "http" (default) OTEL_TRACES_EXPORTER "otlp" (default), "console", or "none"
If no exporter is configured, tracing is a no-op (tracer returns no-op spans).
Index ¶
- func AttributeBool(key string, value bool) attribute.KeyValue
- func AttributeInt(key string, value int) attribute.KeyValue
- func AttributeString(key string, value string) attribute.KeyValue
- func IsAvailable() bool
- func IsEnabled() bool
- func ResetForTest()
- func Shutdown(ctx context.Context) error
- func Tracer(name string) trace.Tracer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AttributeBool ¶
AttributeBool returns a bool attribute key-value pair.
func AttributeInt ¶
AttributeInt returns an int attribute key-value pair.
func AttributeString ¶
AttributeString returns a string attribute key-value pair.
func IsAvailable ¶ added in v0.0.31
func IsAvailable() bool
IsAvailable checks whether the configured OTLP endpoint is reachable. Returns true if the port is open, false otherwise. Returns false if exporter is set to "none" or empty (tracing is inactive anyway).
func IsEnabled ¶
func IsEnabled() bool
IsEnabled returns true when OTEL tracing is active (exporter is set and not "none"/"").
func ResetForTest ¶ added in v0.0.43
func ResetForTest()
ResetForTest resets the lazy-initialized tracer provider. It is intended for tests that need to re-read the OTEL configuration from the current ~/.pi-go/.env or process environment, e.g. when the test process has already triggered init once with a different configuration. Production code should never call this.
Types ¶
This section is empty.