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

Make UUID generation Lazy / Create PropagationContext class #2827

Closed
antonpirker opened this issue Mar 15, 2024 · 1 comment
Closed

Make UUID generation Lazy / Create PropagationContext class #2827

antonpirker opened this issue Mar 15, 2024 · 1 comment
Assignees
Labels

Comments

@antonpirker
Copy link
Member

antonpirker commented Mar 15, 2024

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: Make UUID generation lazy #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.
@antonpirker antonpirker added the enhancement New feature or request label Mar 15, 2024
@sl0thentr0py
Copy link
Member

PR #2826

@antonpirker antonpirker changed the title Make UUID generation Lazy Make UUID generation Lazy / Create PropagationContext class Mar 15, 2024
@antonpirker antonpirker self-assigned this Apr 11, 2024
antonpirker added a commit that referenced this issue Apr 25, 2024
Create a class for the `PropagationContext`. Make the class generate the UUIDs lazily. Fixes #2827
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants