Documentation ¶
Overview ¶
Package autoexport provides OpenTelemetry exporter factory functions with defaults and environment variable support as defined by the OpenTelemetry specification.
Index ¶
- func IsNoneMetricReader(e metric.Reader) bool
- func IsNoneSpanExporter(e trace.SpanExporter) bool
- func NewMetricReader(ctx context.Context, opts ...MetricOption) (metric.Reader, error)
- func NewSpanExporter(ctx context.Context, opts ...SpanOption) (trace.SpanExporter, error)
- func RegisterMetricProducer(name string, factory func(context.Context) (metric.Producer, error))
- func RegisterMetricReader(name string, factory func(context.Context) (metric.Reader, error))
- func RegisterSpanExporter(name string, factory func(context.Context) (trace.SpanExporter, error))
- func WithFallbackMetricProducer(producerFactory func(ctx context.Context) (metric.Producer, error))
- type MetricOption
- type Optiondeprecated
- type SpanOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNoneMetricReader ¶ added in v0.46.0
IsNoneMetricReader returns true for the exporter returned by NewMetricReader when OTEL_METRICS_EXPORTER environment variable is set to "none".
func IsNoneSpanExporter ¶
func IsNoneSpanExporter(e trace.SpanExporter) bool
IsNoneSpanExporter returns true for the exporter returned by NewSpanExporter when OTEL_TRACES_EXPORTER environment variable is set to "none".
func NewMetricReader ¶ added in v0.46.0
NewMetricReader returns a configured go.opentelemetry.io/otel/sdk/metric.Reader defined using the environment variables described below.
OTEL_METRICS_EXPORTER defines the metrics exporter; supported values:
- "none" - "no operation" exporter
- "otlp" (default) - OTLP exporter; see go.opentelemetry.io/otel/exporters/otlp/otlpmetric
- "prometheus" - Prometheus exporter + HTTP server; see go.opentelemetry.io/otel/exporters/prometheus
- "console" - Standard output exporter; see go.opentelemetry.io/otel/exporters/stdout/stdoutmetric
OTEL_EXPORTER_OTLP_PROTOCOL defines OTLP exporter's transport protocol; supported values:
- "grpc" - protobuf-encoded data using gRPC wire format over HTTP/2 connection; see: go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc
- "http/protobuf" (default) - protobuf-encoded data over HTTP connection; see: go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp
OTEL_EXPORTER_PROMETHEUS_HOST (defaulting to "localhost") and OTEL_EXPORTER_PROMETHEUS_PORT (defaulting to 9464) define the host and port for the Prometheus exporter's HTTP server.
Experimental: OTEL_METRICS_PRODUCERS can be used to configure metric producers. supported values: prometheus, none. Multiple values can be specified separated by commas.
An error is returned if an environment value is set to an unhandled value.
Use RegisterMetricReader to handle more values of OTEL_METRICS_EXPORTER. Use RegisterMetricProducer to handle more values of OTEL_METRICS_PRODUCERS.
Use WithFallbackMetricReader option to change the returned exporter when OTEL_METRICS_EXPORTER is unset or empty.
Use IsNoneMetricReader to check if the retured exporter is a "no operation" exporter.
func NewSpanExporter ¶
func NewSpanExporter(ctx context.Context, opts ...SpanOption) (trace.SpanExporter, error)
NewSpanExporter returns a configured go.opentelemetry.io/otel/sdk/trace.SpanExporter defined using the environment variables described below.
OTEL_TRACES_EXPORTER defines the traces exporter; supported values:
- "none" - "no operation" exporter
- "otlp" (default) - OTLP exporter; see go.opentelemetry.io/otel/exporters/otlp/otlptrace
- "console" - Standard output exporter; see go.opentelemetry.io/otel/exporters/stdout/stdouttrace
OTEL_EXPORTER_OTLP_PROTOCOL defines OTLP exporter's transport protocol; supported values:
- "grpc" - protobuf-encoded data using gRPC wire format over HTTP/2 connection; see: go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc
- "http/protobuf" (default) - protobuf-encoded data over HTTP connection; see: go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp
An error is returned if an environment value is set to an unhandled value.
Use RegisterSpanExporter to handle more values of OTEL_TRACES_EXPORTER.
Use WithFallbackSpanExporter option to change the returned exporter when OTEL_TRACES_EXPORTER is unset or empty.
Use IsNoneSpanExporter to check if the retured exporter is a "no operation" exporter.
func RegisterMetricProducer ¶ added in v0.52.0
RegisterMetricProducer sets the MetricReader factory to be used when the OTEL_METRICS_PRODUCERS environment variable contains the producer name. This will panic if name has already been registered.
func RegisterMetricReader ¶ added in v0.46.0
RegisterMetricReader sets the MetricReader factory to be used when the OTEL_METRICS_EXPORTERS environment variable contains the exporter name. This will panic if name has already been registered.
func RegisterSpanExporter ¶
RegisterSpanExporter sets the SpanExporter factory to be used when the OTEL_TRACES_EXPORTERS environment variable contains the exporter name. This will panic if name has already been registered.
Types ¶
type MetricOption ¶ added in v0.46.0
MetricOption applies an autoexport configuration option.
func WithFallbackMetricReader ¶ added in v0.46.0
func WithFallbackMetricReader(metricReaderFactory func(ctx context.Context) (metric.Reader, error)) MetricOption
WithFallbackMetricReader sets the fallback exporter to use when no exporter is configured through the OTEL_METRICS_EXPORTER environment variable.
type Option
deprecated
type Option = SpanOption
Option applies an autoexport configuration option.
Deprecated: Use SpanOption.
type SpanOption ¶ added in v0.46.0
type SpanOption = option[trace.SpanExporter]
SpanOption applies an autoexport configuration option.
func WithFallbackSpanExporter ¶
func WithFallbackSpanExporter(spanExporterFactory func(ctx context.Context) (trace.SpanExporter, error)) SpanOption
WithFallbackSpanExporter sets the fallback exporter to use when no exporter is configured through the OTEL_TRACES_EXPORTER environment variable.