Skip to main content

Crate opentelemetry_otlp

Crate opentelemetry_otlp 

Source
Expand description

§OpenTelemetry OTLP Exporter

The OTLP Exporter enables exporting telemetry data (logs, metrics, and traces) in the OpenTelemetry Protocol (OTLP) format to compatible backends. These backends include:

  • OpenTelemetry Collector
  • Open-source observability tools (Prometheus, Jaeger, etc.)
  • Vendor-specific monitoring platforms

This crate supports sending OTLP data via:

  • gRPC
  • HTTP (binary protobuf or JSON)

§Quickstart with OpenTelemetry Collector

The examples below show traces, but the same pattern applies to metrics (MetricExporter) and logs (LogExporter) — just swap the exporter builder and the corresponding SDK provider.

§HTTP Transport (Port 4318)

Run the OpenTelemetry Collector:

$ docker run -p 4318:4318 otel/opentelemetry-collector:latest

Configure your application to export traces via HTTP:

use opentelemetry::global;
use opentelemetry::trace::Tracer;
use opentelemetry_otlp::Protocol;
use opentelemetry_otlp::WithExportConfig;

fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
    // Initialize OTLP exporter using HTTP binary protocol
    let otlp_exporter = opentelemetry_otlp::SpanExporter::builder()
        .with_http()
        .with_protocol(Protocol::HttpBinary)
        .build()?;

    // Create a tracer provider with the exporter
    let tracer_provider = opentelemetry_sdk::trace::SdkTracerProvider::builder()
        .with_batch_exporter(otlp_exporter)
        .build();

    // Set it as the global provider
    global::set_tracer_provider(tracer_provider);

    // Get a tracer and create spans
    let tracer = global::tracer("my_tracer");
    tracer.in_span("doing_work", |_cx| {
        // Your application logic here...
    });

    Ok(())
}

§gRPC Transport (Port 4317)

Run the OpenTelemetry Collector:

$ docker run -p 4317:4317 otel/opentelemetry-collector:latest

Configure your application to export traces via gRPC (the tonic client requires a Tokio runtime):

  • With [tokio::main]
use opentelemetry::{global, trace::Tracer};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
    // Initialize OTLP exporter using gRPC (Tonic)
    let otlp_exporter = opentelemetry_otlp::SpanExporter::builder()
        .with_tonic()
        .build()?;

    // Create a tracer provider with the exporter
    let tracer_provider = opentelemetry_sdk::trace::SdkTracerProvider::builder()
        .with_batch_exporter(otlp_exporter)
        .build();

    // Set it as the global provider
    global::set_tracer_provider(tracer_provider);

    // Get a tracer and create spans
    let tracer = global::tracer("my_tracer");
    tracer.in_span("doing_work", |_cx| {
        // Your application logic here...
    });

    Ok(())
}
  • Without [tokio::main]
use opentelemetry::{global, trace::Tracer};

fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
    // Initialize OTLP exporter using gRPC (Tonic)
    let rt = tokio::runtime::Runtime::new()?;
    let tracer_provider = rt.block_on(async {
        let exporter = opentelemetry_otlp::SpanExporter::builder()
            .with_tonic()
            .build()
            .expect("Failed to create span exporter");
        opentelemetry_sdk::trace::SdkTracerProvider::builder()
            .with_batch_exporter(exporter)
            .build()
    });

    // Set it as the global provider
    global::set_tracer_provider(tracer_provider);

    // Get a tracer and create spans
    let tracer = global::tracer("my_tracer");
    tracer.in_span("doing_work", |_cx| {
        // Your application logic here...
    });

    // Ensure the runtime (`rt`) remains active until the program ends
    Ok(())
}

§Using with Jaeger

Jaeger natively supports the OTLP protocol, making it easy to send traces directly:

$ docker run -p 16686:16686 -p 4317:4317 jaegertracing/jaeger:latest

After running your application configured with the OTLP exporter, view traces at: http://localhost:16686

§Using with Prometheus

Prometheus natively supports accepting metrics via the OTLP protocol (HTTP/protobuf). You can run Prometheus with the following command:

docker run -p 9090:9090 -v ./prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml --web.enable-otlp-receiver

(An empty prometheus.yml file is sufficient for this example.)

Modify your application to export metrics via OTLP:

use opentelemetry::global;
use opentelemetry::metrics::Meter;
use opentelemetry::KeyValue;
use opentelemetry_otlp::Protocol;
use opentelemetry_otlp::WithExportConfig;

fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
    // Initialize OTLP exporter using HTTP binary protocol
    let exporter = opentelemetry_otlp::MetricExporter::builder()
        .with_http()
        .with_protocol(Protocol::HttpBinary)
        .with_endpoint("http://localhost:9090/api/v1/otlp/v1/metrics")
        .build()?;

    // Create a meter provider with the OTLP Metric exporter
    let meter_provider = opentelemetry_sdk::metrics::SdkMeterProvider::builder()
        .with_periodic_exporter(exporter)
        .build();
    global::set_meter_provider(meter_provider.clone());

    // Get a meter
    let meter = global::meter("my_meter");

    // Create a metric
    let counter = meter.u64_counter("my_counter").build();
    counter.add(1, &[KeyValue::new("key", "value")]);

    // Shutdown the meter provider. This will trigger an export of all metrics.
    meter_provider.shutdown()?;

    Ok(())
}

After running your application configured with the OTLP exporter, view metrics at: http://localhost:9090

§Environment Variables

The OTLP exporter respects the following environment variables, as defined by the OpenTelemetry specification. Programmatic configuration via builder methods takes precedence over environment variables. Signal-specific variables take precedence over the generic OTEL_EXPORTER_OTLP_* variables.

§General (all signals)

VariableDescriptionDefault
OTEL_EXPORTER_OTLP_ENDPOINTTarget URL for the exporter. For HTTP, signal paths (/v1/traces, /v1/metrics, /v1/logs) are appended automatically.http://localhost:4318 (HTTP), http://localhost:4317 (gRPC)
OTEL_EXPORTER_OTLP_PROTOCOLTransport protocol. Valid values: grpc, http/protobuf, http/json. Requires the corresponding crate feature.Feature-dependent
OTEL_EXPORTER_OTLP_TIMEOUTMaximum wait time (in milliseconds) for the backend to process each batch.10000
OTEL_EXPORTER_OTLP_HEADERSKey-value pairs for request headers. Format: key1=value1,key2=value2. Values are URL-decoded.(none)
OTEL_EXPORTER_OTLP_COMPRESSIONCompression algorithm. Valid values: gzip, zstd, none.none
OTEL_EXPORTER_OTLP_INSECUREWhether to disable TLS for gRPC connections. Only applies to gRPC; HTTP security is determined by URL scheme. Valid values: true, false (case-insensitive).false

§Traces

VariableDescription
OTEL_EXPORTER_OTLP_TRACES_ENDPOINTSignal-specific endpoint for trace exports.
OTEL_EXPORTER_OTLP_TRACES_PROTOCOLSignal-specific protocol for trace exports. Valid values: grpc, http/protobuf, http/json.
OTEL_EXPORTER_OTLP_TRACES_TIMEOUTSignal-specific timeout (in milliseconds) for trace exports.
OTEL_EXPORTER_OTLP_TRACES_HEADERSSignal-specific headers for trace exports.
OTEL_EXPORTER_OTLP_TRACES_COMPRESSIONSignal-specific compression for trace exports.
OTEL_EXPORTER_OTLP_TRACES_INSECURESignal-specific insecure flag for gRPC trace exports.

§Metrics

VariableDescription
OTEL_EXPORTER_OTLP_METRICS_ENDPOINTSignal-specific endpoint for metrics exports.
OTEL_EXPORTER_OTLP_METRICS_PROTOCOLSignal-specific protocol for metrics exports. Valid values: grpc, http/protobuf, http/json.
OTEL_EXPORTER_OTLP_METRICS_TIMEOUTSignal-specific timeout (in milliseconds) for metrics exports.
OTEL_EXPORTER_OTLP_METRICS_HEADERSSignal-specific headers for metrics exports.
OTEL_EXPORTER_OTLP_METRICS_COMPRESSIONSignal-specific compression for metrics exports.
OTEL_EXPORTER_OTLP_METRICS_INSECURESignal-specific insecure flag for gRPC metrics exports.
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCETemporality preference for metrics. Valid values: cumulative, delta, lowmemory (case-insensitive).

§Logs

VariableDescription
OTEL_EXPORTER_OTLP_LOGS_ENDPOINTSignal-specific endpoint for log exports.
OTEL_EXPORTER_OTLP_LOGS_PROTOCOLSignal-specific protocol for log exports. Valid values: grpc, http/protobuf, http/json.
OTEL_EXPORTER_OTLP_LOGS_TIMEOUTSignal-specific timeout (in milliseconds) for log exports.
OTEL_EXPORTER_OTLP_LOGS_HEADERSSignal-specific headers for log exports.
OTEL_EXPORTER_OTLP_LOGS_COMPRESSIONSignal-specific compression for log exports.
OTEL_EXPORTER_OTLP_LOGS_INSECURESignal-specific insecure flag for gRPC log exports.

§Feature Flags

The following feature flags can enable exporters for different telemetry signals:

  • trace: Includes the trace exporters.
  • metrics: Includes the metrics exporters.
  • logs: Includes the logs exporters.

The following feature flags offer additional configurations on gRPC:

For users using tonic as grpc layer:

  • grpc-tonic: Use tonic as grpc layer.
  • gzip-tonic: Use gzip compression for tonic grpc layer.
  • zstd-tonic: Use zstd compression for tonic grpc layer.
  • tls-ring: Enable rustls TLS support using ring for tonic.
  • tls-aws-lc: Enable rustls TLS support using aws-lc for tonic.
  • tls-provider-agnostic: Provider-agnostic TLS — enables TLS code paths without bundling a specific crypto provider. Use this when you install a CryptoProvider globally (e.g., via rustls-openssl for FIPS/OpenSSL environments).
  • tls-roots: Adds system trust roots to rustls-based gRPC clients using the rustls-native-certs crate (use with tls-ring or tls-aws-lc).
  • tls-webpki-roots: Embeds Mozilla’s trust roots to rustls-based gRPC clients using the webpki-roots crate (use with tls-ring or tls-aws-lc).

The following feature flags offer additional configurations on http:

  • http-proto: Use http as transport layer, protobuf as body format. This feature is enabled by default.
  • gzip-http: Use gzip compression for HTTP transport.
  • zstd-http: Use zstd compression for HTTP transport.
  • reqwest-blocking-client: Use reqwest blocking http client. This feature is enabled by default.
  • reqwest-client: Use reqwest async http client.
  • hyper-client: Use hyper async http client.
  • reqwest-rustls: Use reqwest with TLS. Uses rustls with the platform’s native trust roots by default. If you need Mozilla’s embedded CA bundle (webpki-roots), build a custom reqwest::Client with a rustls::ClientConfig containing rustls::RootCertStore::from_iter(webpki_roots::TLS_SERVER_ROOTS.iter().cloned()), then pass it via with_http_client().

Retry with exponential backoff is always enabled for both gRPC and HTTP exports. Failed exports are automatically retried according to the configured retry policy, with proper classification of retryable vs non-retryable errors and support for server-provided throttling hints (HTTP Retry-After, gRPC RetryInfo).

§Full Configuration Reference

There are two layers of configuration for the OTLP exporter:

  1. Exporter configuration – controls how telemetry is sent (endpoint, transport, headers, TLS, compression, timeout). Built via the signal-specific builder: SpanExporter::builder(), MetricExporter::builder(), LogExporter::builder().
  2. Provider/SDK configuration – controls how telemetry is collected and batched (sampling, batch size, resource, etc.). Built via opentelemetry_sdk::trace::SdkTracerProvider::builder(), opentelemetry_sdk::metrics::SdkMeterProvider::builder(), or opentelemetry_sdk::logs::SdkLoggerProvider::builder().

Configuration precedence (highest wins):

  1. Programmatic configuration via builder methods — always wins when set
  2. Signal-specific environment variables (e.g. OTEL_EXPORTER_OTLP_TRACES_ENDPOINT) — used when no programmatic value is set
  3. Generic environment variables (e.g. OTEL_EXPORTER_OTLP_ENDPOINT) — used when neither programmatic nor signal-specific env var is set
  4. Built-in defaults — used when nothing else is configured

§gRPC (tonic) — all configuration options

Requires the grpc-tonic feature. The methods below come from two traits:

  • WithExportConfig: with_endpoint, with_timeout (shared with HTTP)
  • WithTonicConfig: with_metadata, with_compression, with_tls_config, with_channel, with_interceptor, with_retry_policy

The examples here use SpanExporter, but the same builder methods are available on MetricExporter and LogExporter.

use opentelemetry_otlp::{WithExportConfig, WithTonicConfig, Compression};
use std::time::Duration;
use tonic::metadata::MetadataMap;

// ── gRPC metadata (custom request headers) ───────────────────────────────
// MetadataMap carries per-call key/value pairs sent as HTTP/2 headers.
// with_metadata() is additive: calling it multiple times merges entries.
let mut metadata = MetadataMap::with_capacity(3);
metadata.insert("x-host", "example.com".parse().unwrap());
metadata.insert("x-api-key", "secret".parse().unwrap());
metadata.insert_bin("trace-proto-bin", tonic::metadata::MetadataValue::from_bytes(b"[bin]"));

let exporter = opentelemetry_otlp::SpanExporter::builder()
    .with_tonic()
    // Target gRPC endpoint. Defaults to http://localhost:4317.
    // Env var: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT (or OTEL_EXPORTER_OTLP_ENDPOINT).
    .with_endpoint("http://my-collector:4317")
    // Per-export timeout. Defaults to 10 s.
    // Env var: OTEL_EXPORTER_OTLP_TRACES_TIMEOUT (or OTEL_EXPORTER_OTLP_TIMEOUT).
    .with_timeout(Duration::from_secs(5))
    // Custom gRPC metadata (auth tokens, routing headers, …).
    // Env var: OTEL_EXPORTER_OTLP_TRACES_HEADERS (or OTEL_EXPORTER_OTLP_HEADERS).
    .with_metadata(metadata)
    // Compression. Requires the `gzip-tonic` or `zstd-tonic` feature.
    // Env var: OTEL_EXPORTER_OTLP_TRACES_COMPRESSION (or OTEL_EXPORTER_OTLP_COMPRESSION).
    .with_compression(Compression::Gzip)
    .build()
    .expect("Failed to build SpanExporter");

§TLS (grpc-tonic)

Requires the tls-ring or tls-aws-lc feature (plus optionally tls-roots or tls-webpki-roots to load CA roots automatically).

use opentelemetry_otlp::{WithExportConfig, WithTonicConfig};
use opentelemetry_otlp::tonic_types::transport::ClientTlsConfig;

let tls = ClientTlsConfig::new()
    .domain_name("my-collector.example.com")
    // Optionally verify the server with a CA certificate:
    // .ca_certificate(tonic::transport::Certificate::from_pem(CA_PEM))
    // Or present a client identity for mutual TLS (mTLS):
    // .identity(tonic::transport::Identity::from_pem(CERT_PEM, KEY_PEM))
    ;

let exporter = opentelemetry_otlp::SpanExporter::builder()
    .with_tonic()
    .with_endpoint("https://my-collector.example.com:4317")
    .with_tls_config(tls)
    .build()
    .expect("Failed to build SpanExporter");

§Pre-built tonic channel

Use with_channel when you need full control over the transport (e.g. Unix sockets, custom load-balancing). Note: with_channel overrides any TLS config set via with_tls_config, and you are responsible for matching the channel timeout to the exporter timeout.

use opentelemetry_otlp::{WithExportConfig, WithTonicConfig};
use std::time::Duration;

let channel = tonic::transport::Channel::from_static("http://localhost:4317")
    .timeout(Duration::from_secs(5))
    .connect_lazy();

let exporter = opentelemetry_otlp::SpanExporter::builder()
    .with_tonic()
    .with_channel(channel)
    .with_timeout(Duration::from_secs(5)) // keep in sync with channel timeout above
    .build()
    .expect("Failed to build SpanExporter");

§gRPC interceptors

Use with_interceptor to modify every outbound gRPC request — useful for injecting auth tokens or dynamic metadata. Only one interceptor can be set; chain multiple together before passing them in.

use opentelemetry_otlp::WithTonicConfig;
use tonic::{Request, Status};

fn auth_interceptor(mut req: Request<()>) -> Result<Request<()>, Status> {
    req.metadata_mut().insert("authorization", "Bearer my-token".parse().unwrap());
    Ok(req)
}

let exporter = opentelemetry_otlp::SpanExporter::builder()
    .with_tonic()
    .with_interceptor(auth_interceptor)
    .build()
    .expect("Failed to build SpanExporter");

§gRPC retry policy

Failed exports are retried with exponential backoff and jitter. The retry policy can be customized:

use opentelemetry_otlp::{WithTonicConfig, RetryPolicy};
use std::time::Duration;

let exporter = opentelemetry_otlp::SpanExporter::builder()
    .with_tonic()
    .with_retry_policy(
        RetryPolicy::default()
            .with_max_retries(5)
            .with_initial_delay(Duration::from_millis(500))
            .with_max_delay(Duration::from_secs(30))
            .with_max_jitter(Duration::from_millis(100)),
    )
    .build()
    .expect("Failed to build SpanExporter");

§HTTP — all configuration options

Requires the http-proto (default) or http-json feature. The methods below come from:

  • WithExportConfig: with_endpoint, with_timeout, with_protocol
  • WithHttpConfig: with_headers, with_compression, with_http_client, with_retry_policy, with_max_request_body_size

The examples here use SpanExporter, but the same builder methods are available on MetricExporter and LogExporter.

use opentelemetry_otlp::{WithExportConfig, WithHttpConfig, Protocol, Compression};
use std::time::Duration;
use std::collections::HashMap;

let exporter = opentelemetry_otlp::SpanExporter::builder()
    .with_http()
    // Target URL, used verbatim: include the signal path, e.g. /v1/traces.
    // OTEL_EXPORTER_OTLP_TRACES_ENDPOINT is also used verbatim.
    // OTEL_EXPORTER_OTLP_ENDPOINT is a base URL and appends /v1/traces automatically.
    // Defaults to http://localhost:4318/v1/traces.
    .with_endpoint("http://my-collector:4318/v1/traces")
    // Per-export timeout. Defaults to 10 s.
    // Env var: OTEL_EXPORTER_OTLP_TRACES_TIMEOUT (or OTEL_EXPORTER_OTLP_TIMEOUT).
    .with_timeout(Duration::from_secs(5))
    // Transport encoding. HttpBinary (protobuf) is the default.
    // HttpJson requires the `http-json` feature.
    // Env var: OTEL_EXPORTER_OTLP_PROTOCOL.
    .with_protocol(Protocol::HttpBinary)
    // Custom HTTP headers (auth tokens, routing headers, …).
    // Values are URL-decoded when read from environment variables.
    // Env var: OTEL_EXPORTER_OTLP_TRACES_HEADERS (or OTEL_EXPORTER_OTLP_HEADERS).
    .with_headers(HashMap::from([
        ("x-api-key".to_string(), "secret".to_string()),
    ]))
    // Compression. Requires the `gzip-http` or `zstd-http` feature.
    // Env var: OTEL_EXPORTER_OTLP_TRACES_COMPRESSION (or OTEL_EXPORTER_OTLP_COMPRESSION).
    .with_compression(Compression::Gzip)
    // Maximum serialized HTTP request size before and after compression.
    // Defaults to the OTLP-recommended 64 MiB.
    .with_max_request_body_size(64 * 1024 * 1024)
    .build()
    .expect("Failed to build SpanExporter");

§Custom HTTP client

By default the exporter uses a reqwest blocking client (reqwest-blocking-client feature, enabled by default). Supply your own client to control TLS, proxies, connection pooling, etc. The client must implement the opentelemetry_http::HttpClient trait.

The standard SDK path uses the default BatchSpanProcessor, BatchLogProcessor, and PeriodicReader. These components run exports on SDK-owned background threads, so OTLP/HTTP should use the default reqwest-blocking-client with them.

HTTP client selection is based on enabled crate features and is not aware of the SDK processor or metric reader that will drive the exporter. If you enable async HTTP clients such as reqwest-client or hyper-client, do not use them with the default batch processors or periodic reader.

use opentelemetry_otlp::WithHttpConfig;

// reqwest async client (requires the `reqwest-client` feature)
let http_client = reqwest::Client::builder()
    .timeout(std::time::Duration::from_secs(5))
    // .danger_accept_invalid_certs(true) // for testing only
    .build()
    .expect("Failed to build reqwest client");

let exporter = opentelemetry_otlp::SpanExporter::builder()
    .with_http()
    .with_http_client(http_client)
    .build()
    .expect("Failed to build SpanExporter");

§HTTP retry policy

Failed exports are retried with exponential backoff and jitter. The retry policy can be customized:

use opentelemetry_otlp::{WithHttpConfig, RetryPolicy};
use std::time::Duration;

let exporter = opentelemetry_otlp::SpanExporter::builder()
    .with_http()
    .with_retry_policy(
        RetryPolicy::default()
            .with_max_retries(5)
            .with_initial_delay(Duration::from_millis(500))
            .with_max_delay(Duration::from_secs(30))
            .with_max_jitter(Duration::from_millis(100)),
    )
    .build()
    .expect("Failed to build SpanExporter");

§All three signals (Traces, Metrics, Logs)

The same exporter configuration options apply to all three signals. The only differences are:

use opentelemetry_otlp::{WithExportConfig, WithTonicConfig};
use opentelemetry_sdk::{
    trace::SdkTracerProvider,
    metrics::SdkMeterProvider,
    logs::SdkLoggerProvider,
    Resource,
};
use std::time::Duration;

let resource = Resource::builder()
    .with_service_name("my-service")
    .build();

// Traces
let span_exporter = opentelemetry_otlp::SpanExporter::builder()
    .with_tonic()
    .with_endpoint("http://my-collector:4317")
    .with_timeout(Duration::from_secs(5))
    .build()
    .expect("Failed to build SpanExporter");
let tracer_provider = SdkTracerProvider::builder()
    .with_resource(resource.clone())
    .with_batch_exporter(span_exporter)
    .build();

// Metrics
let metric_exporter = opentelemetry_otlp::MetricExporter::builder()
    .with_tonic()
    .with_endpoint("http://my-collector:4317")
    .with_timeout(Duration::from_secs(5))
    .build()
    .expect("Failed to build MetricExporter");
let meter_provider = SdkMeterProvider::builder()
    .with_resource(resource.clone())
    .with_periodic_exporter(metric_exporter)
    .build();

// Logs
let log_exporter = opentelemetry_otlp::LogExporter::builder()
    .with_tonic()
    .with_endpoint("http://my-collector:4317")
    .with_timeout(Duration::from_secs(5))
    .build()
    .expect("Failed to build LogExporter");
let logger_provider = SdkLoggerProvider::builder()
    .with_resource(resource)
    .with_batch_exporter(log_exporter)
    .build();

Modules§

tonic_typesgrpc-tonic
Re-exported types from the tonic crate.

Structs§

HttpExporterBuilderSethttp-json or http-proto
Type indicating that the HTTP transport has been selected.
LogExporterlogs and (grpc-tonic or http-json or http-proto)
OTLP exporter that sends log data
LogExporterBuilderlogs and (grpc-tonic or http-json or http-proto)
Builder for creating a new LogExporter.
MetricExportermetrics and (grpc-tonic or http-json or http-proto)
Export metrics in OTEL format.
MetricExporterBuildermetrics and (grpc-tonic or http-json or http-proto)
A builder for creating a new MetricExporter.
NoExporterBuilderSet
Type to indicate the builder does not have a client set.
ParseConfigError
An error parsing an OTLP configuration value.
RetryPolicygrpc-tonic or http-json or http-proto
Configuration for retry policy.
SpanExportertrace and (grpc-tonic or http-json or http-proto)
OTLP exporter that sends tracing data
SpanExporterBuildertrace and (grpc-tonic or http-json or http-proto)
OTLP span exporter builder
TonicExporterBuilderSetgrpc-tonic
Type indicating that the tonic transport has been selected.

Enums§

Compression
The compression algorithm to use when sending data.
ExporterBuildError
Errors that can occur while building an exporter.
Protocol
The communication protocol to use when exporting data.

Constants§

OTEL_EXPORTER_OTLP_COMPRESSION
Compression algorithm to use, defaults to none.
OTEL_EXPORTER_OTLP_ENDPOINT
Target to which the exporter sends signals.
OTEL_EXPORTER_OTLP_HEADERS
Key-value pairs to be used as headers associated with gRPC or HTTP requests Example: k1=v1,k2=v2 Note: as of now, this is only supported for HTTP requests.
OTEL_EXPORTER_OTLP_INSECURE
Whether to disable TLS for the exporter’s gRPC connection. Per the OTLP exporter spec, this only applies to gRPC endpoints that have no explicit scheme; an endpoint with an explicit scheme is used as-is. HTTP security is determined by the endpoint URL scheme. There is intentionally no programmatic builder method — this is env-var-only. Default: false (TLS is used).
OTEL_EXPORTER_OTLP_LOGS_COMPRESSIONlogs and (grpc-tonic or http-json or http-proto)
Compression algorithm to use, defaults to none.
OTEL_EXPORTER_OTLP_LOGS_ENDPOINTlogs and (grpc-tonic or http-json or http-proto)
Target to which the exporter is going to send logs
OTEL_EXPORTER_OTLP_LOGS_HEADERSlogs and (grpc-tonic or http-json or http-proto)
Key-value pairs to be used as headers associated with gRPC or HTTP requests for sending logs. Example: k1=v1,k2=v2 Note: this is only supported for HTTP.
OTEL_EXPORTER_OTLP_LOGS_INSECURElogs and (grpc-tonic or http-json or http-proto)
Whether to disable TLS for gRPC log exports. Only applies to gRPC; HTTP security is determined by URL scheme.
OTEL_EXPORTER_OTLP_LOGS_PROTOCOLlogs and (grpc-tonic or http-json or http-proto)
Protocol to use for log exports. Valid values: grpc, http/protobuf, http/json.
OTEL_EXPORTER_OTLP_LOGS_TIMEOUTlogs and (grpc-tonic or http-json or http-proto)
Maximum time the OTLP exporter will wait for each batch logs export.
OTEL_EXPORTER_OTLP_METRICS_COMPRESSIONmetrics and (grpc-tonic or http-json or http-proto)
Compression algorithm to use, defaults to none.
OTEL_EXPORTER_OTLP_METRICS_ENDPOINTmetrics and (grpc-tonic or http-json or http-proto)
Target to which the exporter is going to send metrics, defaults to https://localhost:4317/v1/metrics. Learn about the relationship between this constant and default/spans/logs at https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#endpoint-urls-for-otlphttp
OTEL_EXPORTER_OTLP_METRICS_HEADERSmetrics and (grpc-tonic or http-json or http-proto)
Key-value pairs to be used as headers associated with gRPC or HTTP requests for sending metrics. Example: k1=v1,k2=v2 Note: this is only supported for HTTP.
OTEL_EXPORTER_OTLP_METRICS_INSECUREmetrics and (grpc-tonic or http-json or http-proto)
Whether to disable TLS for gRPC metrics exports. Only applies to gRPC; HTTP security is determined by URL scheme.
OTEL_EXPORTER_OTLP_METRICS_PROTOCOLmetrics and (grpc-tonic or http-json or http-proto)
Protocol to use for metrics exports. Valid values: grpc, http/protobuf, http/json.
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCEmetrics and (grpc-tonic or http-json or http-proto)
Temporality preference for metrics, defaults to cumulative.
OTEL_EXPORTER_OTLP_METRICS_TIMEOUTmetrics and (grpc-tonic or http-json or http-proto)
Max waiting time for the backend to process each metrics batch, defaults to 10s.
OTEL_EXPORTER_OTLP_PROTOCOL
Protocol the exporter will use. Either http/protobuf or grpc.
OTEL_EXPORTER_OTLP_PROTOCOL_GRPC
Protocol value for gRPC
OTEL_EXPORTER_OTLP_PROTOCOL_HTTP_JSON
Protocol value for HTTP with JSON encoding
OTEL_EXPORTER_OTLP_PROTOCOL_HTTP_PROTOBUF
Protocol value for HTTP with protobuf encoding
OTEL_EXPORTER_OTLP_TIMEOUT
Max waiting time for the backend to process each signal batch, defaults to 10 seconds.
OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT
Default max waiting time for the backend to process each signal batch.
OTEL_EXPORTER_OTLP_TRACES_COMPRESSIONtrace and (grpc-tonic or http-json or http-proto)
Compression algorithm to use, defaults to none.
OTEL_EXPORTER_OTLP_TRACES_ENDPOINTtrace and (grpc-tonic or http-json or http-proto)
Target to which the exporter is going to send spans, defaults to https://localhost:4317/v1/traces. Learn about the relationship between this constant and default/metrics/logs at https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#endpoint-urls-for-otlphttp
OTEL_EXPORTER_OTLP_TRACES_HEADERStrace and (grpc-tonic or http-json or http-proto)
Key-value pairs to be used as headers associated with gRPC or HTTP requests for sending spans. Example: k1=v1,k2=v2 Note: this is only supported for HTTP.
OTEL_EXPORTER_OTLP_TRACES_INSECUREtrace and (grpc-tonic or http-json or http-proto)
Whether to disable TLS for gRPC trace exports. Only applies to gRPC; HTTP security is determined by URL scheme.
OTEL_EXPORTER_OTLP_TRACES_PROTOCOLtrace and (grpc-tonic or http-json or http-proto)
Protocol to use for trace exports. Valid values: grpc, http/protobuf, http/json.
OTEL_EXPORTER_OTLP_TRACES_TIMEOUTtrace and (grpc-tonic or http-json or http-proto)
Max waiting time for the backend to process each spans batch, defaults to 10s.

Traits§

WithExportConfig
Expose methods to set export configuration on exporter builders.
WithHttpConfighttp-json or http-proto
Expose methods to override HTTP-specific configuration.
WithTonicConfiggrpc-tonic
Expose methods to override tonic-specific configuration.