Skip to content

ref(attributes): Enforce sentry-conventions in task integrations - #8404

Draft
srothh wants to merge 3 commits into
srothh/add-conventions-dependencyfrom
srothh/conventions-tasks-mcp-integrations
Draft

srothh wants to merge 3 commits into
srothh/add-conventions-dependencyfrom
srothh/conventions-tasks-mcp-integrations

Conversation

@srothh

@srothh srothh commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Description

Enforce sentry-conventions attributes in task integrations (huey, arq, celery, dramatiq, mcp, ray, rq).

Issues

#8323
PY-3090

Enforce sentry-conventions attributes in task integrations (huey, arq, celery, dramatiq, mcp, ray, rq).

#8323
PY-3090
@linear-code

linear-code Bot commented Nov 26, 2026

Copy link
Copy Markdown

PY-3090

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Results 📊

✅ 59240 passed | ❌ 1 failed | ⏭️ 3047 skipped | Total: 62288 | Pass Rate: 95.11% | Execution Time: 162m 50s

📊 Comparison with Base Branch

Metric Change
Total Tests 📉 -288
Passed Tests 📉 -217
Failed Tests 📈 +1
Skipped Tests 📉 -72

➕ New Tests (1)

View new tests
  • test_no_process_span_without_messages
    • File: tests.integrations.aws_lambda.test_aws_lambda
    • Status: ❌ Failing

❌ Failed Tests

test_no_process_span_without_messages

File: tests.integrations.aws_lambda.test_aws_lambda
Suite: py3.9-aws_lambda
Error: ValueError: too many values to unpack (expected 1)

Stack Trace
tests/integrations/aws_lambda/test_aws_lambda.py:964: in test_no_process_span_without_messages
    (span,) = test_environment["server"].span_items
E   ValueError: too many values to unpack (expected 1)

✅ Patch coverage is 100.00% (25 of 25 changed executable lines covered; target 80%).
Project statement coverage is 90.12% (up 0.01 percentage points from base (c0b416a) to head (fe37fd6)).

Changed files with executable lines (7)
File Patch coverage Changed executable lines
sentry_sdk/integrations/arq.py 100.00% 2/2 covered
sentry_sdk/integrations/celery/init.py 100.00% 7/7 covered
sentry_sdk/integrations/dramatiq.py 100.00% 2/2 covered
sentry_sdk/integrations/huey.py 100.00% 2/2 covered
sentry_sdk/integrations/mcp.py 100.00% 8/8 covered
sentry_sdk/integrations/ray.py 100.00% 1/1 covered
sentry_sdk/integrations/rq.py 100.00% 3/3 covered
Coverage diff
@@            Coverage Diff             @@
##        master     #8404       +/-##
==========================================
+ Coverage    90.11%    90.12%    +0.01%
==========================================
  Files          201       200        -1
  Tracked lines     22199     22105       -94
  Branches      7784      7746       -38
==========================================
- Hits         20004     19921       -83
+ Misses        2195      2184       -11
+ Partials      1283      1276        -7

Generated by Coverage Action

Enforce sentry-conventions attribute names in task integration tests
(arq, celery, dramatiq, fastmcp, huey, mcp, ray, rq).

#8323
PY-3090

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reference the deprecated mcp.request.id attribute through ATTRIBUTE_NAMES instead of
SPANDATA in the mcp integration and the mcp and fastmcp tests. The sent keys stay the same.

#8323
PY-3090

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sentrivana pushed a commit that referenced this pull request Nov 30, 2026
### Description

Removes `_extract_tool_result_content()` from
`sentry_sdk/integrations/mcp.py` (39 lines). Nothing calls it.

**Why it's dead**

- #4964 added it with the MCP integration. It
turned the return value of a patched low-level server tool handler
(`CallToolResult`, a `(unstructured, structured)` tuple, a dict, or a
list of content blocks) into the value for the tool result span
attribute.
- #7508 (`chore(mcp): Drop support for < 2.0`)
replaced that handler patching with the server middleware and deleted
the only call (`extracted = _extract_tool_result_content(result)`). The
definition stayed behind.
- On mcp 2.x, `_instrument_tool_call` gets the result as a dict and
reads `structuredContent` or `content` from it inline. It calls
`_extract_text_from_content_blocks` directly, and this PR keeps that
function.
- `git grep _extract_tool_result_content` on `master` finds only the
definition. `git log -S "_extract_tool_result_content("` finds only the
two PRs above. The helper is private and isn't exported or documented.

**Why it's safe**

Nothing reaches the function, so no behavior changes. Public API,
supported mcp versions, and dependencies stay the same. No open PR or
issue mentions it. The only open PR that touches `mcp.py`,
#8404, edits other lines, so it shouldn't
conflict.

**Why it's better gone**

A reader of `mcp.py` today sees two ways tool results get extracted, and
only the inline one runs. The dead helper also documents result shapes
(tuple, `CallToolResult` object) that the middleware path never
receives.

#### Issues
None.

<!-- junior-request-attribution:start -->
via [automation
`sched_65eed06cc199036c2b13411096f412d4`](https://junior-prod.sentry.dev/automations/sched_65eed06cc199036c2b13411096f412d4)
· Run ID `sched_65eed06cc199036c2b13411096f412d4:1796025600000`.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!--
junior-conversation-id:agent-dispatch%3Adispatch_d2b9643c275b26cf884e93a61f07e0cf
-->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent-dispatch%3Adispatch_d2b9643c275b26cf884e93a61f07e0cf)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent-dispatch%3Adispatch_d2b9643c275b26cf884e93a61f07e0cf/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

1 participant