davidB / tracing-opentelemetry-instrumentation-sdk

Middlewares and tools to integrate axum + tracing + opentelemetry
Creative Commons Zero v1.0 Universal
149 stars 42 forks source link

How to export logs on grpc endpoint? #100

Open bangbaew opened 1 year ago

bangbaew commented 1 year ago

According to the Official OpenTelemetry Website , if I set OTEL_EXPORTER_OTLP_ENDPOINT env, it will apply to all OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, OTEL_EXPORTER_OTLP_LOGS_ENDPOINT, but this crate seems to apply to only OTEL_EXPORTER_OTLP_TRACES_ENDPOINT as shown on startup, I wanna export Axum logs to OpenTelemetry Collector endpoint, which is then exported to Loki.

I could do this in Actix Web using opentelemetry_appender_log crate, I wonder how to achieve this in Axum? image

davidB commented 1 year ago

I could do this in Actix Web using opentelemetry_appender_log crate, I wonder how to achieve this in Axum?

Currently, I don't know. I'll look at how actixweb does (I'm also interested, but currently I used a dedicated agent fluentd/fluentbit for logs). And last time I look at opentelemetry on rust, metrics was is beta iirc, and logs in alpha or not supported. From Rust | OpenTelemetry: metrics & log are in alpha, and traces in beta.

PR is welcome, if you want to contribute.

davidB commented 1 year ago

Maybe this crate could do the work (not tested): opentelemetry-appender-tracing - crates.io: Rust Package Registry