We want to lazily create UUIDs to decrease the number of CPU cycles we use. There are two important places where UUIDs are created: 1. Span/Transaction creation: https://github.com/getsentry/sentry-python/blob/master/sentry_sdk/tracing.py#L145-L146 2. When a propagation context is created: https://github.com/getsentry/sentry-python/blob/master/sentry_sdk/scope.py#L225-L232 3. When creating a Profile: https://github.com/getsentry/sentry-python/blob/sentry-sdk-2.0/sentry_sdk/profiler.py#L455 4. When creating a Session: https://github.com/getsentry/sentry-python/blob/sentry-sdk-2.0/sentry_sdk/session.py#L49 ## Solution brainstorm 1. There is a PR that already started the work: https://github.com/getsentry/sentry-python/pull/2826 This already fixes point 1. from above. 2. For point 2. we need to create a class `PropagationContext` and create the uuid4 only when the `trace_id` or the `span_id` is read. 3. Implement similar to 1. 4. Implement similar to 1.
We want to lazily create UUIDs to decrease the number of CPU cycles we use.
There are two important places where UUIDs are created:
Solution brainstorm
This already fixes point 1. from above.
PropagationContextand create the uuid4 only when thetrace_idor thespan_idis read.