providers

package
v0.2.17 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package providers contains telemetry provider implementations and factory logic

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder builds telemetry providers based on configuration. It validates configuration, creates resources, and assembles composite providers.

func WithConfig added in v0.2.17

func WithConfig(config Config) *Builder

WithConfig creates a new provider builder with the given configuration

func (*Builder) Build

func (b *Builder) Build(ctx context.Context) (*CompositeProvider, error)

Build creates the appropriate providers based on configuration

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 (*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
}

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 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

Jump to

Keyboard shortcuts

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