Documentation
¶
Overview ¶
Package telemetry provides GoModel's OpenTelemetry integration: OTLP trace and metric export for inbound HTTP requests and outbound provider calls.
Enabling it is the only GoModel-specific switch (OTEL_ENABLED). Exporters, resource attributes, sampling, and propagation follow the standard OTEL_* environment variables read by the OpenTelemetry SDK.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service owns one OpenTelemetry pipeline: providers, the HTTP middleware, and the provider-call observer. Core builds one per application generation so a reload picks up changed OTEL_* settings.
func New ¶
func New(ctx context.Context, cfg config.OpenTelemetryConfig, metricsEndpoint string) (*Service, error)
New configures OTLP traces and metrics from the standard OpenTelemetry environment variables, after exporting the YAML-configured settings into the environment for the SDK to read. Exporters are asynchronous, so the collector does not need to be reachable for this call to succeed. metricsEndpoint is the resolved Prometheus path, excluded from HTTP instrumentation together with the other operational endpoints.
func (*Service) Close ¶
Close flushes pending telemetry and releases exporter resources. Both providers shut down concurrently so a stalled metric export cannot consume the deadline the final spans need.
func (*Service) Hooks ¶
Hooks instruments logical provider calls with GenAI client spans and metrics. Attach them to the provider factory before any provider exists.
func (*Service) Middleware ¶
func (s *Service) Middleware() echo.MiddlewareFunc
Middleware traces inbound HTTP requests and records the standard HTTP server metrics. It belongs at the outer edge of the middleware stack so a span covers the whole request.