Documentation
¶
Overview ¶
Package otel exports spans and metrics to an OpenTelemetry collector using the OTLP HTTP/JSON protocol.
Use NewExporter to create an exporter, then chain its Exporter.ProcessEvent method with other exporters:
otelExporter := otel.NewExporter(ctx,
otel.WithEndpoint("http://localhost:4318"),
otel.WithServiceName("myservice"),
)
event.SetExporter(otelExporter.ProcessEvent)
The exporter batches telemetry and flushes periodically in a background goroutine. Call Exporter.Flush to force an immediate export.
Index ¶
Constants ¶
const ( DefaultEndpoint = "http://localhost:4318" DefaultServiceName = "unknown_service" DefaultTimeout = 10 * time.Second DefaultFlushPeriod = 2 * time.Second )
Default configuration values.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Exporter ¶
type Exporter struct {
// contains filtered or unexported fields
}
Exporter exports spans and metrics to an OTLP HTTP endpoint.
func NewExporter ¶
NewExporter creates an exporter that sends spans to an OTLP endpoint. Spans are collected and exported periodically in a background goroutine. When the context is done, remaining spans are flushed.
type Option ¶
type Option func(*Exporter)
Option configures an OTelExporter.
func WithEndpoint ¶
WithEndpoint sets the OTLP HTTP endpoint.
func WithFlushPeriod ¶
WithFlushPeriod sets the interval for automatic background flushing.
func WithServiceName ¶
WithServiceName sets the service name for exported spans.
func WithServiceVersion ¶
WithServiceVersion sets the service version for exported telemetry.
func WithTimeout ¶
WithTimeout sets the HTTP client timeout.