Comments (2)
The otel suggested way to filter spans is to provide your own sampler using the ShouldSample
trait.
#[derive(Debug)]
struct MySampler(Box<dyn sdk::trace::ShouldSample>);
impl sdk::trace::ShouldSample for MySampler {
fn should_sample(
&self,
parent_context: Option<&opentelemetry::Context>,
trace_id: opentelemetry::trace::TraceId,
name: &str,
span_kind: &opentelemetry::trace::SpanKind,
attributes: &[opentelemetry::KeyValue],
links: &[opentelemetry::trace::Link],
instrumentation_library: &sdk::InstrumentationLibrary,
) -> sdk::trace::SamplingResult {
// find names / attributes / other information you don't want to sample
if name == "/health-check" {
sdk::trace::SamplingResult {
attributes: Vec::new(),
decision: sdk::trace::SamplingDecision::Drop, // Drop these spans
trace_state: Default::default(),
}
} else {
// fall back to whichever default sampling logic you have configured
self.0.should_sample(
parent_context,
trace_id,
name,
span_kind,
attributes,
links,
instrumentation_library,
)
}
}
}
// configure your sampler with whichever default sampling behavior you prefer
let my_sampler = MySampler(Box::new(sdk::trace::Sampler::AlwaysOn));
let tracer = opentelemetry_jaeger::new_pipeline()
.with_service_name("actix_client")
.with_trace_config(sdk::trace::config().with_sampler(my_sampler)) // set your sampler config
.install_simple()?;
from actix-web-opentelemetry.
Many many thanks, we'll try this!
from actix-web-opentelemetry.
Related Issues (17)
- Is there a logging feature? HOT 2
- Update Opentelemetry to 1.19 HOT 1
- Enabling "process" feature for Prometheus metrics HOT 1
- Get duplicates http_server_active_requests metric after trying to refresh the same path again and again. HOT 4
- Info : Status code returned from actix-web HOT 2
- Using RequestTracingMiddleware with a TraceContextPropagator. HOT 3
- Support for actix-web 3.0 ?
- no default features for actix-web HOT 1
- Zipkin pipeline fail HOT 3
- Record user agent attribute on server
- Please help with the example HOT 3
- Record srevice version attribute HOT 1
- Guidance: Accessing the current span from another middleware HOT 5
- Server middleware on the doc doesn't work HOT 4
- status code handling for awc client HOT 3
- Release v3 ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from actix-web-opentelemetry.