otlptrace

package module
Version: v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2022 License: Apache-2.0 Imports: 6 Imported by: 172

README

OpenTelemetry-Go OTLP Span Exporter

Go Reference

OpenTelemetry Protocol Exporter implementation.

Installation

go get -u go.opentelemetry.io/otel/exporters/otlp/otlptrace

Examples

otlptrace

The otlptrace package provides an exporter implementing the OTel span exporter interface. This exporter is configured using a client satisfying the otlptrace.Client interface. This client handles the transformation of data into wire format and the transmission of that data to the collector.

otlptracegrpc

The otlptracegrpc package implements a client for the span exporter that sends trace telemetry data to the collector using gRPC with protobuf-encoded payloads.

otlptracehttp

The otlptracehttp package implements a client for the span exporter that sends trace telemetry data to the collector using HTTP with protobuf-encoded payloads.

Configuration

Environment Variables

The following environment variables can be used (instead of options objects) to override the default configuration. For more information about how each of these environment variables is interpreted, see the OpenTelemetry specification.

Environment variable Option Default value
OTEL_EXPORTER_OTLP_ENDPOINT OTEL_EXPORTER_OTLP_TRACES_ENDPOINT WithEndpoint WithInsecure https://localhost:4317 or https://localhost:4318[^1]
OTEL_EXPORTER_OTLP_CERTIFICATE OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE WithTLSClientConfig
OTEL_EXPORTER_OTLP_HEADERS OTEL_EXPORTER_OTLP_TRACES_HEADERS WithHeaders
OTEL_EXPORTER_OTLP_COMPRESSION OTEL_EXPORTER_OTLP_TRACES_COMPRESSION WithCompression
OTEL_EXPORTER_OTLP_TIMEOUT OTEL_EXPORTER_OTLP_TRACES_TIMEOUT WithTimeout 10s

[^1]: The gRPC client defaults to https://localhost:4317 and the HTTP client https://localhost:4318.

Configuration using options have precedence over the environment variables.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {

	// Start should establish connection(s) to endpoint(s). It is
	// called just once by the exporter, so the implementation
	// does not need to worry about idempotence and locking.
	Start(ctx context.Context) error

	// Stop should close the connections. The function is called
	// only once by the exporter, so the implementation does not
	// need to worry about idempotence, but it may be called
	// concurrently with UploadTraces, so proper
	// locking is required. The function serves as a
	// synchronization point - after the function returns, the
	// process of closing connections is assumed to be finished.
	Stop(ctx context.Context) error

	// UploadTraces should transform the passed traces to the wire
	// format and send it to the collector. May be called
	// concurrently.
	UploadTraces(ctx context.Context, protoSpans []*tracepb.ResourceSpans) error
}

Client manages connections to the collector, handles the transformation of data into wire format, and the transmission of that data to the collector.

type Exporter

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

Exporter exports trace data in the OTLP wire format.

func New

func New(ctx context.Context, client Client) (*Exporter, error)

New constructs a new Exporter and starts it.

func NewUnstarted

func NewUnstarted(client Client) *Exporter

NewUnstarted constructs a new Exporter and does not start it.

func (*Exporter) ExportSpans

func (e *Exporter) ExportSpans(ctx context.Context, ss []tracesdk.ReadOnlySpan) error

ExportSpans exports a batch of spans.

func (*Exporter) MarshalLog added in v1.5.0

func (e *Exporter) MarshalLog() interface{}

MarshalLog is the marshaling function used by the logging system to represent this exporter.

func (*Exporter) Shutdown

func (e *Exporter) Shutdown(ctx context.Context) error

Shutdown flushes all exports and closes all connections to the receiving endpoint.

func (*Exporter) Start

func (e *Exporter) Start(ctx context.Context) error

Start establishes a connection to the receiving endpoint.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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