-
Notifications
You must be signed in to change notification settings - Fork 499
fix(tracing): honor OTEL resource env config #7061
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7012fe7
c452c4e
60e65ad
0b4c16b
0a76332
9cf86e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,6 @@ | ||
| mod config; | ||
|
|
||
| use std::{ | ||
| sync::{LazyLock, Mutex}, | ||
| time::Duration, | ||
| }; | ||
| use std::sync::{LazyLock, Mutex}; | ||
|
|
||
| use common_runtime::get_io_runtime; | ||
| pub use config::Config; | ||
|
|
@@ -53,7 +50,7 @@ impl TraceFormat { | |
|
|
||
| pub fn init_tracing() { | ||
| let config = Config::from_env(); | ||
| let resource = Resource::builder().with_service_name("daft").build(); | ||
| let resource = config.resource(); | ||
| let tracer_provider = if config.enabled() { | ||
| let runtime = get_io_runtime(true); | ||
| runtime.block_on_current_thread(async { | ||
|
|
@@ -158,7 +155,6 @@ fn init_otlp_logger_provider(config: &Config, otlp_endpoint: &str, resource: Res | |
| let log_exporter = opentelemetry_otlp::LogExporter::builder() | ||
| .with_tonic() | ||
| .with_endpoint(otlp_endpoint) | ||
| .with_timeout(Duration::from_secs(10)) | ||
| .build() | ||
| .expect("Failed to build OTLP logger exporter."); | ||
|
|
||
|
|
@@ -188,14 +184,12 @@ fn init_otlp_metrics_provider(config: &Config, endpoint: &str, resource: Resourc | |
| opentelemetry_otlp::MetricExporter::builder() | ||
| .with_tonic() | ||
| .with_endpoint(endpoint) | ||
| .with_timeout(Duration::from_secs(10)) | ||
| .build() | ||
| } | ||
| Protocol::HttpBinary => { | ||
| opentelemetry_otlp::MetricExporter::builder() | ||
| .with_http() | ||
| .with_endpoint(endpoint) | ||
| .with_timeout(Duration::from_secs(10)) | ||
| .with_protocol(config.otlp_protocol) | ||
| .build() | ||
| } | ||
|
|
@@ -242,7 +236,6 @@ fn init_otlp_tracer_provider( | |
| let exporter = opentelemetry_otlp::SpanExporter::builder() | ||
| .with_tonic() | ||
| .with_endpoint(otlp_endpoint) | ||
| .with_timeout(Duration::from_secs(10)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is now being read from the env what is the default if it's not set?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like the defaults were already 10s: https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/#timeout-configuration |
||
| .build() | ||
| .expect("Failed to build OTLP span exporter for tracing"); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the closure
f()panics (e.g. an assertion fires), theforloop that restores the previous values never executes, leaving the modified env vars behind for every subsequent test in the process. TheENV_LOCKmutex will also be poisoned by the panic, causing all laterwith_env_varscalls to propagate the poison via.unwrap(). ADrop-based restore guard would fix both problems.