This project is a sample code that collects trace logs using OpenTelemetry in Rust and sends them to Jaeger or Google Cloud Trace. It sends trace data using the OTLP gRPC protocol.
- Collection of traces using the OpenTelemetry SDK
- Sending trace data to Jaeger using the OTLP gRPC protocol
- Sending trace data to Google Cloud Trace
- Standard output logs in JSON format
- Integration of tracing and logging
- Exporter selection feature via environment variables
- Rust (latest version recommended)
- Docker and Docker Compose (when running with Docker Compose)
- GCP project and authentication settings when using Google Cloud Trace
-
Start Jaeger locally:
docker compose up -d
-
Build and run the application:
OTEL_EXPORTER=jaeger JAEGER_ENDPOINT=http://localhost:4317 RUST_LOG=info cargo run
-
Access the Jaeger UI: http://localhost:16686
-
GCP authentication settings:
# Set up ADC using gcloud gcloud auth application-default login
-
Run the application:
OTEL_EXPORTER=cloud_trace GOOGLE_CLOUD_PROJECT=your-project-id cargo run
RUST_LOG
: Control the log level (e.g.,info
,debug
,warn
)OTEL_EXPORTER
: Specify the exporter to use (jaeger
orcloud_trace
, default:jaeger
)JAEGER_ENDPOINT
: Jaeger's OTLP endpoint (default:http://localhost:4317
)GOOGLE_CLOUD_PROJECT
: Google Cloud Project ID