Skip to content

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
wants to merge 425 commits into
base: master
Choose a base branch
from
Draft

POtel implementation base branch #3152

wants to merge 425 commits into from

Conversation

sl0thentr0py
Copy link
Member

@sl0thentr0py sl0thentr0py commented Jun 10, 2024

Contains:

Simple test

import sentry_sdk
from time import sleep

sentry_sdk.init(
    debug=True,
    traces_sample_rate=1.0,
    _experiments={"otel_powered_performance": True},
)

with sentry_sdk.start_span(description="sentry request"):
    sleep(0.1)
    with sentry_sdk.start_span(description="sentry db"):
        sleep(0.5)
        with sentry_sdk.start_span(description="sentry redis"):
            sleep(0.2)
    with sentry_sdk.start_span(description="sentry http"):
        sleep(1)

References

Misc

In OTel, this:

with tracer.start_as_current_span("parent") as parent:
    with tracer.start_span("child1"):
        pass
    with tracer.start_span("child2"):
        pass

is equivalent to

from opentelemetry import trace, context

parent = tracer.start_span("parent")

# Creates a Context object with parent set as current span
ctx = trace.set_span_in_context(parent)

# Set as the implicit current context
token = context.attach(ctx)

# Child will automatically be a child of parent
child1 = tracer.start_span("child1")
child1.end()

# Child will automatically be a child of parent
child2 = tracer.start_span("child2")
child2.end()

# Don't forget to detach or parent will remain the parent above this call stack
context.detach(token)
parent.end()

@sl0thentr0py sl0thentr0py requested a review from sentrivana June 10, 2024 19:00
@sl0thentr0py sl0thentr0py force-pushed the potel-base branch 2 times, most recently from f7f153c to 28effd6 Compare June 11, 2024 11:43
@sl0thentr0py sl0thentr0py force-pushed the potel-base branch 2 times, most recently from 16f9341 to 951477f Compare June 25, 2024 15:16
Copy link

codecov bot commented Jun 26, 2024

Codecov Report

❌ Patch coverage is 91.54863% with 179 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.02%. Comparing base (19914cd) to head (893d9fb).
⚠️ Report is 3 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
sentry_sdk/integrations/aws_lambda.py 26.76% 52 Missing ⚠️
sentry_sdk/integrations/gcp.py 0.00% 35 Missing ⚠️
sentry_sdk/integrations/ray.py 43.47% 13 Missing ⚠️
sentry_sdk/integrations/clickhouse_driver.py 79.54% 5 Missing and 4 partials ⚠️
sentry_sdk/integrations/tornado.py 82.22% 5 Missing and 3 partials ⚠️
sentry_sdk/integrations/asgi.py 89.39% 4 Missing and 3 partials ⚠️
sentry_sdk/integrations/rq.py 86.04% 2 Missing and 4 partials ⚠️
sentry_sdk/integrations/django/__init__.py 91.37% 5 Missing ⚠️
sentry_sdk/integrations/aiohttp.py 93.44% 2 Missing and 2 partials ⚠️
sentry_sdk/integrations/wsgi.py 92.00% 2 Missing and 2 partials ⚠️
... and 24 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3152      +/-   ##
==========================================
- Coverage   85.07%   85.02%   -0.06%     
==========================================
  Files         156      158       +2     
  Lines       15824    15541     -283     
  Branches     2677     2461     -216     
==========================================
- Hits        13462    13213     -249     
+ Misses       1583     1572      -11     
+ Partials      779      756      -23     
Files with missing lines Coverage Δ
sentry_sdk/__init__.py 100.00% <100.00%> (ø)
sentry_sdk/_init_implementation.py 100.00% <100.00%> (+4.16%) ⬆️
sentry_sdk/_log_batcher.py 79.76% <100.00%> (+0.24%) ⬆️
sentry_sdk/_lru_cache.py 100.00% <100.00%> (ø)
sentry_sdk/_queue.py 62.22% <100.00%> (ø)
sentry_sdk/_werkzeug.py 50.00% <100.00%> (+1.85%) ⬆️
sentry_sdk/ai/monitoring.py 89.47% <100.00%> (+0.14%) ⬆️
sentry_sdk/ai/utils.py 73.91% <100.00%> (+1.18%) ⬆️
sentry_sdk/api.py 94.54% <100.00%> (+7.96%) ⬆️
sentry_sdk/attachments.py 100.00% <100.00%> (ø)
... and 140 more

@sl0thentr0py sl0thentr0py changed the title Skeletons for new POTEL components New POTEL base branch Jul 9, 2024
@sl0thentr0py sl0thentr0py changed the title New POTEL base branch potel implementation base branch Jul 9, 2024
@antonpirker antonpirker changed the title potel implementation base branch POtel implementation base branch Aug 5, 2024
@sentrivana sentrivana removed their request for review August 28, 2024 09:12
sentrivana and others added 18 commits December 2, 2024 15:42
* Make sure to add data before span is closed. some cleanup

* Fixed some tests
* Make sure only spans are created, not transactions
* Move scope context init outside integration

* Fix ThreadingIntegration by carrying forward span reference in (#3851)

`use_scope`

Since the otel context span reference is the source of truth for the
current active span, we need to explicitly pass the span reference on
the scope through when we use `use_scope` since we are changing context
variables in the other thread.

Also,

* fixes some typing in the original scope
* adds more types to the `contextvars_context` manager
getsentry-bot and others added 30 commits July 22, 2025 08:33
Remove `MAX_EVENT_BYTES` (which doesn't seem to be used anyway?)

Ref #4172
The migration guide was slowly becoming unreadable. It doesn't have to
be as digestible as the migration guide in the docs, but it still
shouldn't completely suck.

Divide stuff into subsections and rephrase/expand on some points.
Unsure if the types in `tests` are any good, but might as well make them
into annotations
Merging `master` into `potel-base`, done in a PR because there have been
some changes needed to the `span.name` setter to make it work for potel.
…4682)

Co-authored-by: Ivana Kellyer <ivana.kellyer@sentry.io>
Seems like some `before_send`s out there might assume tags without safe
access as we found out during dogfooding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants