Skip to main content

Overview

The OTLP (OpenTelemetry Protocol) HTTP exporter allows you to send traces, metrics, and logs to any OpenTelemetry-compatible backend over HTTP. This is the recommended protocol for production deployments.

Dependencies

Add these dependencies to your Cargo.toml:
Cargo.toml

Exporting Traces via HTTP

1

Configure OTLP HTTP Exporter

Set up the OTLP exporter with HTTP transport.
2

Configure Authentication

Add headers for authentication if required by your backend.
3

Use the Tracer

Create and export spans as usual.

Exporting Metrics via HTTP

Exporting Logs via HTTP

Protocol Options

The OTLP HTTP exporter supports two protocols:
Use Protocol::HttpBinary for production as it’s more efficient. Use Protocol::HttpJson for development and debugging.

Common Backend Endpoints

Local OpenTelemetry Collector

Cloud Providers

Most cloud providers require custom endpoints and authentication headers:

Configuration via Environment Variables

The OTLP exporter respects standard OpenTelemetry environment variables:
When using environment variables, you can create exporters without explicit configuration in code. The SDK will automatically read these values.

Batch Configuration

Configure batching behavior for better performance:

Error Handling

Always handle exporter initialization errors gracefully. In production, you may want to fall back to a stdout exporter or disable telemetry if the backend is unavailable.