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

(0) Cleaning up existing code to prepare for new Scopes API #2611

Merged
merged 12 commits into from Jan 25, 2024

Conversation

antonpirker
Copy link
Member

@antonpirker antonpirker commented Dec 19, 2023

This cleans up existing code and reorganizes it to have a clean foundation for the refactoring the Hub and Scopes. This does not change any behavior and can be released in a minor version.

Moved some functionality from Hub to Scope or Client:
- moved `add_breadcrumb` from Hub to Scope
- moved session functions from Hub to Scope
- moved `get_integration1` from Hub to Client.

This is preparation work for refactoring how we deal with Hubs and Scopes in the future.
Each commit is moving one function, so it should be easy to review commit by commit.
…)` (#2570)

Improves the capabilities of our threadlocal context variables, we use when no "real" context variables are available (for example in old Python versions)

- Adds a no-op [copy_context](https://docs.python.org/3/library/contextvars.html#contextvars.copy_context) function to use in environments without context vars
- Adds [reset](https://docs.python.org/3/library/contextvars.html#contextvars.ContextVar.reset) functionality to our threadlocal based context vars.

This is preparation work for refactoring how we deal with Hubs and Scopes in the future.
Moved some functionality from Hub to Client:

- Capture Event:
  - moved `capture_event` from Hub to Client
  - created new `capture_event` in Scope that calls `capture_event` in Client
  - made `capture_event` in Hub call the new `capture_event` in Scope

- Capture Exception:
  - created new `capture_exception` in Scope
  - made `capture_exception` in Hub call the new one in Scope

- Capture Message:
  - created new `capture_message` in Scope
  - made `capture_message` in Hub call the new one in Scope

- renamed `**scope_args` to `**scope_kwargs` because it contains keyword arguments.
- moved `_update_scope` from Hub to Scope and renamed it to `_merge_scopes` 

This is preparation work for refactoring how we deal with Hubs and Scopes in the future.
Its properly easier to reason about this change when checking out the branch than looking at the diff.
Moved some functionality from Hub to Client:

- sorted some typing imports
- moved `get_traceparent` from Hub to Scope
- moved `get_baggage` from Hub to Scope
- moved `iter_trace_propagation_headers` from Hub to Scope
- moved `trace_propagation_meta` from Hub to Scope

This is preparation work for refactoring how we deal with Hubs and Scopes in the future.
@antonpirker antonpirker changed the title New Scopes API (0) New Scopes API Jan 19, 2024
@antonpirker antonpirker changed the title (0) New Scopes API (0) Cleaning up existing code to prepare for new Scopes API Jan 22, 2024
@antonpirker antonpirker marked this pull request as ready for review January 22, 2024 13:02
@antonpirker antonpirker merged commit ed3ac88 into master Jan 25, 2024
123 checks passed
@antonpirker antonpirker deleted the feat/new-scopes branch January 25, 2024 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants