Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5.4.0
uses: codecov/codecov-action@v5.4.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down Expand Up @@ -132,7 +132,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5.4.0
uses: codecov/codecov-action@v5.4.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5.4.0
uses: codecov/codecov-action@v5.4.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down Expand Up @@ -140,7 +140,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5.4.0
uses: codecov/codecov-action@v5.4.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5.4.0
uses: codecov/codecov-action@v5.4.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-dbs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5.4.0
uses: codecov/codecov-action@v5.4.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down Expand Up @@ -180,7 +180,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5.4.0
uses: codecov/codecov-action@v5.4.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-flags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5.4.0
uses: codecov/codecov-action@v5.4.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-gevent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5.4.0
uses: codecov/codecov-action@v5.4.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-graphql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5.4.0
uses: codecov/codecov-action@v5.4.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5.4.0
uses: codecov/codecov-action@v5.4.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5.4.0
uses: codecov/codecov-action@v5.4.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5.4.0
uses: codecov/codecov-action@v5.4.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5.4.0
uses: codecov/codecov-action@v5.4.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down Expand Up @@ -160,7 +160,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5.4.0
uses: codecov/codecov-action@v5.4.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-web-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5.4.0
uses: codecov/codecov-action@v5.4.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-web-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5.4.0
uses: codecov/codecov-action@v5.4.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down Expand Up @@ -172,7 +172,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v5.4.0
uses: codecov/codecov-action@v5.4.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## 2.27.0

### Various fixes & improvements

- fix: Make sure to use the default decimal context in our code (#4231) by @antonpirker
- fix(integrations): ASGI integration not capture transactions in Websocket (#4293) by @guodong000
- feat(typing): Make all relevant types public (#4315) by @antonpirker
- feat(spans): Record flag evaluations as span attributes (#4280) by @cmanallen
- test(logs): Avoid failure when running with integrations enabled (#4316) by @rominf
- tests: Remove unused code and rerun (#4313) by @sentrivana
- tests: Add cohere to toxgen (#4304) by @sentrivana
- tests: Migrate fastapi to toxgen (#4302) by @sentrivana
- tests: Add huggingface_hub to toxgen (#4299) by @sentrivana
- tests: Add huey to toxgen (#4298) by @sentrivana
- tests: Update tox.ini (#4297) by @sentrivana
- tests: Move aiohttp under toxgen (#4319) by @sentrivana
- tests: Fix version picking in toxgen (#4323) by @sentrivana
- build(deps): bump codecov/codecov-action from 5.4.0 to 5.4.2 (#4318) by @dependabot

## 2.26.1

### Various fixes & improvements
Expand Down
8 changes: 8 additions & 0 deletions scripts/populate_tox/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
# See scripts/populate_tox/README.md for more info on the format and examples.

TEST_SUITE_CONFIG = {
"aiohttp": {
"package": "aiohttp",
"deps": {
"*": ["pytest-aiohttp"],
">=3.8": ["pytest-asyncio"],
},
"python": ">=3.7",
},
"ariadne": {
"package": "ariadne",
"deps": {
Expand Down
5 changes: 2 additions & 3 deletions scripts/populate_tox/populate_tox.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"potel",
# Integrations that can be migrated -- we should eventually remove all
# of these from the IGNORE list
"aiohttp",
"anthropic",
"arq",
"asyncpg",
Expand Down Expand Up @@ -189,10 +188,10 @@ def _prefilter_releases(
if (
version.major == saved_version.major
and version.minor == saved_version.minor
and version.micro > saved_version.micro
):
# Don't save all patch versions of a release, just the newest one
filtered_releases[i] = version
if version.micro > saved_version.micro:
filtered_releases[i] = version
break
else:
filtered_releases.append(version)
Expand Down
13 changes: 0 additions & 13 deletions scripts/populate_tox/tox.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ envlist =
# At a minimum, we should test against at least the lowest
# and the latest supported version of a framework.

# AIOHTTP
{py3.7}-aiohttp-v{3.4}
{py3.7,py3.9,py3.11}-aiohttp-v{3.8}
{py3.8,py3.12,py3.13}-aiohttp-latest

# Anthropic
{py3.8,py3.11,py3.12}-anthropic-v{0.16,0.28,0.40}
{py3.7,py3.11,py3.12}-anthropic-latest
Expand Down Expand Up @@ -165,14 +160,6 @@ deps =

# === Integrations ===

# AIOHTTP
aiohttp-v3.4: aiohttp~=3.4.0
aiohttp-v3.8: aiohttp~=3.8.0
aiohttp-latest: aiohttp
aiohttp: pytest-aiohttp
aiohttp-v3.8: pytest-asyncio
aiohttp-latest: pytest-asyncio

# Anthropic
anthropic: pytest-asyncio
anthropic-v{0.16,0.28}: httpx<0.28.0
Expand Down
2 changes: 1 addition & 1 deletion scripts/split_tox_gh_actions/templates/test_group.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

- name: Upload coverage to Codecov
if: {% raw %}${{ !cancelled() }}{% endraw %}
uses: codecov/codecov-action@v5.4.0
uses: codecov/codecov-action@v5.4.2
with:
token: {% raw %}${{ secrets.CODECOV_TOKEN }}{% endraw %}
files: coverage.xml
Expand Down
6 changes: 6 additions & 0 deletions sentry_sdk/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ class SDKInfo(TypedDict):
tuple[None, None, None],
]

# TODO: Make a proper type definition for this (PRs welcome!)
Hint = Dict[str, Any]

Log = TypedDict(
"Log",
{
Expand All @@ -231,9 +233,13 @@ class SDKInfo(TypedDict):
},
)

# TODO: Make a proper type definition for this (PRs welcome!)
Breadcrumb = Dict[str, Any]

# TODO: Make a proper type definition for this (PRs welcome!)
BreadcrumbHint = Dict[str, Any]

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

EventProcessor = Callable[[Event, Hint], Optional[Event]]
Expand Down
4 changes: 4 additions & 0 deletions sentry_sdk/feature_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ def add_feature_flag(flag, result):
"""
flags = sentry_sdk.get_current_scope().flags
flags.set(flag, result)

span = sentry_sdk.get_current_span()
if span:
span.set_flag(flag, result)
4 changes: 3 additions & 1 deletion sentry_sdk/integrations/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ async def _run_app(self, scope, receive, send, asgi_version):
ty = scope["type"]

method = scope.get("method", "").upper()
should_trace = method in self.http_methods_to_capture
should_trace = ty == "websocket" or (
ty == "http" and method in self.http_methods_to_capture
)
if not should_trace:
return await self._run_original_app(
scope, receive, send, asgi_version
Expand Down
6 changes: 3 additions & 3 deletions sentry_sdk/integrations/launchdarkly.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import sentry_sdk

from sentry_sdk.feature_flags import add_feature_flag
from sentry_sdk.integrations import DidNotEnable, Integration

try:
Expand Down Expand Up @@ -53,8 +53,8 @@ def metadata(self):
def after_evaluation(self, series_context, data, detail):
# type: (EvaluationSeriesContext, dict[Any, Any], EvaluationDetail) -> dict[Any, Any]
if isinstance(detail.value, bool):
flags = sentry_sdk.get_current_scope().flags
flags.set(series_context.key, detail.value)
add_feature_flag(series_context.key, detail.value)

return data

def before_evaluation(self, series_context, data):
Expand Down
8 changes: 3 additions & 5 deletions sentry_sdk/integrations/openfeature.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import sentry_sdk

from sentry_sdk.feature_flags import add_feature_flag
from sentry_sdk.integrations import DidNotEnable, Integration

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

def error(self, hook_context, exception, hints):
# type: (HookContext, Exception, HookHints) -> None
if isinstance(hook_context.default_value, bool):
flags = sentry_sdk.get_current_scope().flags
flags.set(hook_context.flag_key, hook_context.default_value)
add_feature_flag(hook_context.flag_key, hook_context.default_value)
5 changes: 2 additions & 3 deletions sentry_sdk/integrations/unleash.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from functools import wraps
from typing import Any

import sentry_sdk
from sentry_sdk.feature_flags import add_feature_flag
from sentry_sdk.integrations import Integration, DidNotEnable

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

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

return enabled

Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/opentelemetry/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def should_sample(

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

if sampled:
return sampled_result(
Expand Down
9 changes: 8 additions & 1 deletion sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@

from sentry_sdk.tracing_utils import Baggage


_FLAGS_CAPACITY = 10
_OTEL_VERSION = parse_version(otel_version)

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

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

def set_flag(self, flag, value):
# type: (str, bool) -> None
flag_count = self.get_attribute("flag.count") or 0
if flag_count < _FLAGS_CAPACITY:
self.set_attribute(f"flag.evaluation.{flag}", value)
self.set_attribute("flag.count", flag_count + 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to remove this flag.count in the span processor at the end?

We should probably cleanup some of these internal attributes at the end in general, since it costs money to get indexed and stored.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do in a new PR!



# TODO-neel-potel add deprecation
Transaction = Span
Expand Down
Loading
Loading