telemetry

package
v0.1.85 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 34 Imported by: 0

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, serviceName 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. serviceName is the default service.name resource attribute — the product name of the running distribution — used unless OTEL_SERVICE_NAME or the YAML service_name overrides it. Empty falls back to "gomodel".

func (*Service) Close

func (s *Service) Close() error

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

func (s *Service) Hooks() llmclient.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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL