Skip to content

feat(tracing): AI Agents templates for @trace decorator - #4676

Merged
antonpirker merged 83 commits into
masterfrom
manual-instrumentation2
Aug 13, 2025
Merged

antonpirker merged 83 commits into
masterfrom
manual-instrumentation2

Conversation

@antonpirker

@antonpirker antonpirker commented Aug 6, 2025 •

Copy link
Copy Markdown
Contributor

Adding a template parameter to the @trace decorator to make it easier to manually create spans for insights modules. Currently there are three templates supported ai_agent, ai_tool, and ai_chat.

@antonpirker antonpirker changed the title feat(agents): AI Agents templates for @trace decorator feat(tracing): AI Agents templates for @trace decorator Aug 11, 2025
Comment thread sentry_sdk/consts.py Resolved
Comment thread sentry_sdk/tracing_utils.py Resolved
Comment thread sentry_sdk/tracing_utils.py Resolved
Comment thread sentry_sdk/tracing_utils.py Resolved
Comment thread sentry_sdk/tracing_utils.py Resolved
Comment thread sentry_sdk/tracing_utils.py Resolved
Comment thread sentry_sdk/tracing_utils.py Resolved
Comment thread sentry_sdk/tracing_utils.py Resolved
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@sentrivana sentrivana left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tests are looking much better, also thanks for the dedup.

There's still some places where it'd be good to dedup, see comments

Comment thread sentry_sdk/tracing_utils.py Resolved
Comment thread sentry_sdk/tracing_utils.py Resolved
Comment thread sentry_sdk/tracing_utils.py Resolved
cursor[bot]

This comment was marked as outdated.

@antonpirker
antonpirker enabled auto-merge (squash) August 13, 2025 10:54
@antonpirker
antonpirker merged commit 1804955 into master Aug 13, 2025
@antonpirker
antonpirker deleted the manual-instrumentation2 branch August 13, 2025 11:04
sentrivana added a commit that referenced this pull request Oct 29, 2026
### Description

Removes the private `_get_usage_attributes()` helper from
`sentry_sdk/tracing_utils.py`. Nothing on `major/3.0` calls it anymore.

It pulled `gen_ai.usage.*` token counts out of return values for the AI
Agents `@trace` templates added in #4676. #7457 ("Remove trace template,
trace_ignore_status_codes") deleted the template code that called it,
but left the helper behind.

**Evidence**
- On `major/3.0`, `git grep -w _get_usage_attributes` matches only the
definition. There are no callers in `sentry_sdk` or `tests`.
- No open PR touches it.

`_get_value()` is still imported by the LangChain integration, so it
stays.

On `master` the helper is still used, because the trace templates still
exist there. This change only applies to `major/3.0`.

#### Issues
n/a

<!-- junior-request-attribution:start -->
via **Ivana Kellyer**.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC0BTREZTS2Z%3A1793270559.842119 -->

--

[View Junior
Session](https://junior-prod.sentry.dev/conversations/slack%3AC0BTREZTS2Z%3A1793270559.842119)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0BTREZTS2Z%3A1793270559.842119/?project=4510944073809921)

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

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Ivana Kellyer <ivana.kellyer@sentry.io>
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.

2 participants