Skip to content

Commit f0de66b

Browse files
committed
Merge branch 'master' into ivana/toxgen/httpx
2 parents 762a233 + 178c5d2 commit f0de66b

File tree

9 files changed

+88
-8
lines changed

9 files changed

+88
-8
lines changed

CHANGELOG.md

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

3+
## 2.38.0
4+
5+
### Various fixes & improvements
6+
7+
- Feat(huggingface_hub): Update HuggingFace Hub integration (#4746) by @antonpirker
8+
- Feat(Anthropic): Add proper tool calling data to Anthropic integration (#4769) by @antonpirker
9+
- Feat(openai-agents): Add input and output to `invoke_agent` span. (#4785) by @antonpirker
10+
- Feat(AI): Create transaction in AI agents framworks, when no transaction is running. (#4758) by @constantinius
11+
- Feat(GraphQL): Support gql 4.0-style execute (#4779) by @sentrivana
12+
- Fix(logs): Expect `log_item` as rate limit category (#4798) by @sentrivana
13+
- Fix: CI for mypy, gevent (#4790) by @sentrivana
14+
- Fix: Correctly check for a running transaction (#4791) by @antonpirker
15+
- Fix: Use float for sample rand (#4677) by @sentrivana
16+
- Fix: Avoid reporting false-positive StopAsyncIteration in the asyncio integration (#4741) by @vmarkovtsev
17+
- Fix: Add log message when `DedupeIntegration` is dropping an error. (#4788) by @antonpirker
18+
- Fix(profiling): Re-init continuous profiler (#4772) by @Zylphrex
19+
- Chore: Reexport module `profiler` (#4535) by @zen-xu
20+
- Tests: Update tox.ini (#4799) by @sentrivana
21+
- Build(deps): bump actions/create-github-app-token from 2.1.1 to 2.1.4 (#4795) by @dependabot
22+
- Build(deps): bump actions/setup-python from 5 to 6 (#4774) by @dependabot
23+
- Build(deps): bump codecov/codecov-action from 5.5.0 to 5.5.1 (#4773) by @dependabot
24+
325
## 2.37.1
426

527
### Various fixes & improvements

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
copyright = "2019-{}, Sentry Team and Contributors".format(datetime.now().year)
3232
author = "Sentry Team and Contributors"
3333

34-
release = "2.37.1"
34+
release = "2.38.0"
3535
version = ".".join(release.split(".")[:2]) # The short X.Y version.
3636

3737

sentry_sdk/_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ class SDKInfo(TypedDict):
269269
"metric_bucket",
270270
"monitor",
271271
"span",
272-
"log",
272+
"log_item",
273273
]
274274
SessionStatus = Literal["ok", "exited", "crashed", "abnormal"]
275275

sentry_sdk/consts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,4 +1331,4 @@ def _get_default_options():
13311331
del _get_default_options
13321332

13331333

1334-
VERSION = "2.37.1"
1334+
VERSION = "2.38.0"

sentry_sdk/envelope.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def data_category(self):
273273
elif ty == "event":
274274
return "error"
275275
elif ty == "log":
276-
return "log"
276+
return "log_item"
277277
elif ty == "client_report":
278278
return "internal"
279279
elif ty == "profile":

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def get_file_text(file_name):
2121

2222
setup(
2323
name="sentry-sdk",
24-
version="2.37.1",
24+
version="2.38.0",
2525
author="Sentry Team and Contributors",
2626
author_email="[email protected]",
2727
url="https://github.com/getsentry/sentry-python",

tests/test_envelope.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from sentry_sdk.envelope import Envelope
1+
from sentry_sdk.envelope import Envelope, Item, PayloadRef
22
from sentry_sdk.session import Session
33
from sentry_sdk import capture_event
44
import sentry_sdk.client
@@ -239,3 +239,24 @@ def test_envelope_without_headers():
239239

240240
assert len(items) == 1
241241
assert items[0].payload.get_bytes() == b'{"started": "2020-02-07T14:16:00Z"}'
242+
243+
244+
def test_envelope_item_data_category_mapping():
245+
"""Test that envelope items map to correct data categories for rate limiting."""
246+
test_cases = [
247+
("event", "error"),
248+
("transaction", "transaction"),
249+
("log", "log_item"),
250+
("session", "session"),
251+
("attachment", "attachment"),
252+
("client_report", "internal"),
253+
("profile", "profile"),
254+
("profile_chunk", "profile_chunk"),
255+
("statsd", "metric_bucket"),
256+
("check_in", "monitor"),
257+
("unknown_type", "default"),
258+
]
259+
260+
for item_type, expected_category in test_cases:
261+
item = Item(payload=PayloadRef(json={"test": "data"}), type=item_type)
262+
assert item.data_category == expected_category

tests/test_transport.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ def test_metric_bucket_limits(capturing_server, response_code, make_client):
611611
assert capturing_server.captured[0].path == "/api/132/envelope/"
612612
capturing_server.clear_captured()
613613

614-
assert set(client.transport._disabled_until) == set(["metric_bucket"])
614+
assert set(client.transport._disabled_until) == {"metric_bucket"}
615615

616616
client.transport.capture_envelope(envelope)
617617
client.capture_event({"type": "transaction"})
@@ -629,6 +629,43 @@ def test_metric_bucket_limits(capturing_server, response_code, make_client):
629629
]
630630

631631

632+
@pytest.mark.parametrize("response_code", [200, 429])
633+
def test_log_item_limits(capturing_server, response_code, make_client):
634+
client = make_client()
635+
capturing_server.respond_with(
636+
code=response_code,
637+
headers={
638+
"X-Sentry-Rate-Limits": "4711:log_item:organization:quota_exceeded:custom"
639+
},
640+
)
641+
642+
envelope = Envelope()
643+
envelope.add_item(Item(payload=b"{}", type="log"))
644+
client.transport.capture_envelope(envelope)
645+
client.flush()
646+
647+
assert len(capturing_server.captured) == 1
648+
assert capturing_server.captured[0].path == "/api/132/envelope/"
649+
capturing_server.clear_captured()
650+
651+
assert set(client.transport._disabled_until) == {"log_item"}
652+
653+
client.transport.capture_envelope(envelope)
654+
client.capture_event({"type": "transaction"})
655+
client.flush()
656+
657+
assert len(capturing_server.captured) == 2
658+
659+
envelope = capturing_server.captured[0].envelope
660+
assert envelope.items[0].type == "transaction"
661+
envelope = capturing_server.captured[1].envelope
662+
assert envelope.items[0].type == "client_report"
663+
report = parse_json(envelope.items[0].get_bytes())
664+
assert report["discarded_events"] == [
665+
{"category": "log_item", "reason": "ratelimit_backoff", "quantity": 1},
666+
]
667+
668+
632669
@pytest.mark.parametrize("response_code", [200, 429])
633670
def test_metric_bucket_limits_with_namespace(
634671
capturing_server, response_code, make_client

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# The file (and all resulting CI YAMLs) then need to be regenerated via
1111
# "scripts/generate-test-files.sh".
1212
#
13-
# Last generated: 2025-09-15T15:03:26.855602+00:00
13+
# Last generated: 2025-09-15T15:06:00.206204+00:00
1414

1515
[tox]
1616
requires =

0 commit comments

Comments
 (0)