Skip to content

Commit

Permalink
fix: Resolve some build issues (especially around libssl)
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Apr 23, 2024
1 parent 7c858f3 commit 1d8461f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ async-trait = "0.1"
clap = { version = "4.5", features = ["derive"] }
futures = "0.3"
lazy_static = "1.4"
openssl-sys = { version = "0.9", features = ["vendored"] }
opentelemetry = { version = "0.22" }
opentelemetry-otlp = { version = "0.15", features = ["tls-roots"] }
opentelemetry_sdk = { version = "0.22", features = ["rt-tokio"] }
Expand Down
31 changes: 13 additions & 18 deletions src/telemetry.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use opentelemetry::global;
use opentelemetry_otlp::WithExportConfig;
use opentelemetry_sdk::propagation::TraceContextPropagator;
use opentelemetry_sdk::{propagation::TraceContextPropagator, trace::Sampler};
use tracing::Subscriber;
use tracing_subscriber::{prelude::*, registry::LookupSpan, Layer};

Expand Down Expand Up @@ -50,31 +50,31 @@ fn load_otlp_headers() -> tonic::metadata::MetadataMap {
tracing_metadata
}

fn load_trace_sampler() -> opentelemetry_sdk::trace::Sampler {
fn load_trace_sampler() -> Sampler {
fn get_trace_ratio() -> f64 {
std::env::var("OTEL_TRACES_SAMPLER_ARG")
.ok()
.and_then(|ratio| ratio.parse().ok())
.unwrap_or(1.0)
}

match std::env::var("OTEL_TRACES_SAMPLER") {
Ok(&"always_on") => opentelemetry_sdk::trace::Sampler::AlwaysOn,
Ok(&"always_off") => opentelemetry_sdk::trace::Sampler::AlwaysOff,
Ok(&"traceidratio") => {
std::env::var("OTEL_TRACES_SAMPLER").map(|s| match s.as_str() {
"always_on" => opentelemetry_sdk::trace::Sampler::AlwaysOn,
"always_off" => opentelemetry_sdk::trace::Sampler::AlwaysOff,
"traceidratio" => {
opentelemetry_sdk::trace::Sampler::TraceIdRatioBased(get_trace_ratio())
}
Ok(&"parentbased_always_on") => opentelemetry_sdk::trace::Sampler::ParentBased(
opentelemetry_sdk::trace::Sampler::AlwaysOn,
"parentbased_always_on" => opentelemetry_sdk::trace::Sampler::ParentBased(
Box::new(opentelemetry_sdk::trace::Sampler::AlwaysOn),
),
Ok(&"parentbased_always_off") => opentelemetry_sdk::trace::Sampler::ParentBased(
opentelemetry_sdk::trace::Sampler::AlwaysOff,
"parentbased_always_off" => opentelemetry_sdk::trace::Sampler::ParentBased(
Box::new(opentelemetry_sdk::trace::Sampler::AlwaysOff),
),
Ok(&"parentbased_traceidratio") => opentelemetry_sdk::trace::Sampler::ParentBased(
opentelemetry_sdk::trace::Sampler::TraceIdRatioBased(get_trace_ratio()),
"parentbased_traceidratio" => opentelemetry_sdk::trace::Sampler::ParentBased(
Box::new(opentelemetry_sdk::trace::Sampler::TraceIdRatioBased(get_trace_ratio())),
),
_ => opentelemetry_sdk::trace::Sampler::AlwaysOn,
}
}).unwrap_or(opentelemetry_sdk::trace::Sampler::AlwaysOn)
}

fn load_output_layer<S>() -> Box<dyn Layer<S> + Send + Sync + 'static>
Expand All @@ -88,11 +88,6 @@ where
#[cfg(debug_assertions)]
let tracing_endpoint = Some("https://api.honeycomb.io:443".to_string());

let sampling_ratio = std::env::var("OTEL_EXPORTER_OTLP_SAMPLING_RATIO")
.ok()
.and_then(|ratio| ratio.parse().ok())
.unwrap_or(1.0);

if let Some(endpoint) = tracing_endpoint {
let metadata = load_otlp_headers();
let tracer = opentelemetry_otlp::new_pipeline()
Expand Down

0 comments on commit 1d8461f

Please sign in to comment.