Help Integrating opentelemetry crate with tracing crate

Question 1:

Please can someone explain what i might be missing, code seems to work, at least spans are getting to Jaeger. but the problem is every span are sent to the collector as a separate trace, i want to make each request up to to the response a single trace.

I saw some videos and hoping that adding this line would help. but no, spans are still sent as a separate trace for each function

opentelemetry::global::set_text_map_propagator(TraceContextPropagator::new());
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    dotenv::dotenv().ok();

    opentelemetry::global::set_text_map_propagator(TraceContextPropagator::new());

    let tracer = opentelemetry_jaeger::new_pipeline()
    .with_service_name("Tracing-Demo")
    .with_trace_config(Config::default().with_sampler(Sampler::AlwaysOn))
    .install_simple()?;

    // Create a tracing layer with the configured tracer
    let otel_layer = tracing_opentelemetry::layer().with_tracer(tracer);
    let subscriber = Registry::default().with(otel_layer);
   
    tracing::subscriber::set_global_default(subscriber).unwrap();
   
    println!("Test Line");
    tracing::info!("It started here");
    // spawn a task listening green thread
    let mut _grpc_handle = tokio::spawn(async move { g_rpc_server(tx).await });
    tracing::info!("It got here");
}

Question 2.

I notice these 2 events are not sent to Jaeger

    tracing::info!("It started here");
    tracing::info!("It got here");

but every other span from the spawn task are.

Question 2.

==========
is there a way to filter traces to just my applications only, i don't want to see traces from dependencies.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.