Skip to content

Commit d7e2c21

Browse files
committed
Merge branch 'master' into potel-base
2 parents 6d2e988 + 76d6b04 commit d7e2c21

37 files changed

+334
-121
lines changed

.github/workflows/test-integrations-ai.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
coverage xml
7171
- name: Upload coverage to Codecov
7272
if: ${{ !cancelled() }}
73-
uses: codecov/[email protected].0
73+
uses: codecov/[email protected].2
7474
with:
7575
token: ${{ secrets.CODECOV_TOKEN }}
7676
files: coverage.xml
@@ -132,7 +132,7 @@ jobs:
132132
coverage xml
133133
- name: Upload coverage to Codecov
134134
if: ${{ !cancelled() }}
135-
uses: codecov/[email protected].0
135+
uses: codecov/[email protected].2
136136
with:
137137
token: ${{ secrets.CODECOV_TOKEN }}
138138
files: coverage.xml

.github/workflows/test-integrations-cloud.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
coverage xml
7575
- name: Upload coverage to Codecov
7676
if: ${{ !cancelled() }}
77-
uses: codecov/[email protected].0
77+
uses: codecov/[email protected].2
7878
with:
7979
token: ${{ secrets.CODECOV_TOKEN }}
8080
files: coverage.xml
@@ -140,7 +140,7 @@ jobs:
140140
coverage xml
141141
- name: Upload coverage to Codecov
142142
if: ${{ !cancelled() }}
143-
uses: codecov/[email protected].0
143+
uses: codecov/[email protected].2
144144
with:
145145
token: ${{ secrets.CODECOV_TOKEN }}
146146
files: coverage.xml

.github/workflows/test-integrations-common.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
coverage xml
5555
- name: Upload coverage to Codecov
5656
if: ${{ !cancelled() }}
57-
uses: codecov/[email protected].0
57+
uses: codecov/[email protected].2
5858
with:
5959
token: ${{ secrets.CODECOV_TOKEN }}
6060
files: coverage.xml

.github/workflows/test-integrations-dbs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
coverage xml
9595
- name: Upload coverage to Codecov
9696
if: ${{ !cancelled() }}
97-
uses: codecov/[email protected].0
97+
uses: codecov/[email protected].2
9898
with:
9999
token: ${{ secrets.CODECOV_TOKEN }}
100100
files: coverage.xml
@@ -180,7 +180,7 @@ jobs:
180180
coverage xml
181181
- name: Upload coverage to Codecov
182182
if: ${{ !cancelled() }}
183-
uses: codecov/[email protected].0
183+
uses: codecov/[email protected].2
184184
with:
185185
token: ${{ secrets.CODECOV_TOKEN }}
186186
files: coverage.xml

.github/workflows/test-integrations-flags.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
coverage xml
6767
- name: Upload coverage to Codecov
6868
if: ${{ !cancelled() }}
69-
uses: codecov/[email protected].0
69+
uses: codecov/[email protected].2
7070
with:
7171
token: ${{ secrets.CODECOV_TOKEN }}
7272
files: coverage.xml

.github/workflows/test-integrations-gevent.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
coverage xml
5555
- name: Upload coverage to Codecov
5656
if: ${{ !cancelled() }}
57-
uses: codecov/[email protected].0
57+
uses: codecov/[email protected].2
5858
with:
5959
token: ${{ secrets.CODECOV_TOKEN }}
6060
files: coverage.xml

.github/workflows/test-integrations-graphql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
coverage xml
6767
- name: Upload coverage to Codecov
6868
if: ${{ !cancelled() }}
69-
uses: codecov/[email protected].0
69+
uses: codecov/[email protected].2
7070
with:
7171
token: ${{ secrets.CODECOV_TOKEN }}
7272
files: coverage.xml

.github/workflows/test-integrations-misc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
coverage xml
7575
- name: Upload coverage to Codecov
7676
if: ${{ !cancelled() }}
77-
uses: codecov/[email protected].0
77+
uses: codecov/[email protected].2
7878
with:
7979
token: ${{ secrets.CODECOV_TOKEN }}
8080
files: coverage.xml

.github/workflows/test-integrations-network.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
coverage xml
6363
- name: Upload coverage to Codecov
6464
if: ${{ !cancelled() }}
65-
uses: codecov/[email protected].0
65+
uses: codecov/[email protected].2
6666
with:
6767
token: ${{ secrets.CODECOV_TOKEN }}
6868
files: coverage.xml
@@ -116,7 +116,7 @@ jobs:
116116
coverage xml
117117
- name: Upload coverage to Codecov
118118
if: ${{ !cancelled() }}
119-
uses: codecov/[email protected].0
119+
uses: codecov/[email protected].2
120120
with:
121121
token: ${{ secrets.CODECOV_TOKEN }}
122122
files: coverage.xml

.github/workflows/test-integrations-tasks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
coverage xml
8585
- name: Upload coverage to Codecov
8686
if: ${{ !cancelled() }}
87-
uses: codecov/[email protected].0
87+
uses: codecov/[email protected].2
8888
with:
8989
token: ${{ secrets.CODECOV_TOKEN }}
9090
files: coverage.xml
@@ -160,7 +160,7 @@ jobs:
160160
coverage xml
161161
- name: Upload coverage to Codecov
162162
if: ${{ !cancelled() }}
163-
uses: codecov/[email protected].0
163+
uses: codecov/[email protected].2
164164
with:
165165
token: ${{ secrets.CODECOV_TOKEN }}
166166
files: coverage.xml

.github/workflows/test-integrations-web-1.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
coverage xml
8585
- name: Upload coverage to Codecov
8686
if: ${{ !cancelled() }}
87-
uses: codecov/[email protected].0
87+
uses: codecov/[email protected].2
8888
with:
8989
token: ${{ secrets.CODECOV_TOKEN }}
9090
files: coverage.xml

.github/workflows/test-integrations-web-2.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
coverage xml
9191
- name: Upload coverage to Codecov
9292
if: ${{ !cancelled() }}
93-
uses: codecov/[email protected].0
93+
uses: codecov/[email protected].2
9494
with:
9595
token: ${{ secrets.CODECOV_TOKEN }}
9696
files: coverage.xml
@@ -172,7 +172,7 @@ jobs:
172172
coverage xml
173173
- name: Upload coverage to Codecov
174174
if: ${{ !cancelled() }}
175-
uses: codecov/[email protected].0
175+
uses: codecov/[email protected].2
176176
with:
177177
token: ${{ secrets.CODECOV_TOKEN }}
178178
files: coverage.xml

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Changelog
22

3+
## 2.27.0
4+
5+
### Various fixes & improvements
6+
7+
- fix: Make sure to use the default decimal context in our code (#4231) by @antonpirker
8+
- fix(integrations): ASGI integration not capture transactions in Websocket (#4293) by @guodong000
9+
- feat(typing): Make all relevant types public (#4315) by @antonpirker
10+
- feat(spans): Record flag evaluations as span attributes (#4280) by @cmanallen
11+
- test(logs): Avoid failure when running with integrations enabled (#4316) by @rominf
12+
- tests: Remove unused code and rerun (#4313) by @sentrivana
13+
- tests: Add cohere to toxgen (#4304) by @sentrivana
14+
- tests: Migrate fastapi to toxgen (#4302) by @sentrivana
15+
- tests: Add huggingface_hub to toxgen (#4299) by @sentrivana
16+
- tests: Add huey to toxgen (#4298) by @sentrivana
17+
- tests: Update tox.ini (#4297) by @sentrivana
18+
- tests: Move aiohttp under toxgen (#4319) by @sentrivana
19+
- tests: Fix version picking in toxgen (#4323) by @sentrivana
20+
- build(deps): bump codecov/codecov-action from 5.4.0 to 5.4.2 (#4318) by @dependabot
21+
322
## 2.26.1
423

524
### Various fixes & improvements

scripts/populate_tox/config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
# See scripts/populate_tox/README.md for more info on the format and examples.
77

88
TEST_SUITE_CONFIG = {
9+
"aiohttp": {
10+
"package": "aiohttp",
11+
"deps": {
12+
"*": ["pytest-aiohttp"],
13+
">=3.8": ["pytest-asyncio"],
14+
},
15+
"python": ">=3.7",
16+
},
917
"ariadne": {
1018
"package": "ariadne",
1119
"deps": {

scripts/populate_tox/populate_tox.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
"potel",
6767
# Integrations that can be migrated -- we should eventually remove all
6868
# of these from the IGNORE list
69-
"aiohttp",
7069
"anthropic",
7170
"arq",
7271
"asyncpg",
@@ -189,10 +188,10 @@ def _prefilter_releases(
189188
if (
190189
version.major == saved_version.major
191190
and version.minor == saved_version.minor
192-
and version.micro > saved_version.micro
193191
):
194192
# Don't save all patch versions of a release, just the newest one
195-
filtered_releases[i] = version
193+
if version.micro > saved_version.micro:
194+
filtered_releases[i] = version
196195
break
197196
else:
198197
filtered_releases.append(version)

scripts/populate_tox/tox.jinja

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ envlist =
3333
# At a minimum, we should test against at least the lowest
3434
# and the latest supported version of a framework.
3535

36-
# AIOHTTP
37-
{py3.7}-aiohttp-v{3.4}
38-
{py3.7,py3.9,py3.11}-aiohttp-v{3.8}
39-
{py3.8,py3.12,py3.13}-aiohttp-latest
40-
4136
# Anthropic
4237
{py3.8,py3.11,py3.12}-anthropic-v{0.16,0.28,0.40}
4338
{py3.7,py3.11,py3.12}-anthropic-latest
@@ -165,14 +160,6 @@ deps =
165160
166161
# === Integrations ===
167162
168-
# AIOHTTP
169-
aiohttp-v3.4: aiohttp~=3.4.0
170-
aiohttp-v3.8: aiohttp~=3.8.0
171-
aiohttp-latest: aiohttp
172-
aiohttp: pytest-aiohttp
173-
aiohttp-v3.8: pytest-asyncio
174-
aiohttp-latest: pytest-asyncio
175-
176163
# Anthropic
177164
anthropic: pytest-asyncio
178165
anthropic-v{0.16,0.28}: httpx<0.28.0

scripts/split_tox_gh_actions/templates/test_group.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777

7878
- name: Upload coverage to Codecov
7979
if: {% raw %}${{ !cancelled() }}{% endraw %}
80-
uses: codecov/[email protected].0
80+
uses: codecov/[email protected].2
8181
with:
8282
token: {% raw %}${{ secrets.CODECOV_TOKEN }}{% endraw %}
8383
files: coverage.xml

sentry_sdk/_types.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ class SDKInfo(TypedDict):
218218
tuple[None, None, None],
219219
]
220220

221+
# TODO: Make a proper type definition for this (PRs welcome!)
221222
Hint = Dict[str, Any]
223+
222224
Log = TypedDict(
223225
"Log",
224226
{
@@ -231,9 +233,13 @@ class SDKInfo(TypedDict):
231233
},
232234
)
233235

236+
# TODO: Make a proper type definition for this (PRs welcome!)
234237
Breadcrumb = Dict[str, Any]
238+
239+
# TODO: Make a proper type definition for this (PRs welcome!)
235240
BreadcrumbHint = Dict[str, Any]
236241

242+
# TODO: Make a proper type definition for this (PRs welcome!)
237243
SamplingContext = Dict[str, Any]
238244

239245
EventProcessor = Callable[[Event, Hint], Optional[Event]]

sentry_sdk/feature_flags.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,7 @@ def add_feature_flag(flag, result):
6666
"""
6767
flags = sentry_sdk.get_current_scope().flags
6868
flags.set(flag, result)
69+
70+
span = sentry_sdk.get_current_span()
71+
if span:
72+
span.set_flag(flag, result)

sentry_sdk/integrations/asgi.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ async def _run_app(self, scope, receive, send, asgi_version):
204204
ty = scope["type"]
205205

206206
method = scope.get("method", "").upper()
207-
should_trace = method in self.http_methods_to_capture
207+
should_trace = ty == "websocket" or (
208+
ty == "http" and method in self.http_methods_to_capture
209+
)
208210
if not should_trace:
209211
return await self._run_original_app(
210212
scope, receive, send, asgi_version

sentry_sdk/integrations/launchdarkly.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import TYPE_CHECKING
2-
import sentry_sdk
32

3+
from sentry_sdk.feature_flags import add_feature_flag
44
from sentry_sdk.integrations import DidNotEnable, Integration
55

66
try:
@@ -53,8 +53,8 @@ def metadata(self):
5353
def after_evaluation(self, series_context, data, detail):
5454
# type: (EvaluationSeriesContext, dict[Any, Any], EvaluationDetail) -> dict[Any, Any]
5555
if isinstance(detail.value, bool):
56-
flags = sentry_sdk.get_current_scope().flags
57-
flags.set(series_context.key, detail.value)
56+
add_feature_flag(series_context.key, detail.value)
57+
5858
return data
5959

6060
def before_evaluation(self, series_context, data):

sentry_sdk/integrations/openfeature.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import TYPE_CHECKING
2-
import sentry_sdk
32

3+
from sentry_sdk.feature_flags import add_feature_flag
44
from sentry_sdk.integrations import DidNotEnable, Integration
55

66
try:
@@ -29,11 +29,9 @@ class OpenFeatureHook(Hook):
2929
def after(self, hook_context, details, hints):
3030
# type: (HookContext, FlagEvaluationDetails[bool], HookHints) -> None
3131
if isinstance(details.value, bool):
32-
flags = sentry_sdk.get_current_scope().flags
33-
flags.set(details.flag_key, details.value)
32+
add_feature_flag(details.flag_key, details.value)
3433

3534
def error(self, hook_context, exception, hints):
3635
# type: (HookContext, Exception, HookHints) -> None
3736
if isinstance(hook_context.default_value, bool):
38-
flags = sentry_sdk.get_current_scope().flags
39-
flags.set(hook_context.flag_key, hook_context.default_value)
37+
add_feature_flag(hook_context.flag_key, hook_context.default_value)

sentry_sdk/integrations/unleash.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from functools import wraps
22
from typing import Any
33

4-
import sentry_sdk
4+
from sentry_sdk.feature_flags import add_feature_flag
55
from sentry_sdk.integrations import Integration, DidNotEnable
66

77
try:
@@ -26,8 +26,7 @@ def sentry_is_enabled(self, feature, *args, **kwargs):
2626

2727
# We have no way of knowing what type of unleash feature this is, so we have to treat
2828
# it as a boolean / toggle feature.
29-
flags = sentry_sdk.get_current_scope().flags
30-
flags.set(feature, enabled)
29+
add_feature_flag(feature, enabled)
3130

3231
return enabled
3332

sentry_sdk/opentelemetry/sampler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def should_sample(
276276

277277
# Compare sample_rand to sample_rate to make the final sampling decision
278278
sample_rate = float(cast("Union[bool, float, int]", sample_rate))
279-
sampled = sample_rand < sample_rate
279+
sampled = sample_rand < Decimal.from_float(sample_rate)
280280

281281
if sampled:
282282
return sampled_result(

sentry_sdk/tracing.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171

7272
from sentry_sdk.tracing_utils import Baggage
7373

74-
74+
_FLAGS_CAPACITY = 10
7575
_OTEL_VERSION = parse_version(otel_version)
7676

7777
tracer = otel_trace.get_tracer(__name__)
@@ -598,6 +598,13 @@ def set_context(self, key, value):
598598

599599
self.set_attribute(f"{SentrySpanAttribute.CONTEXT}.{key}", value)
600600

601+
def set_flag(self, flag, value):
602+
# type: (str, bool) -> None
603+
flag_count = self.get_attribute("flag.count") or 0
604+
if flag_count < _FLAGS_CAPACITY:
605+
self.set_attribute(f"flag.evaluation.{flag}", value)
606+
self.set_attribute("flag.count", flag_count + 1)
607+
601608

602609
# TODO-neel-potel add deprecation
603610
Transaction = Span

0 commit comments

Comments
 (0)