-
Notifications
You must be signed in to change notification settings - Fork 537
POtel implementation base branch #3152
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
Draft
sl0thentr0py
wants to merge
325
commits into
master
Choose a base branch
from
potel-base
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f7f153c
to
28effd6
Compare
16f9341
to
951477f
Compare
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #3152 +/- ##
==========================================
+ Coverage 80.23% 84.38% +4.15%
==========================================
Files 142 144 +2
Lines 15937 14638 -1299
Branches 2727 2329 -398
==========================================
- Hits 12787 12353 -434
+ Misses 2273 1558 -715
+ Partials 877 727 -150
|
d4b1d00
to
4428ee9
Compare
Set the correct span `op` for database spans, instead of the generic `"db"`.
…ts (#3631) Otel `span.set_attribute()` does not allow `dict` values, thus we change the data to be compatible
* while sending the event in the final payload, the transaction name will be picked up from the attributes `sentry.name` or fallback to the `description` when we only have otel instrumentation * for populating DSC in the head case, we are doing a best attempt solution and fetching the transaction name/source from the current and isolation scopes * NOTE that there are cases where this will be inaccurate if we never set the transaction name on the scope in some integration, so we will go through and fix those cases separately.
Instead of getting span from ._span_recorder get it from envelope.
- Change `span.set_data` to `span.set_attribute` - Change `start_transaction`s in the tests to `start_span`s - Stringify `db.params`, `db.paramstyle`, `db.cursor` - ❗ Change how adding query source works. Previously, we first let the DB span finish and then looked at its start and end timestamps to figure out if the query was slow enough to attach query data. With the switch to OTel, we can no longer put stuff on a finished span, meaning the slow query span still has to be alive when adding data to it. So instead of looking at the end timestamp of a finished span, we keep the span alive and instead look at current time at the point when the query is finished. This means the DB span will be longer than the actual query (since it now includes adding query data).
Moving stuff out of `integrations/opentelemetry/` step by step since there is no OpenTelemetry integration anymore -- it's part of the core SDK. This moves `sentry_sdk/integrations/opentelemetry/sampler.py` -> `sentry_sdk/opentelemetry/sampler.py` Ref #3853
Closes #4235 --------- Co-authored-by: Ivana Kellyer <ivana.kellyer@sentry.io>
Moving stuff out of `integrations/opentelemetry/` step by step since there is no OpenTelemetry integration anymore -- it's part of the core SDK. This moves `sentry_sdk/integrations/opentelemetry/span_processor.py` -> `sentry_sdk/opentelemetry/span_processor.py` Ref #3853 --------- Co-authored-by: Daniel Szoke <7881302+szokeasaurusrex@users.noreply.github.com>
Moving stuff out of `integrations/opentelemetry/` step by step since there is no OpenTelemetry integration anymore -- it's part of the core SDK. This moves `sentry_sdk/integrations/opentelemetry/propagator.py` -> `sentry_sdk/opentelemetry/propagator.py` Ref #3853 --------- Co-authored-by: Daniel Szoke <7881302+szokeasaurusrex@users.noreply.github.com>
Moving stuff out of `integrations/opentelemetry/` step by step since there is no OpenTelemetry integration anymore -- it's part of the core SDK. This moves `sentry_sdk/integrations/opentelemetry/contextvars_context.py` -> `sentry_sdk/opentelemetry/contextvars_context.py` Ref #3853
Port of #4278 for POTel. <!-- Describe your PR here --> --- Thank you for contributing to `sentry-python`! Please add tests to validate your changes, and lint your code using `tox -e linters`. Running the test suite on your PR might require maintainer approval.
Moving stuff out of `integrations/opentelemetry/` step by step since there is no OpenTelemetry integration anymore -- it's part of the core SDK. This moves `sentry_sdk/integrations/opentelemetry/{utils,consts}.py` -> `sentry_sdk/opentelemetry/{utils,consts}.py`. There's quite some stuff moving around in this PR in order to remove circular dependencies that have to do with `tracing.py`: - `get_span_status_from_http_code` from `tracing.py` is now in `tracing_utils.py` - various constants from `tracing.py` are now in `consts.py` Additionally, Sphinx was unhappy, so tweaked the way we type some things in `api.py` and `_init_implementation.py`. I'll possibly follow this up with creating a nice structure for the tracing files, maybe a common `tracing` directory with `tracing.py`, `tracing_utils.py` -> `utils.py`, and dedicated `consts.py`. Ref #3853
Moving stuff out of `integrations/opentelemetry/` step by step since there is no OpenTelemetry integration anymore -- it's part of the core SDK. This moves `sentry_sdk/integrations/opentelemetry/scope.py` -> `sentry_sdk/opentelemetry/scope.py` Ref #3853
Moving stuff out of `integrations/opentelemetry/` step by step since there is no OpenTelemetry integration anymore -- it's part of the core SDK. - Moved `sentry_sdk/integrations/opentelemetry/integration.py` -> `sentry_sdk/opentelemetry/tracing.py`. - Removed all the experimental autoinstrumentation stuff from `integration.py`. - Removed `integrations/opentelemetry/` altogether (there was nothing left but `__init__.py`, which is now also gone). - Moved all tests from `tests/integrations/opentelemetry` to `tests/opentelemetry`. - Removed the potel/opentelemetry integration test targets from `tox.ini`. These will now be run as part of the Common test suite. Ref #3853
Porting stuff from master and other fixes * add correct `event_level` to new logging tests (on `potel-base`, we don't capture logging errors by default so this has to be set explicitly) * add compat for `start_transaction` * re-enable an old test **Note:** This still leaves one failing threading test, will address that separately
For testing purposes I set the next major version of the SDK.
Currently, this property has type `Any`, but it can now be changed to `Optional[Span]` Depends on: - #4263
`ThreadingIntegration` can optionally **NOT** propagate scope data to threads (`propagate_scope=False`). In that case, in POTel we were wrapping the thread's task in an `isolation_scope()`: ```python with sentry_sdk.isolation_scope() as scope: return _run_old_run_func() ``` But as this forks the currently active isolation scope, the thread effectively gets all scope data from the parent isolation scope -- so the scope is actually propagated to the thread, even though it shouldn't be since `propagate_scope=False`. ~We effectively need some way to give the thread a clear isolation scope instead. In this PR, I'm just clearing the forked iso scope, but I'm not sure if this is good enough and if something doesn't need to be done on the OTel side too.~ ~Another option would be to set the iso/current scopes to the initial, empty iso/current scopes instead, before running the thread's target function.~ UPDATE: we're just instantiating new scopes now Another change is that in OTel, the spans in the threads, now without a parent, automatically get promoted to transactions. (On master they'd just be orphaned spans, so they wouldn't be taken into account at all.) We probably need to instruct folks to add `only_if_parent` if they don't want this to happen. --------- Co-authored-by: Neel Shah <neel.shah@sentry.io>
With the switch to OTel, the Common test suite is now dependent on an otel package, so it technically fits the toxgen usecase. By letting toxgen take care of it, we're making sure we're always testing a good range of otel versions, including the oldest one (to catch regressions) and the newest one (to catch incompatibilities early). Couple things surfaced in terms of incompatibility with older versions: - Some semantic attributes we're using weren't there from the get go open-telemetry/opentelemetry-python@495d705. Changed the code that uses them to handle failure. - The signature of `span.set_status()` changed at some point open-telemetry/opentelemetry-python@6e282d2. Added a compat version of `set_status()` for older otel. Also included: - removing the `opentelemetry-experimental` extra (not used anymore) - ❗ switching to using `opentelemetry-sdk` instead of `opentelemetry-distro` -- the `distro` only seems to [be setting up some defaults](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/8390db35ae2062c09d4d74a08d310c7bde1912c4/opentelemetry-distro/src/opentelemetry/distro/__init__.py) that we're not using Closes #3241
Introduce the convention of underscore-prefixed span attributes. These won't be sent to Sentry and are meant for internal SDK usage. Changed `flag.count` to internal. Looked through the rest of the attrs we're setting and that stuff requires a big comprehensive cleanup altogether to make stuff align with OTel. Didn't touch anything else for now. Closes #4329
Revert changing the default of `traces_sample_rate` done in #4240
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Full state of CI: #3744
Contains:
set_measurement
#4333propagate_scope=False
inThreadingIntegration
#4310Scope.root_span
logic #4274Scope.root_span
#4273LoggingIntegration
to Sentry by default #4300integrations/opentelemetry/
#4277integrations/opentelemetry/
#4276integrations/opentelemetry/
#4272integrations/opentelemetry/
#4260integrations/opentelemetry/
#4259integrations/opentelemetry/
#4258cache_spans
by default #3994start_span
fail if unsupported args are provided #4201Span.set_data()
#4261sample_rand
to POTel #4106propagate_traces
#4206warnings
module for deprecation messagse. #4180sample_rate
update topotel-base
#4069SystemExit(0)
not as a span status of 'internal_error' #4094use_scope
#3851None
#3816only_if_parent
option to POTelSpan and use it in integrations #3748_serialize_span_attribute
intoset_attribute
#3732subprocess
breadcrumbs frommaybe_create_breadcrumbs_from_span
to integration. #3637add
to trace state if key does not exist #3645op
. #3628make aws lambda layer
#3586use_scope
,use_isolation_scope
#3522use_scope
,use_isolation_scope
#3500OpenTelemetryIntegration
toDEFAULT_INTEGRATIONS
#3471active
flag onPOTelSpan
#3470start_transaction
#3379Hub
and related code for good. #3446Simple test
References
startSpan
& friendsstart_span
& friendsMisc
In OTel, this:
is equivalent to