Skip to content
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

Global error handler cleanup - Jaeger Remote sampler #2257

Merged
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use opentelemetry::trace::TraceError;
use std::time::SystemTime;

// leaky bucket based rate limit
Expand All @@ -9,6 +8,7 @@
bucket_size: f64,
last_time: SystemTime,
}
use opentelemetry::otel_debug;

impl LeakyBucket {
pub(crate) fn new(bucket_size: f64, span_per_sec: f64) -> LeakyBucket {
Expand Down Expand Up @@ -53,10 +53,12 @@
false
}
}
Err(_) => {
opentelemetry::global::handle_error(TraceError::Other(
"jaeger remote sampler gets rewinded timestamp".into(),
));
Err(err) => {
otel_debug!(

Check warning on line 57 in opentelemetry-sdk/src/trace/sampler/jaeger_remote/rate_limit.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/trace/sampler/jaeger_remote/rate_limit.rs#L56-L57

Added lines #L56 - L57 were not covered by tests
name: "JaegerRemoteSampler.LeakyBucket.ClockAdjustment",
message = "Jaeger remote sampler detected a rewind in system clock",
reason = format!("{:?}", err),

Check warning on line 60 in opentelemetry-sdk/src/trace/sampler/jaeger_remote/rate_limit.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/trace/sampler/jaeger_remote/rate_limit.rs#L60

Added line #L60 was not covered by tests
);
true
}
}
Expand Down
10 changes: 8 additions & 2 deletions opentelemetry-sdk/src/trace/sampler/jaeger_remote/sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use futures_util::{stream, StreamExt as _};
use http::Uri;
use opentelemetry::trace::{Link, SamplingResult, SpanKind, TraceError, TraceId};
use opentelemetry::{global, Context, KeyValue};
use opentelemetry::{otel_warn, Context, KeyValue};
use opentelemetry_http::HttpClient;
use std::str::FromStr;
use std::sync::Arc;
Expand Down Expand Up @@ -203,7 +203,13 @@
// send request
match Self::request_new_strategy(&client, endpoint.clone()).await {
Ok(remote_strategy_resp) => strategy.update(remote_strategy_resp),
Err(err_msg) => global::handle_error(TraceError::Other(err_msg.into())),
Err(err_msg) => {
otel_warn!(

Check warning on line 207 in opentelemetry-sdk/src/trace/sampler/jaeger_remote/sampler.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/trace/sampler/jaeger_remote/sampler.rs#L206-L207

Added lines #L206 - L207 were not covered by tests
name: "JaegerRemoteSampler.UpdateStrategy.RequestFailed",
lalitb marked this conversation as resolved.
Show resolved Hide resolved
message= "Failed to fetch the sampling strategy from the remote endpoint. The last successfully fetched configuration will be used if available; otherwise, the default sampler will be applied until a successful configuration fetch.",
reason = format!("{}", err_msg),

Check warning on line 210 in opentelemetry-sdk/src/trace/sampler/jaeger_remote/sampler.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/trace/sampler/jaeger_remote/sampler.rs#L210

Added line #L210 was not covered by tests
);
}
};
} else {
// shutdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
};
use crate::trace::sampler::sample_based_on_probability;
use opentelemetry::trace::{
SamplingDecision, SamplingResult, TraceContextExt, TraceError, TraceId, TraceState,
SamplingDecision, SamplingResult, TraceContextExt, TraceId, TraceState,
};
use opentelemetry::{global, Context};
use opentelemetry::{otel_warn, Context};
use std::collections::HashMap;
use std::fmt::{Debug, Formatter};
use std::sync::Mutex;
Expand Down Expand Up @@ -107,9 +107,10 @@
}
})
.unwrap_or_else(|_err| {
global::handle_error(TraceError::Other(
"jaeger remote sampler mutex poisoned".into(),
))
otel_warn!(
name: "JaegerRemoteSampler.MutexPoisoned",
message = "Unable to update Jaeger Remote sampling strategy: the sampler's internal mutex is poisoned, likely due to a panic in another thread holding the lock. The last known configuration will continue to be used until the remote sampling client is restarted.",
lalitb marked this conversation as resolved.
Show resolved Hide resolved
);

Check warning on line 113 in opentelemetry-sdk/src/trace/sampler/jaeger_remote/sampling_strategy.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/trace/sampler/jaeger_remote/sampling_strategy.rs#L110-L113

Added lines #L110 - L113 were not covered by tests
});
}

Expand Down Expand Up @@ -137,7 +138,13 @@
(_, _, Some(probabilistic)) => {
Some(Strategy::Probabilistic(probabilistic.sampling_rate))
}
_ => None,
_ => {
otel_warn!(
name: "Sampler.JaegerRemote.InvalidStrategy",
lalitb marked this conversation as resolved.
Show resolved Hide resolved
message = "Invalid sampling strategy received from the remote endpoint. Expected one of: OperationSampling, RateLimitingSampling, or ProbabilisticSampling. Continuing to use the previous strategy or default sampler until a successful update.",
);
None

Check warning on line 146 in opentelemetry-sdk/src/trace/sampler/jaeger_remote/sampling_strategy.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/trace/sampler/jaeger_remote/sampling_strategy.rs#L142-L146

Added lines #L142 - L146 were not covered by tests
}
}
}

Expand Down
Loading