Skip to main content

Overview

The OTLP gRPC exporter provides a high-performance alternative to HTTP for sending traces, metrics, and logs. gRPC offers better throughput and lower latency, making it ideal for high-volume production environments.

Dependencies

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

Exporting Traces via gRPC

1

Configure OTLP gRPC Exporter

Set up the OTLP exporter with gRPC transport using Tonic.
2

Configure TLS and Authentication

Add TLS and metadata for secure connections.
3

Use the Tracer

Create and export spans normally.

Exporting Metrics via gRPC

Exporting Logs via gRPC

gRPC-Specific Configuration

Connection Settings

Compression

gRPC compression can significantly reduce network bandwidth usage, especially for high-volume telemetry data.

HTTP vs gRPC Comparison

For most production use cases, gRPC is recommended due to better performance. Use HTTP if you have strict firewall requirements or need easier debugging.

Environment Variables

The OTLP gRPC exporter respects standard OpenTelemetry environment variables:

Common Endpoints

Local OpenTelemetry Collector

Secure Connection

Complete Example: All Signals

Here’s a complete example exporting traces, metrics, and logs via gRPC:
Always shutdown all providers in the correct order (traces, metrics, logs) to ensure all telemetry data is flushed before the application exits.