otlpjson

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package otlpjson sends spans to an OTLP/HTTP endpoint in OTLP's JSON encoding (POST {endpoint}/v1/traces, application/json), over net/http alone. It is the exporter of a program that cannot carry the OTLP exporters' protobuf and gRPC code, such as Tacklr on Cloudflare Workers (js/wasm), where net/http sends through fetch. Install sets up the process-wide tracer with it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Headers

func Headers(s string) map[string]string

Headers parses OTEL_EXPORTER_OTLP_HEADERS ("k1=v1,k2=v2", values URL-encoded, as the OpenTelemetry environment variables give them).

func Install

func Install(e *Exporter, service string) *sdktrace.TracerProvider

Install installs the process-wide tracer provider, exporting through e in batches, with the W3C propagator and parent-based sampling, as export.Init does for a host process. It returns the provider: Flush it when the platform may stop the program, and Shutdown it at the end.

Types

type Exporter

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

Exporter is an sdktrace.SpanExporter to one OTLP/HTTP endpoint.

func New

func New(endpoint string, headers map[string]string, client *http.Client) *Exporter

New exports to endpoint (the OTLP/HTTP base URL, such as https://otlp.example.com/otlp), with headers on each request (an API key). A nil client is http.DefaultClient.

func (*Exporter) ExportSpans

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

ExportSpans implements sdktrace.SpanExporter: one request for the batch.

func (*Exporter) Shutdown

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

Shutdown implements sdktrace.SpanExporter. The exporter holds nothing.

Jump to

Keyboard shortcuts

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