Skip to content

When the random seed is set, it causes duplicate traceId and spanId. #4376

@lyred193

Description

@lyred193

Describe your environment

OS: ALL
Python version: Python 3.10.16
SDK version: 1.29.0

What happened?

After setting a random seed in the Python application, the traceId and spanId are duplicated after each restart of the application.

Steps to Reproduce

from opentelemetry.sdk.trace import RandomIdGenerator

if name == "main":
import random
random.seed(10)
id_generator = RandomIdGenerator()
trace_id = id_generator.generate_trace_id()
span_id = id_generator.generate_span_id()
# Every time the main function is run, the trace_id is always 164207228320579316746596838417247989971
print(trace_id)
# Every time the main function is run, the span_id is always 273610340023782072
print(span_id)

Expected Result

Each time the main function runs, the trace_id and span_id are different.

Actual Result

Every time the main function is run, the trace_id is always 164207228320579316746596838417247989971
Every time the main function is run, the span_id is always 273610340023782072

Additional context

No response

Would you like to implement a fix?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions