class TemporalIdGenerator(IdGenerator): (source)
Constructor: TemporalIdGenerator(id_generator)
OpenTelemetry ID generator that uses Temporal's deterministic random generator.
Warning
This class is experimental and may change in future versions. Use with caution in production environments.
This generator uses Temporal's workflow-safe random number generator when inside a workflow execution, ensuring deterministic span and trace IDs across workflow replays. Falls back to standard random generation outside of workflows.
Can be seeded with OpenTelemetry span IDs from client context to maintain proper span parenting across the client-workflow boundary.
| Method | __init__ |
Initialize a TemporalIdGenerator. |
| Method | generate |
Generate a span ID using Temporal's deterministic random when in workflow. |
| Method | generate |
Generate a trace ID using Temporal's deterministic random when in workflow. |
| Method | seed |
Seed the generator with a span ID to use as the first result. |
| Method | seed |
Seed the generator with a trace ID to use as the first result. |
| Instance Variable | spans |
Undocumented |
| Instance Variable | traces |
Undocumented |
| Instance Variable | _id |
Undocumented |
Generate a span ID using Temporal's deterministic random when in workflow.
| Returns | |
int | A 64-bit span ID. |
Generate a trace ID using Temporal's deterministic random when in workflow.
| Returns | |
int | A 128-bit trace ID. |
Seed the generator with a span ID to use as the first result.
This is typically used to maintain OpenTelemetry span parenting when crossing the client-workflow boundary.
| Parameters | |
spanint | The span ID to use as the first generated span ID. |
Seed the generator with a trace ID to use as the first result.
| Parameters | |
traceint | The trace ID to use as the first generated trace ID. |