Skip to content

No root span #215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
johnnyggalt opened this issue Mar 6, 2025 · 3 comments
Open

No root span #215

johnnyggalt opened this issue Mar 6, 2025 · 3 comments

Comments

@johnnyggalt
Copy link

Describe the bug
Figuring out the manner in which traces are supposed to be recorded has been a bit difficult because it's changed so much, but the last thing I've tried is the (new?) trace method. But the problem is that no Span has the root ID (indeed, nothing but tests invoke the SpanId.root() method).

Consequently, the span that should be marked as root is instead marked as invalid and Grafana shows:

Image

And there doesn't seem to be a "way in" such that I can manually override or control the ID of the span.

Steps to reproduce
I'm just doing:

final tracer = globalTracerProvider.getTracer('my_app');
return trace(
        'span_name',
        () async { /* code here */ },
        tracer: tracer,
        spanKind: SpanKind.client,
    );

I also tried specifying newRoot: true, but it made no difference (nor did I expect it to based on the current code).

What did you expect to see?
I don't know if my expectations are off, but I expected the library to just make sure the first span for the context is marked as the root span. I don't think any kind of manual intervention should be required.

What did you see instead?
No span is marked as root. What should be the root span instead has the invalid ID.

What version and what artifacts are you using?

`opentelemetry: 0.18.9`

My bootstrap logic looks like:

  final tracerProvider = TracerProviderBase(
    processors: [
      BatchSpanProcessor(
        CollectorExporter(Uri.parse('http://localhost:4318/v1/traces')),
      ),
      SimpleSpanProcessor(ConsoleExporter()),
    ],
  );

  registerGlobalTracerProvider(tracerProvider);

  registerGlobalTextMapPropagator(W3CTraceContextPropagator());

Environment
Dart Version: 3.7.0
OS: Windows 10

@johnnyggalt
Copy link
Author

PS. I should have mentioned I also tried the approach espoused by the README (manually creating spans via tracer.startSpan and ending them), but had the same issue.

@johnnyggalt
Copy link
Author

May be the same as #189, not sure.

@ChiaraMC
Copy link

ChiaraMC commented Apr 21, 2025

Potentially also related: #188 (I'm sticking with version 0.18.3 because of this issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants