Giter VIP home page Giter VIP logo

Comments (3)

TommyCpp avatar TommyCpp commented on June 12, 2024 1

How can I test that parent ID is set correctly?

You can replace the OTLP exporter with stdout exporter

let exporter = opentelemetry_stdout::SpanExporterBuilder::default().build();

This will print the span information to stdout and you can inspect the parentSpanId there.
You will also need to keep reference to tracer provider so it doesn't drop when init_observability function. I recommend to set it as global default by adding this line in the init_observability function

opentelemetry::global::set_tracer_provider(provider);

I tried this and this is the what I get

{
  "resourceSpans": [
    {
      "resource": {
        "attributes": [
          {
            "key": "telemetry.sdk.language",
            "value": {
              "stringValue": "rust"
            }
          },
          {
            "key": "telemetry.sdk.version",
            "value": {
              "stringValue": "0.22.1"
            }
          },
          {
            "key": "telemetry.sdk.name",
            "value": {
              "stringValue": "opentelemetry"
            }
          },
          {
            "key": "service.name",
            "value": {
              "stringValue": "unknown_service"
            }
          }
        ]
      },
      "scopeSpans": [
        {
          "scope": {
            "name": "lambda"
          },
          "spans": [
            {
              "traceId": "65dc50081561ed7046ffcbcb114af027",
              "spanId": "8c7d1cb651742fe8",
              "parentSpanId": "b510129166d5a083",
              "name": "Handler is called",
              "kind": 1,
              "startTimeUnixNano": 1710026004438046310,
              "startTime": "2024-03-09 23:13:24.438",
              "endTimeUnixNano": 1710026004438126497,
              "endTime": "2024-03-09 23:13:24.438",
              "attributes": [
                {
                  "key": "code.filepath",
                  "value": {
                    "stringValue": "examples/tracing-jaeger/src/main.rs"
                  }
                },
                {
                  "key": "code.namespace",
                  "value": {
                    "stringValue": "tracing_jaeger"
                  }
                },
                {
                  "key": "code.lineno",
                  "value": {
                    "intValue": 54
                  }
                },
                {
                  "key": "thread.id",
                  "value": {
                    "intValue": 1
                  }
                },
                {
                  "key": "thread.name",
                  "value": {
                    "stringValue": "main"
                  }
                },
                {
                  "key": "busy_ns",
                  "value": {
                    "intValue": 0
                  }
                },
                {
                  "key": "idle_ns",
                  "value": {
                    "intValue": 0
                  }
                }
              ],
              "droppedAttributesCount": 0,
              "droppedEventsCount": 0,
              "flags": 1,
              "droppedLinksCount": 0,
              "status": {}
            }
          ]
        }
      ]
    }
  ]
}

I will close this issue for now as the behavior is intented. Feel free to reopen should you have more questions

from opentelemetry-rust.

stormshield-fabs avatar stormshield-fabs commented on June 12, 2024

set_parent is a tracing-opentelemetry method that does not interact with the opentelemetry structures the way you expect but instead on its own OtelData.

Basically, you're dealing with two instrumentation APIs: opentelemetry and tracing (via tracing-opentelemetry). It looks like you want to use tracing for the rest of your instrumentation, so everything should work fine. You will find that the parent ID is correctly set when exporting the traces (example below in Jaeger).

image

from opentelemetry-rust.

hkford avatar hkford commented on June 12, 2024

Thank you for trying out my code. I could visualize traces using Jaeger too.
How can I test that parent ID is set correctly?

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.