Giter VIP home page Giter VIP logo

Comments (5)

lalitb avatar lalitb commented on June 3, 2024 1

Will it make sense for TraceProvider to have similar behavior as LoggerProvider (#1455) - Let Tracer own TracerProvider (with shared referenece to TracerProviderInner), which would ensure that it won't be dropped till all instances of Tracers are dropped.

from opentelemetry-rust.

TommyCpp avatar TommyCpp commented on June 3, 2024 1

Ah you are right. Let me give it a try

from opentelemetry-rust.

TommyCpp avatar TommyCpp commented on June 3, 2024

Yeah it's a known behavior. Users need to manually hold reference to provider or pass the provider to global tracer provider.

Agree on we should update documentation and possible looking into compiler warnings

from opentelemetry-rust.

TommyCpp avatar TommyCpp commented on June 3, 2024

Like pointed out in #1455 after I did some POC I realized the drawback of curent implementation is we will no longer shutdown tracer/logger processor when dropping TracerProvider.

Considering the following unit test that validates we will not send out spans after tracer provider shuts down

    #[test]
    fn test_span_exported_data() {
        let provider = crate::trace::TracerProvider::builder()
            .with_simple_exporter(NoopSpanExporter::new())
            .build();
        let tracer = provider.tracer("test");

        let mut span = tracer.start("test_span");
        span.add_event("test_event", vec![]);
        span.set_status(Status::error(""));

        let exported_data = span.exported_data();
        assert!(exported_data.is_some());

        drop(provider);
        let dropped_span = tracer.start("span_with_dropped_provider");
        // return none if the provider has already been dropped
        // but this won't happen if the tracer still holds a reference to tracer inner
        assert!(dropped_span.exported_data().is_none());
    }

I think there are two questions we need to answer:

  1. Do we need to shutdown SpanProcssors when TracerProvider drops?
  2. How do we make sure the span exporting stops once the SpanProcessor shuts down?
    • LoggerProvider has try_shutdown which requries users to manualy track down all cloned LoggerProvider, given every Logger has a reference to LoggerProvider this means users is responsible for clean up Logger before LoggerProvider
    • Is it possible for us to keep a Weak reference to every Tracer created from a givenTracerProviderInner. Upon shutting down, the TracerProviderInner notify all Tracer and ask them to remove their reference to TracerProviderInner.

from opentelemetry-rust.

cijothomas avatar cijothomas commented on June 3, 2024

https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry/src/trace/mod.rs#L20-L31 - The recently added doc updates should cover this?

from opentelemetry-rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.