forked from open-telemetry/opentelemetry-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
opentelemetry-zipkin: Add Environment Variables
As described in https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md * Add support for: ** OTEL_EXPORTER_ZIPKIN_ENDPOINT ** OTEL_EXPORTER_ZIPKIN_TIMEOUT * Update Default to use Closes open-telemetry#534
- Loading branch information
Showing
3 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use crate::ZipkinPipelineBuilder; | ||
|
||
/// HTTP endpoint for Zipkin collector. | ||
/// e.g. "http://localhost:9411/api/v2/spans" | ||
#[cfg(feature = "collector_client")] | ||
const ENV_ENDPOINT: &str = "OTEL_EXPORTER_ZIPKIN_ENDPOINT"; | ||
|
||
/// Maximum time the Zipkin exporter will wait for each batch export | ||
#[cfg(feature = "collector_client")] | ||
const ENV_TIMEOUT: &str = "OTEL_EXPORTER_ZIPKIN_TIMEOUT"; | ||
|
||
/// Assign builder attributes from env | ||
pub(crate) fn assign_attrs(builder: ZipkinPipelineBuilder) -> ZipkinPipelineBuilder { | ||
|
||
#[cfg(any( | ||
feature = "reqwest-client", | ||
feature = "surf-client", | ||
feature = "reqwest-blocking-client" | ||
))] | ||
{ | ||
if let Some(endpoint) = env::var(ENV_ENDPOINT).ok().filter(|var| !var.is_empty()) { | ||
builder = builder.with_collector_endpoint(endpoint); | ||
} | ||
} | ||
|
||
#[cfg(any( | ||
feature = "reqwest-client", | ||
feature = "surf-client", | ||
feature = "reqwest-blocking-client" | ||
))] | ||
{ | ||
// TODO: Need to parse from strings | ||
if let Some(timeout) = env::var(ENV_TIMEOUT).ok().filter(|var| !var.is_empty()) { | ||
let timeout = duration_str::parse(timeout) | ||
.expect(format!("{} is not formatted correctly.",ENV_TIMEOUT)); | ||
|
||
#[cfg(feature = "reqwest-blocking-client")] | ||
let client = reqwest::blocking::Client::builder().timeout(timeout).build().unwrap(); | ||
#[cfg(all( | ||
not(feature = "reqwest-blocking-client"), | ||
not(feature = "surf-client"), | ||
feature = "reqwest-client" | ||
))] | ||
let client = reqwest::Client::builder().timeout(timeout).build().unwrap(); | ||
#[cfg(all( | ||
not(feature = "reqwest-client"), | ||
not(feature = "reqwest-blocking-client"), | ||
feature = "surf-client" | ||
))] | ||
let client: surf::Client = surf::Config::new() | ||
.set_timeout(Some()).into(); | ||
|
||
builder = builder.with_http_client(client); | ||
} | ||
} | ||
|
||
builder | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters