Documentation
¶
Overview ¶
Package otlp is a logging sink that sends records to an OpenTelemetry collector, or any service that takes OTLP over HTTP (Grafana Cloud, Honeycomb, New Relic, SigNoz, Axiom…), as OTLP/HTTP JSON:
logging.New(logging.Options{Sinks: []logging.Sink{otlp.New(otlp.Options{})}})
With no options it reads the standard environment variables: OTEL_EXPORTER_OTLP_LOGS_ENDPOINT or OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_LOGS_HEADERS or OTEL_EXPORTER_OTLP_HEADERS, OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES. Records logged in a request with a trusted traceparent carry its trace and span.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Options ¶
type Options struct {
// Endpoint is the URL logs are posted to, ending in /v1/logs. The
// default is OTEL_EXPORTER_OTLP_LOGS_ENDPOINT's, or
// OTEL_EXPORTER_OTLP_ENDPOINT's with /v1/logs added, or
// http://localhost:4318/v1/logs.
Endpoint string
// Headers are sent with each request, such as an API key.
Headers http.Header
// ServiceName is the service.name resource attribute. The default is
// OTEL_SERVICE_NAME's, or the program's name.
ServiceName string
// Resource adds resource attributes, after OTEL_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 sink. Unset fields come from the environment.
Click to show internal directories.
Click to hide internal directories.