Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    cqx820
    @cqx820:matrix.org
    [m]

    Hi everyone,

    I'm trying to send trace data to Google Cloud Trace, I tried a python script with my_key.json and it's working for me, but I'm unable to do the same with rust. The Cargo.toml looks like

    opentelemetry = { version = "0.16.0", default_features = false, features = ["rt-tokio", "rt-async-std", "rt-tokio-current-thread", "trace", "metrics"] }
    opentelemetry-stackdriver = { version = "0.12.0", default_features = false, features = ["gcp_auth", "yup-authorizer"] }
    tracing = "0.1.28"
    tracing-futures = "0.2.5"
    tracing-opentelemetry = "0.15.0"
    tracing-subscriber = "0.2.24"

    My workflow is like this:

    1. Get exporter
      let handle = tokio::runtime::Handle::current();
      let spawner = tokio_adapter::TokioSpawner::new(handle);
      let exporter = StackDriverExporter::connect(
       GcpAuthorizer::new().await.unwrap(), &spawner, None, None).await.unwrap();  // Tried YupAuthorizer as well, didn't work too.
    2. Get tracer
      let tracer = sdk::trace::TracerProvider::builder()
         .with_simple_exporter(exporter)
         .build()
         .tracer("tracer_name", Some(VERSION));
    3. Get subscriber
      let subscriber = tracing_subscriber::registry().with(tracing_opentelemetry::layer().with_tracer(tracer));
    4. Set global default
      tracing::subscriber::set_global_default(subscriber);
    5. Call tracing::span!(tracing::Level::TRACE, span_name, ...)

    Above is my entire workflow, after running I can't find any traces on Google Cloud Trace, I'm sure the cred file has enough permission. I've also tried raising the trace levels but no lucks. There were no runtime errors found. I wonder if I'm doing wrong with getting the exporter and the tracer.

    I also wrote some sample codes below just for testing, but they didn't work for me too

    let exporter = StackDriverExporter::connect(
        GcpAuthorizer::new().await.unwrap(),
        &spawner, Some(Duration::from_secs(5)), Some(5usize),
      ).await.unwrap();
    
    let tracer = sdk::trace::TracerProvider::builder()
          .with_simple_exporter(exporter)
          .build()
          .tracer("tracer_name", Some(VERSION));
    
    let attributes =
          vec![KeyValue::new("version", "0.0.0")];
    
    let _span = tracer
            .span_builder("my_test_span")
            .with_attributes(attributes)
            .start(&tracer);
    
    tracer.with_span(_span, |cx| {
          sleep(Duration::from_millis(500));
        });

    Any suggestions would be appreciated, thank you very much!!

    I also found another issue about the YupAuthorizer, I provided a path for persistent_token_file, but I found it's not persisting the token to disk too.
    Jan Steinke
    @jan-xyz:matrix.org
    [m]
    Good morning (in Europe and Africa), I filed yesterday a PR to bump the Prometheus dependency and noticed that some of the examples are pinned to old versions, while others use path directives. Would you be interested in a PR which changes everything to path directives so that the examples don't go out of sync?
    1 reply
    Cecile Tonglet
    @cecton

    Hello I have a question about TraceState.

    Context: If I understand right I should pass a HTTP header "tracestate" to the sub services I call using this. (So I can see the trace across multiple services.)

    More context: I'm using tokio's tracing with opentelemetry-rust and jaeger to vizualize. I do see the spans I created with tracing in jaeger. Everything seems to be working for now.

    I want to make this trace state header for the subservices. So I do this before calling the subservice:

    let trace_state_header = opentelemetry::trace::get_active_span(|span| {
        let span_context = span.span_context();
        span_context.trace_state().header()
    });

    The problem is that I always get an empty string. The SpanRef's debug looks like this: SpanRef(SynchronizedSpan { span_context: SpanContext { trace_id: TraceId(0), span_id: SpanId(0), trace_flags: TraceFlags(0), is_remote: false, trace_state: TraceState(None) }, inner: None }) which doesn't look great (TraceState(None) looks wrong).

    I have the impression that there is a difference between tracing's span and opentelemetry's span. Maybe I'm missing a step somewhere?

    6 replies
    altanozlu
    @altanozlu:matrix.org
    [m]
    Hi every one, i would like to ask why there isn’t another repository for contrib modules like go and python does
    1 reply
    Matteo Giachino
    @matteosister

    Hello everybody. I'm trying to have a "version" tag for every span in our rust service. Right now we are using the opentelemetry-zipkin exporter, but we tried also with jaeger, and otel with the same result.
    We are doing:

    let trace_config = trace::config().with_resource(Resource::new(vec![
        KeyValue::new("version", version),
    ]));
    let tracer = opentelemetry_zipkin::new_pipeline()
            .with_collector_endpoint("http://otel_url")
            .with_service_name("app_name")
            .with_trace_config(trace_config)
            .install_batch(opentelemetry::runtime::TokioCurrentThread)
            .expect("failed to install opentelemetry_zipkin exporter pipeline");

    The problem is that I don't see the version tag in the reported spans. Is this the correct way to do this?

    7 replies
    Jan Steinke
    @jan-xyz:matrix.org
    [m]
    You will need to add the tag to each span separately
    gsson
    @gsson:matrix.org
    [m]

    👋
    Hello! OpenTelemetry/tracing noob here!

    I'm trying to use opentelemetry-prometheus to add some metrics to my app.

    I would like to add request information as attributes to to the meters when recording the response metrics, but I can't quite figure out how. I've played around a bit with span fields or attributes but no luck. I my test I'm using the new and shiny axum server, but I guess I would run into similar issues everywhere.

    I have created a very simple tower_http::trace::TraceLayer like so:

    .layer(TraceLayer::new_for_http()
        .on_response(move |response: &Response<_>, latency: Duration, _span: &Span| {
            let attributes = [
                KeyValue::new("status", response.status().as_str().to_string()),
                // KeyValue::new("path", ???),
                // KeyValue::new("method", ???),
            ];
            server_request_recorder.record(latency.as_secs_f64(), &attributes);
        },
    ));

    Can anyone help me fill in the blanks? :)

    I put the full minimal-ish example here: https://github.com/gsson/mini-web-rs

    9 replies
    Matteo Giachino
    @matteosister
    Is there a way to add some kind of hook to tracing-subscriber to add a custom tag to every span generated?
    3 replies
    bbigras
    @bbigras:matrix.org
    [m]
    I got OpenTelemetry trace error occurred. Exporter jaeger encountered the following error(s): thrift agent failed with message too long. Any way to dump the offending message?
    bbigras
    @bbigras:matrix.org
    [m]
    Eric Kidd
    @emk
    Good morning. I've been trying to figure out how to use tracing-opentelemetry to integrate a Rust app with an external trace. This mostly seems to work, but I can't figure out how to add new keys to the TraceState. It appears that tracing fields and OpenTelemetry attributes get added to events, like I'd expect, but I haven't figured out how to add a key to the TraceState, which is separate from OpenTelemetry attributes. Am I missing something obvious here?
    1 reply
    bbigras
    @bbigras:matrix.org
    [m]
    @emk: by "remote context" do you mean you extracted the trace id from http headers?
    1 reply
    I have no idea what tracestat and baggage are yet. Still have things to learn.
    Eric Kidd
    @emk
    Clearly, I do, too.
    bbigras
    @bbigras:matrix.org
    [m]

    if you need to extract the trace stuff from headers, here's how I do it:

    let parent_cx = global::get_text_map_propagator(|propagator| {
        propagator.extract(&HeaderExtractor(&headers))
    });
    
    let tracer = global::tracer("example");
    let span = tracer
        .span_builder("something")
        .with_kind(SpanKind::Server)
        .with_parent_context(parent_cx)
        .start(&tracer);

    I'm using global::set_text_map_propagator(TraceContextPropagator::new()); on the client side.

    Josh Triplett
    @joshtriplett

    I'm trying to migrate from opentelemetry-rust 0.14 to 0.16. I'm using OTLP HTTP. In 0.14, I had this:

            opentelemetry_otlp::TraceExporter::new_http(
                opentelemetry_otlp::ExporterConfig {
                    endpoint: "https://api.honeycomb.io/v1/traces".to_string(),
                    protocol: opentelemetry_otlp::Protocol::HttpBinary,
                    ..Default::default()
                },
                opentelemetry_otlp::HttpConfig {
                    headers: Some(headers),
                    ..Default::default()
                },
            )

    But in 0.16, HttpConfig doesn't seem to be public anymore, so I can't create one to call new_http. I tried creating an HttpExporterBuilder, but once I'm done building, I don't see how to get from there to a SpanExporter, because SpanExporterBuilder::build_span_exporter is private.
    What's the supported way to build a SpanExporter in 0.16?

    Josh Triplett
    @joshtriplett
    @jtescher found and pushed a solution, thank you!
    Mark Van de Vyver
    @taqtiqa-mark
    Hi, I'm trying to get my head around the Rust debugging story. In particular around the using the tracing crate with Jaeger. As best I understand, this means coming to grips with how these crates hang together: tracing -> tracing-subscriber -> tracing-opentelemetry -> opentelemetry - opentelemetry-tracing. Before clogging this channel, is there any doc/blog giving a high level over view? Or even lower level overview of the relations and intended uses?
    3 replies
    Mark Van de Vyver
    @taqtiqa-mark
    If not, one immediate question is: Should I expect the Tracing crates #[instrument] in a 3rd party library to generate OT spans to Jaeger? Assuming my app has somthing like the following working:
    async fn main() {
        // Build a Jaeger batch span processor
        // Setup Tracer Provider
        // Get new Tracer from TracerProvider
        // Create a layer ( `layer`) with the configured Tracer
         tracing_subscriber::registry()
                            .with(layer)
                            .try_init()
                            .expect("Global default subscriber.");
         let root = trace_span!("my_app_start").entered();
    1 reply
    Robert F. Dickerson
    @rfdickerson

    I'm struggling to get batched reporting working- but simple works fine.

        let tracer = opentelemetry_jaeger::new_pipeline()
        .with_service_name("report_example")
        .install_simple()?;
    
        // let tracer = opentelemetry_jaeger::new_pipeline()
        //     .with_service_name("orchestrator")
        //     .install_batch(opentelemetry::runtime::Tokio)?;
    
        let opentelemetry = tracing_opentelemetry::layer().with_tracer(tracer);
    
        tracing_subscriber::registry()
            .with(opentelemetry)
            .try_init()
            .expect("Global default subscriber.");

    If I enable batching (uncomment and comment the other) I get the following error:

    OpenTelemetry trace error occurred. Exporter jaeger encountered the following error(s): thrift agent failed with message too long
    3 replies
    restioson
    @restioson:breadpirates.chat
    [m]
    hi all, wondering if it's a known bug that (with tracing) recording a f64/f32 into a span doesn't display correctly in jaeger? i don't really know which part of the tracing-opentelemetry-jaeger stack could be causing it, so maybe someone here has seen this before?
    1 reply
    restioson
    @restioson:breadpirates.chat
    [m]
    this is what i mean, saving should be around 25.71 as printed by dbg macro
    restioson
    @restioson:breadpirates.chat
    [m]
    I have not tried instrumenting with OT directly, I can try that
    Could also be a Jaeger bug
    Andrey Cherkashin
    @andoriyu
    Is it normal that propagator from opentracing_jaeger does inject sometimes?
    Or rather, what's the proper way to go from tracing'span to injecting headers before making a remote call?
    Atanas Yankov
    @atanunq
    Hi all, yesterday I wanted to experiment with sending traces to an OTel collector with the opentelemetry-otlp crate. I hoped that the Quickstart section will be enough to get me started but it turned out that tonic needs an async executor and I had to go on a massive detour to figure out features, executors, etc. Am I missing something or is the guide there outdated? I'd love to improve the docs but I need to figure it out myself first
    2 replies
    Ankit Gupta
    @agoops

    :wave: I'd like to use opentelemetry to persist my application's spans and events so I can export it to an otel compatible backend later.

    While writing an Exporter to persist json-serialized SpanData, I noticed that SpanData and its associated Events are not exported until the span fully completes.

    Running this example produces this sample-trace-data.jsonl, where each line is a complete Span.

    If my app hangs or crashes before completing a Span, I'd certainly like to capture any Events emitted before hang or crash, so that I can debug.

    Is this possible using the opentelemetry-rustsdk? Is there a good place for me to hook into upstream of SpanExporter that I can capture and persist span/event data as it's generated?

    Alexandros Liarokapis
    @aliarokapis_gitlab
    hi all! what would be a good direction for say adding kafka support to opentelemetry? That means adding all the MESSAGING_* attributes writing injectors/extractors from headers etc
    4 replies
    wise0wl
    @wise0wl:jobmachine.org
    [m]

    Hello! Our services all utilize OTLP for tracing, with the exception being our API gateway. The API gateway is called Ambassador, and it is based on Envoy. Unfortunately, Envoy and Ambassador do not yet support OTLP, but do support Jaeger and Zipkin (and a few others). We successfully start a trace on our API gateway, export the trace to our Otel collectors, and forward the trace in Zipkin format (x-b3-traceid etc.) but our downstream services do not know what to do with the x-b3-traceid headers.

    Is there a way to set multiple TraceContextPropagator's?

    1 reply
    ie. we want to use the opentelemetry::sdk::propagation::TraceContextPropagator as well as the zipkin one
    Alexandros Liarokapis
    @aliarokapis_gitlab
    Do I need to call .instrument() on the sub-futures of an async function if I use the #[instrument] macro on it?
    Filip Kieres
    @diceride
    Hello! I added a new opentelemetry-dynatrace crate in PR open-telemetry/opentelemetry-rust#679. Some tests are failing, I'm looking into this to get the test suite passed.
    8 replies
    Zachary Mattor
    @ZackMattor
    Hey all! Having a bear of a time trying to get opentelemetry, tracing, and an OTLP exporter working together. I'm trying to get started with the basic_otlp example, but it is only sorta building for me... I'm using the v0.16.0 branch. Any pointers or other examples I could look at? :D
      thread 'main' panicked at 'Error generating protobuf: Custom { kind: Other, error: "protoc failed: Could not make proto path relative: src/proto/opentelemetry-proto/opentelemetry/proto/common/v1/common.proto: No such file or directory\n" }', opentelemetry-otlp/build.rs:34:10
    1 reply
    metahayek
    @metahayek:matrix.org
    [m]
    Hi, any idea why the prometheus exporter wouldn't be getting any metric families from a call to .gather()
    Eg. in this code, I create a meter using the default global meter,
    let meter = global::meter("poseidon");
    
    let rec = meter
    .f64_value_recorder(format!("indicies.{}.quote", "TEST"))
    .with_description("Index quote value")
    .init()
    .bind(HANDLER_ALL.as_ref());
    rec.record(12.0);
    2 replies
    And then later on, if I call on my exporter, created with opentelemetry_prometheus::exporter() .with_resource(Resource::new(vec![KeyValue::new("R", "V")])) .init(), there are no metric families returned.
    let metric_families = instance.metrics.exporter.registry().gather();
    ie. metric_families is an empty vector
    metahayek
    @metahayek:matrix.org
    [m]

    For context this seems to work

    let exporter = opentelemetry_prometheus::exporter().try_init()?;
    let meter = global::meter("poseidon");

    But this does not

        let meter = global::meter("poseidon");
        let exporter = opentelemetry_prometheus::exporter().try_init()?;