Comments (9)
Cloning the provider before passing it to set_tracer_provider
works. Thanks again!
from opentelemetry-rust.
https://github.com/open-telemetry/opentelemetry-rust/blob/main/examples/tracing-jaeger/src/main.rs#L46 Could you see if this is what you are looking for?
from opentelemetry-rust.
@cijothomas: Thanks for the quick reply!
The use case here is FaaS/"serverless" (e.g., AWS Lambda). Specifically, we need a way to flush traces after a request completes, but before AWS Lambda freezes the container to wait for the next request (which may never come, in which case unflushed traces are lost). Prior to the 0.18 release, I would have called opentelemetry::global::tracer_provider().force_flush()
here, but that's no longer possible.
Shutting down and registering a new tracing provider for each request seems like it would introduce a lot of unnecessary overhead, when we just need access to the force_flush
method.
from opentelemetry-rust.
Also, I'm willing to contribute a PR to get this done once there's consensus on the API changes.
from opentelemetry-rust.
@ramosbugs how/where is the tracer provider being created in this case?
from opentelemetry-rust.
I'm using the following code when the Lambda process starts (i.e., from main
), before it enters its request loop:
let batch = BatchSpanProcessor::builder(exporter, opentelemetry::runtime::Tokio)
.with_max_queue_size(MAX_SPAN_QUEUE_SIZE)
.build();
let provider = TracerProvider::builder()
.with_span_processor(batch)
.with_config(tracer_config)
.build();
opentelemetry::global::set_tracer_provider(provider);
from opentelemetry-rust.
One possible solution is to impl<T> TracerProvider for Arc<T> where T: TracerProvider
. Then, we can just pass a copy of the Arc<opentelemetry_sdk::trace::TracerProvider>
to set_tracer_provider
and maintain our own copy for access to force_flush
.
I don't see anything that requires a mutable reference to the provider, so an Arc
seems like it should work?
from opentelemetry-rust.
TracerProvider
is already clone, so you don't need the Arc
, you can pass a clone to set_tracer_provider
directly 👍
from opentelemetry-rust.
Oh, I totally missed that! Thank you, I will confirm that this works and then close the issue or report back otherwise.
from opentelemetry-rust.
Related Issues (20)
- [Bug]: The `reqwest` feature also tries to configure `reqwest::blocking::Client` and it might not be available
- [Feature]: Possibly update Extractor::key(&self) signature.
- [Bug]: SDK Trace propagator documentation is hidden.
- [Feature]: Avoid parsing empty strings into `TraceId`
- [Feature]: Update HTTP dependencie to ^1.0.0 HOT 1
- [Bug]: `SimpleSpanProcessor` might fail and error is ignored HOT 2
- [Bug]: opentelemetry-appender-tracing not setting log timestamp HOT 4
- There should be a way to create a synchronous guage. HOT 2
- Remove aws id generator from core sdk HOT 2
- Flaky test HOT 10
- [Bug]: incorrect docs on SdkMeterProvider.builder() HOT 2
- Flaky test in CI HOT 4
- [Bug]: PeriodicReader uses sync::Mutex.
- AttributeSet in the OpenTelemetry API HOT 4
- [Bug]: constructing a tonic builder defaults to connect to 4318? HOT 6
- Add Testing for Shutdown Scenarios. HOT 4
- ObservableCounter aggregation bug for cumulative
- [Feature]: remove the grpcio gRPC backend HOT 1
- Instrumentation scope - move to builder pattern? HOT 11
- [Feature]: Move `SpanLimits` to `opentelemetry` and use the limits in `SpanBuilder` HOT 3
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 opentelemetry-rust.