Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc] Number of root spans per trace #403

Closed
b-viguier opened this issue Jun 21, 2022 · 4 comments 路 Fixed by #408
Closed

[Doc] Number of root spans per trace #403

b-viguier opened this issue Jun 21, 2022 · 4 comments 路 Fixed by #408
Labels
question Further information is requested spec:traces

Comments

@b-viguier
Copy link

Hello 馃憢 馃檪

This repository states that a trace can contain several root spans:

// or more subspans for its sub-operations. A trace can also contain
// multiple root spans, or none at all. Spans do not need to be

A trace can also contain multiple root spans, or none at all.

but the documentation repository explicitly says that a trace contains only 1 root span
https://github.com/open-telemetry/opentelemetry-specification/blob/5fb819c72e34cb21fe1ce5acba1dc93c2216ecb1/specification/trace/api.md?plain=1#L384-L386

Each trace includes a single root span, which is the shared ancestor of all other spans in the trace.

Which one is right? 馃槄
My feeling is that the 2nd statement is right (1 single root span per trace). But when receiving spans from the collector, it's possible to receive several root spans from different traces, in a same OTLP payload, maybe it's the source of the mistake?

@arminru arminru added question Further information is requested spec:traces labels Jun 21, 2022
@arminru
Copy link
Member

arminru commented Jun 21, 2022

Hey @b-viguier!

If you produce spans via the OTel Trace API, you can only specify a parent Span (via a Context) from which the Trace ID is re-used along with the parent Span ID but there is no way to specify just a Trace ID to create a root span using it. For root spans, a new, random Trace ID would be generated.
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#span-creation
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#determining-the-parent-span-from-a-context

On a data model/protocol level, however, other producers would technically be able to construct multiple spans with identical Trace IDs but no Parent Span ID. The lines you are citing - for my understanding - kind of serve as warning for proto consumers that they might encounter such data and would need to gracefully handle this.

@b-viguier
Copy link
Author

Hi @arminru, thanks for your reply!

The lines you are citing - for my understanding - kind of serve as warning for proto consumers that they might encounter such data and would need to gracefully handle this.

But in these case, we could have the same warning for every required fields?
The protocol cannot ensure all semantic constraints are respected by every SDK implementation 馃

At least, it comforts me that in the right use-case we should have only 1 root span per trace 馃槄

@arminru
Copy link
Member

arminru commented Jun 22, 2022

@b-viguier Indeed - I don't know why this particular possible deviation is documented while others are not.
Generally I think it makes sense to have it here at least, so consumers know that "get me the span with parent_span_id=null" might not always yield exactly 1 as one would expect.

I tried to clarify the comment in #408, please let me know if this is clear enough 馃檪

@b-viguier
Copy link
Author

Your proposal is very relevant, thanks a lot 馃憤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested spec:traces
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants