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