Skip to content

feat(junior): Add gen_ai.conversation.id semantic attribute#131

Merged
dcramer merged 2 commits intomainfrom
dcramer/feat/gen-ai-conversation-id
Mar 27, 2026
Merged

feat(junior): Add gen_ai.conversation.id semantic attribute#131
dcramer merged 2 commits intomainfrom
dcramer/feat/gen-ai-conversation-id

Conversation

@dcramer
Copy link
Copy Markdown
Member

@dcramer dcramer commented Mar 27, 2026

Add the gen_ai.conversation.id OpenTelemetry semantic convention attribute to
the logging context, mapped from the existing conversationId. This flows
through span attributes, Sentry tags, and log context — enabling Sentry's AI
agent monitoring to correlate all spans and events within a conversation.

The existing app.conversation.id attribute is preserved for backward
compatibility with current dashboards and queries.

Emit the gen_ai.conversation.id OpenTelemetry semantic convention
alongside the existing app.conversation.id attribute. This enables
Sentry AI agent monitoring to correlate spans across conversation
turns.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
junior-docs Ready Ready Preview, Comment Mar 27, 2026 5:45pm

Request Review

@dcramer dcramer marked this pull request as ready for review March 27, 2026 17:37
Use gen_ai.conversation.id instead of app.conversation.id and
gen_ai.agent.name instead of app.assistant.username, aligning with
OpenTelemetry gen_ai semantic conventions for Sentry AI agent
monitoring.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

function contextToAttributes(context: LogContext): LogAttributes {
const attributes: Record<string, unknown> = {
"app.conversation.id": context.conversationId,
"gen_ai.conversation.id": context.conversationId,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Backward-compatible app.conversation.id attribute not preserved

High Severity

The PR description states "The existing app.conversation.id attribute is preserved for backward compatibility with current dashboards and queries," but contextToAttributes only emits gen_ai.conversation.id — the old app.conversation.id key is completely removed. Any existing Sentry dashboards, alerts, or queries that filter on app.conversation.id will silently stop matching.

Fix in Cursor Fix in Web

function contextToAttributes(context: LogContext): LogAttributes {
const attributes: Record<string, unknown> = {
"app.conversation.id": context.conversationId,
"gen_ai.conversation.id": context.conversationId,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The code removes the app.conversation.id attribute, breaking the backward compatibility promised in the PR description and causing existing Sentry dashboards and alerts to fail silently.
Severity: MEDIUM

Suggested Fix

To maintain backward compatibility, modify the contextToAttributes function to emit both the old app.conversation.id and the new gen_ai.conversation.id attributes. This will ensure that existing observability systems continue to function correctly during the transition period.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: packages/junior/src/chat/logging.ts#L324

Potential issue: The pull request description claims that the `app.conversation.id`
attribute will be preserved for backward compatibility. However, the code changes
completely remove this attribute and replace it with `gen_ai.conversation.id`. The
`contextToAttributes` function, which is responsible for setting Sentry tags, now only
emits the new attribute. As a result, any existing Sentry dashboards, queries, or alerts
that rely on the `app.conversation.id` tag will silently stop receiving data, leading to
a regression in production observability without any warning.

Did we get this right? 👍 / 👎 to inform future reviews.

@dcramer dcramer merged commit ca15bbd into main Mar 27, 2026
14 checks passed
@dcramer dcramer deleted the dcramer/feat/gen-ai-conversation-id branch March 27, 2026 17:55
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