Open bangbaew opened 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.
Maybe this crate could do the work (not tested): opentelemetry-appender-tracing - crates.io: Rust Package Registry
According to the Official OpenTelemetry Website , if I set
OTEL_EXPORTER_OTLP_ENDPOINT
env, it will apply to allOTEL_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?