Documentation
¶
Overview ¶
Package providers contains telemetry provider implementations and builder logic
Index ¶
- type CompositeProvider
- type Config
- type MeterResult
- type MeterStrategy
- type NoOpMeterStrategy
- type NoOpTracerStrategy
- type OTLPTracerStrategy
- type ProviderOption
- func WithCustomAttributes(attributes map[string]string) ProviderOption
- func WithEnablePrometheusMetricsPath(enablePrometheusMetricsPath bool) ProviderOption
- func WithHeaders(headers map[string]string) ProviderOption
- func WithInsecure(insecure bool) ProviderOption
- func WithMetricsEnabled(metricsEnabled bool) ProviderOption
- func WithOTLPEndpoint(endpoint string) ProviderOption
- func WithSamplingRate(samplingRate float64) ProviderOption
- func WithServiceName(serviceName string) ProviderOption
- func WithServiceVersion(serviceVersion string) ProviderOption
- func WithTracingEnabled(tracingEnabled bool) ProviderOption
- type StrategySelector
- type TracerStrategy
- type UnifiedMeterStrategy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompositeProvider ¶
type CompositeProvider struct {
// contains filtered or unexported fields
}
CompositeProvider combines telemetry providers into a single interface. It manages tracer providers, meter providers, Prometheus handlers, and cleanup.
func NewCompositeProvider ¶ added in v0.3.0
func NewCompositeProvider( ctx context.Context, options ...ProviderOption, ) (*CompositeProvider, error)
NewCompositeProvider creates the appropriate providers based on provided options
func (*CompositeProvider) MeterProvider ¶
func (p *CompositeProvider) MeterProvider() metric.MeterProvider
MeterProvider returns the primary meter provider
func (*CompositeProvider) PrometheusHandler ¶
func (p *CompositeProvider) PrometheusHandler() http.Handler
PrometheusHandler returns the Prometheus metrics handler if configured
func (*CompositeProvider) Shutdown ¶
func (p *CompositeProvider) Shutdown(ctx context.Context) error
Shutdown gracefully shuts down all providers
func (*CompositeProvider) TracerProvider ¶
func (p *CompositeProvider) TracerProvider() trace.TracerProvider
TracerProvider returns the tracer provider
type Config ¶
type Config struct {
// Service information
ServiceName string // ServiceName identifies the service for telemetry data
ServiceVersion string // ServiceVersion identifies the service version for telemetry data
// OTLP configuration
OTLPEndpoint string // OTLPEndpoint is the OTLP collector endpoint (e.g., "localhost:4318")
Headers map[string]string // Headers are additional headers to send with OTLP requests
Insecure bool // Insecure enables insecure transport (no TLS) for OTLP
TracingEnabled bool // TracingEnabled controls whether tracing is enabled for OTLP
MetricsEnabled bool // MetricsEnabled controls whether metrics are enabled for OTLP
SamplingRate float64 // SamplingRate controls trace sampling (0.0 to 1.0)
// Prometheus configuration
EnablePrometheusMetricsPath bool // EnablePrometheusMetricsPath enables Prometheus /metrics endpoint
// Custom attributes
// CustomAttributes are additional resource attributes to include (as map for JSON serialization)
CustomAttributes map[string]string
}
Config holds the telemetry configuration for all providers. It contains service information, OTLP settings, and Prometheus configuration.
type MeterResult ¶ added in v0.2.17
type MeterResult struct {
MeterProvider metric.MeterProvider
PrometheusHandler http.Handler
ShutdownFunc func(context.Context) error
}
MeterResult contains the result of creating a meter provider
type MeterStrategy ¶ added in v0.2.17
type MeterStrategy interface {
CreateMeterProvider(ctx context.Context, config Config, res *resource.Resource) (*MeterResult, error)
}
MeterStrategy defines the interface for creating meter providers
type NoOpMeterStrategy ¶ added in v0.2.17
type NoOpMeterStrategy struct{}
NoOpMeterStrategy creates a no-op meter provider that discards all metric data. It's used when both OTLP and Prometheus metrics are disabled.
func (*NoOpMeterStrategy) CreateMeterProvider ¶ added in v0.2.17
func (*NoOpMeterStrategy) CreateMeterProvider( _ context.Context, _ Config, _ *resource.Resource, ) (*MeterResult, error)
CreateMeterProvider creates a no-op meter provider
type NoOpTracerStrategy ¶ added in v0.2.17
type NoOpTracerStrategy struct{}
NoOpTracerStrategy creates a no-op tracer provider that discards all trace data. It's used when tracing is disabled or no OTLP endpoint is configured.
func (*NoOpTracerStrategy) CreateTracerProvider ¶ added in v0.2.17
func (*NoOpTracerStrategy) CreateTracerProvider( _ context.Context, _ Config, _ *resource.Resource, ) (trace.TracerProvider, func(context.Context) error, error)
CreateTracerProvider creates a no-op tracer provider
type OTLPTracerStrategy ¶ added in v0.2.17
type OTLPTracerStrategy struct{}
OTLPTracerStrategy creates an OTLP tracer provider that sends traces to an OTLP collector. It supports sampling configuration, custom headers, and secure/insecure transport.
func (*OTLPTracerStrategy) CreateTracerProvider ¶ added in v0.2.17
func (*OTLPTracerStrategy) CreateTracerProvider( ctx context.Context, config Config, res *resource.Resource, ) (trace.TracerProvider, func(context.Context) error, error)
CreateTracerProvider creates an OTLP tracer provider with the configured endpoint and sampling rate
type ProviderOption ¶ added in v0.3.0
ProviderOption is an option type used to configure the telemetry providers
func WithCustomAttributes ¶ added in v0.4.1
func WithCustomAttributes(attributes map[string]string) ProviderOption
WithCustomAttributes sets the custom resource attributes
func WithEnablePrometheusMetricsPath ¶ added in v0.3.0
func WithEnablePrometheusMetricsPath(enablePrometheusMetricsPath bool) ProviderOption
WithEnablePrometheusMetricsPath sets the enable prometheus metrics path flag
func WithHeaders ¶ added in v0.3.0
func WithHeaders(headers map[string]string) ProviderOption
WithHeaders sets the headers
func WithInsecure ¶ added in v0.3.0
func WithInsecure(insecure bool) ProviderOption
WithInsecure sets the insecure flag
func WithMetricsEnabled ¶ added in v0.3.0
func WithMetricsEnabled(metricsEnabled bool) ProviderOption
WithMetricsEnabled sets the metrics enabled flag
func WithOTLPEndpoint ¶ added in v0.3.0
func WithOTLPEndpoint(endpoint string) ProviderOption
WithOTLPEndpoint sets the OTLP endpoint
func WithSamplingRate ¶ added in v0.3.0
func WithSamplingRate(samplingRate float64) ProviderOption
WithSamplingRate sets the sampling rate
func WithServiceName ¶ added in v0.3.0
func WithServiceName(serviceName string) ProviderOption
WithServiceName sets the service name
func WithServiceVersion ¶ added in v0.3.0
func WithServiceVersion(serviceVersion string) ProviderOption
WithServiceVersion sets the service version
func WithTracingEnabled ¶ added in v0.3.0
func WithTracingEnabled(tracingEnabled bool) ProviderOption
WithTracingEnabled sets the tracing enabled flag
type StrategySelector ¶ added in v0.2.17
type StrategySelector struct {
// contains filtered or unexported fields
}
StrategySelector determines which strategies to use based on configuration. It analyzes the configuration to select appropriate tracer and meter strategies.
func NewStrategySelector ¶ added in v0.2.17
func NewStrategySelector(config Config) *StrategySelector
NewStrategySelector creates a new strategy selector with the given configuration. The selector will analyze the config to determine appropriate strategies.
func (*StrategySelector) IsFullyNoOp ¶ added in v0.2.17
func (s *StrategySelector) IsFullyNoOp() bool
IsFullyNoOp returns true if both tracer and meter would be no-op.
func (*StrategySelector) SelectMeterStrategy ¶ added in v0.2.17
func (s *StrategySelector) SelectMeterStrategy() MeterStrategy
SelectMeterStrategy determines the appropriate meter strategy based on configuration.
func (*StrategySelector) SelectTracerStrategy ¶ added in v0.2.17
func (s *StrategySelector) SelectTracerStrategy() TracerStrategy
SelectTracerStrategy determines the appropriate tracer strategy based on configuration.
type TracerStrategy ¶ added in v0.2.17
type TracerStrategy interface {
// CreateTracerProvider creates a tracer provider with optional shutdown function
CreateTracerProvider(ctx context.Context, config Config, res *resource.Resource) (
trace.TracerProvider, func(context.Context) error, error)
}
TracerStrategy defines the interface for creating tracer providers. Implementations create trace providers based on configuration and resource information.
type UnifiedMeterStrategy ¶ added in v0.2.17
type UnifiedMeterStrategy struct {
EnableOTLP bool // EnableOTLP controls whether to add an OTLP metrics reader
EnablePrometheus bool // EnablePrometheus controls whether to add a Prometheus reader
}
UnifiedMeterStrategy creates a meter provider with multiple readers (OTLP and/or Prometheus). It can combine OTLP metrics export and Prometheus scraping in a single provider.
func (*UnifiedMeterStrategy) CreateMeterProvider ¶ added in v0.2.17
func (s *UnifiedMeterStrategy) CreateMeterProvider( ctx context.Context, config Config, res *resource.Resource, ) (*MeterResult, error)
CreateMeterProvider creates a unified meter provider with OTLP and/or Prometheus readers
Directories
¶
| Path | Synopsis |
|---|---|
|
Package otlp provides OpenTelemetry Protocol (OTLP) provider implementations
|
Package otlp provides OpenTelemetry Protocol (OTLP) provider implementations |
|
Package prometheus provides Prometheus metric exporter implementation
|
Package prometheus provides Prometheus metric exporter implementation |