Skip to content

Make UUID generation Lazy / Create PropagationContext class #2827

Closed

Description

@antonpirker

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.

Activity

  1. sl0thentr0py commented on Mar 15, 2024

    @sl0thentr0py
    Member
  2. changed the title [-]Make UUID generation Lazy[/-] [+]Make UUID generation Lazy / Create PropagationContext class[/+] on Mar 15, 2024
  3. added
    Component: SDK Core
    on Mar 15, 2024
  4. self-assigned this
    on Apr 11, 2024
  5. added a commit that references this issue on Apr 25, 2024
    f5db9ce
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Component: SDK Core

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions