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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDGenerator may generate zero TraceId / SpanId #5462

Closed
vijayaggarwal opened this issue Jun 2, 2024 · 1 comment · Fixed by #5514
Closed

IDGenerator may generate zero TraceId / SpanId #5462

vijayaggarwal opened this issue Jun 2, 2024 · 1 comment · Fixed by #5514
Labels
bug Something isn't working
Milestone

Comments

@vijayaggarwal
Copy link

Description

The spec (https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md) mentions that TraceId and SpanId must have at least one non-zero byte. However, the default id generator doesn't ensure that (https://github.com/open-telemetry/opentelemetry-go/blob/main/sdk/trace/id_generator.go#L44). The generator simply uses rand.Read() which does not guarantee non-zero output.

Environment

All environments

Steps To Reproduce

Difficult to give exact steps to reproduce, as random number generation is involved.

Expected behavior

Generated TraceId and SpanId must always be non-zero as per spec.

@vijayaggarwal vijayaggarwal added the bug Something isn't working label Jun 2, 2024
@Charlie-lizhihan
Copy link
Contributor

Charlie-lizhihan commented Jun 3, 2024

Hi there, I think this one is the same issue in Python repo as RandomIdGenerator can generate invalid Span/Trace Ids #3921

And I'm working on solving the python one, maybe I could try to solve it with Golang as well

MrAlias pushed a commit that referenced this issue Jun 18, 2024
# Description
Fix #5462 

## Type of change

add a loop to generate the spanID and traceID. 
the loop will not stop until it generate a valid ID

- [x] Bug fix (non-breaking change which fixes an issue)

---------

Co-authored-by: Damien Mathieu <42@dmathieu.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
@MrAlias MrAlias added this to the v1.28.0 milestone Jun 20, 2024
OrHayat pushed a commit to OrHayat/opentelemetry-go that referenced this issue Jun 23, 2024
# Description
Fix open-telemetry#5462 

## Type of change

add a loop to generate the spanID and traceID. 
the loop will not stop until it generate a valid ID

- [x] Bug fix (non-breaking change which fixes an issue)

---------

Co-authored-by: Damien Mathieu <42@dmathieu.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants