davidB / tracing-opentelemetry-instrumentation-sdk

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

The otel::tracing log level is not set to the same or lower level than TRACING_LEVEL, which makes span.set_parent() invalid. #148

Open Lvzhenqian opened 4 months ago

Lvzhenqian commented 4 months ago

Cargo.toml

axum = "0.7"
tracing = "0.1"
tracing-opentelemetry = "0.24.0"
opentelemetry = "0.23.0"
opentelemetry_sdk = { version = "0.23.0", features = ["rt-tokio"] }
opentelemetry-otlp = { version = "0.16", features = ["trace", "tonic"] }
opentelemetry-semantic-conventions = "0.15"
axum-tracing-opentelemetry = "0.19"
tracing-opentelemetry-instrumentation-sdk = { version = "0.19", features = [
    "tracing_level_info",
] }
init-tracing-opentelemetry = "0.19"
tracing-subscriber = { version = "0.3", features = [
    "env-filter",
    "std",
    "local-time",
    "ansi",
    "json",
] }
tracing-appender = "0.2"

The span generated before setting will not bring in the traceparent id of the http request: 1 After configuring the tagger log level, it can be normally associated with the incoming trace: 2

davidB commented 2 months ago

I release a new version of axum-tracing-opentelemetry with the missing feature flag "tracing_level_info".

Bad new, this version is for opentelemetry 0.24 and the auto-bump version releases axum-tracing-opentelemetry with version 0.19.1

lcmgh commented 2 months ago

My tracing otlp tonic export setup works pretty fine but tonic-tracing-opentelemetry = { version = "0.20.0", features = ["tracing_level_info"] } is not exporting / producing anything to my otel backend (jaeger).

For other things I use tracing-opentelemetry = "0.25.0"

My overcall tracing level is INFO. I tried with and without ["tracing_level_info"] so I don't really know what's going on.

davidB commented 1 month ago

opentelemetry use static variables, you should not have multiple version of opentelemetry (else tracer could not be connected to your configured exporter,...)

# Check only one version of opentelemetry_api should be used
# else issue with setup of global (static variable)
# check_single_version_opentelemtry:
cargo tree -i opentelemetry_api
lcmgh commented 1 month ago

Before using this crate I have no results for cargo tree -i opentelemetry_api.

For cargo tree -i opentelemetry_sdk I get

opentelemetry_sdk v0.24.1
├── opentelemetry-otlp v0.17.0
│   └── private-init v0.1.33 
│       └── myservice v0.1.0 (/Users/user/Code/..)
├── opentelemetry-proto v0.7.0
│   └── opentelemetry-otlp v0.17.0 (*)
├── private-init v0.1.33
└── tracing-opentelemetry v0.25.0
    └── private-init v0.1.33