otlp

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package otlp exports spans to an OpenTelemetry collector, or any service that takes OTLP over HTTP (Grafana Tempo, Honeycomb, Jaeger, SigNoz, Datadog, New Relic…), as OTLP/HTTP JSON:

tracing.New(tracing.Options{Exporters: []tracing.Exporter{otlp.New(otlp.Options{})}})

With no options it reads the standard environment variables: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT or OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_TRACES_HEADERS or OTEL_EXPORTER_OTLP_HEADERS, OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES, as logging/otlp does.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exporter

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

Exporter sends spans over OTLP/HTTP. Make one with New.

func New

func New(o Options) *Exporter

New returns an OTLP exporter.

func (*Exporter) Export

func (e *Exporter) Export(ctx context.Context, spans []tracing.SpanData) error

Export implements tracing.Exporter.

func (*Exporter) Name

func (*Exporter) Name() string

Name is the exporter's name in error reports.

type Options

type Options struct {
	// Endpoint is the URL spans are posted to, ending in /v1/traces.
	Endpoint string
	// Headers are sent with each request, such as an API key.
	Headers http.Header
	// ServiceName is the service.name resource attribute.
	ServiceName string
	// Resource adds resource attributes.
	Resource map[string]string
	// NoGzip sends requests uncompressed.
	NoGzip bool
	// Client sends the requests. The default is http.DefaultClient.
	Client *http.Client
}

Options configures the exporter. Unset fields come from the environment.

Jump to

Keyboard shortcuts

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