Skip to content

fix(semconv): add latest GenAI semantic convention attributes#3990

Open
electricwolfemarshmallowhypertext wants to merge 1 commit intotraceloop:mainfrom
electricwolfemarshmallowhypertext:fix-genai-deprecated-attrs-3515
Open

fix(semconv): add latest GenAI semantic convention attributes#3990
electricwolfemarshmallowhypertext wants to merge 1 commit intotraceloop:mainfrom
electricwolfemarshmallowhypertext:fix-genai-deprecated-attrs-3515

Conversation

@electricwolfemarshmallowhypertext
Copy link
Copy Markdown

@electricwolfemarshmallowhypertext electricwolfemarshmallowhypertext commented Apr 14, 2026

  • I have added tests that cover my changes.
  • If adding a new instrumentation or changing an existing one, I've added screenshots from some observability platform showing the change.
  • PR name follows conventional commits format: feat(instrumentation): ... or fix(instrumentation): ....
  • (If applicable) I have updated the documentation accordingly.

Fixes #3515.

Adds constants for the latest OpenTelemetry GenAI message attributes:

  • gen_ai.input.messages
  • gen_ai.output.messages
  • gen_ai.system_instructions

The existing gen_ai.prompt and gen_ai.completion constants are preserved for backward compatibility.

Tests updated in opentelemetry-semantic-conventions-ai/_testing.py.

Tested locally:

245 passed in 0.23s

Summary by CodeRabbit

  • New Features
    • Added three new span attributes to semantic conventions: gen_ai.input.messages, gen_ai.output.messages, and gen_ai.system_instructions.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 14, 2026

📝 Walkthrough

Walkthrough

This PR adds three new legacy SpanAttributes constants—GEN_AI_INPUT_MESSAGES, GEN_AI_OUTPUT_MESSAGES, and GEN_AI_SYSTEM_INSTRUCTIONS—to align with updated OpenTelemetry GenAI semantic conventions, replacing deprecated gen_ai.prompt and gen_ai.completion attributes.

Changes

Cohort / File(s) Summary
New GenAI Span Attributes Constants
packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/__init__.py
Added three new SpanAttributes legacy constants mapping to gen_ai.input.messages, gen_ai.output.messages, and gen_ai.system_instructions namespaces.
Test Parametrization Updates
packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/_testing.py
Extended TestSpanAttributesLegacyLLMNamesPresent parametrized assertions to validate the three new legacy-name constants and their expected mappings.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 Hops with delight through conventions so bright,
Old gen_ai.prompt bids farewell tonight,
Input and output, instructions now clear,
Structured messages bring semantics near!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive The PR adds the three new attribute constants (gen_ai.input.messages, gen_ai.output.messages, gen_ai.system_instructions) required by issue #3515, but does not implement the structured message format or update instrumentation logic. Clarify whether the constant definitions alone fully satisfy #3515's requirement to migrate instrumentation to use the new structured message format, or if additional work is needed.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly describes the main change: adding new GenAI semantic convention attributes to maintain alignment with the latest OpenTelemetry specification.
Out of Scope Changes check ✅ Passed All changes are directly scoped to adding the three new GenAI semantic convention attribute constants and their test cases as specified in #3515.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/__init__.py (1)

159-161: Consider moving these GEN_AI_* constants out of the legacy alias block.

Line 159-Line 161 are canonical GEN_AI_* names, but they currently live under Legacy LLM_* aliases. Keeping true legacy aliases and canonical constants in separate sections will make future deprecation/migration cleanup less error-prone.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/__init__.py`
around lines 159 - 161, The three canonical constants GEN_AI_INPUT_MESSAGES,
GEN_AI_OUTPUT_MESSAGES, and GEN_AI_SYSTEM_INSTRUCTIONS are currently placed
inside the "Legacy LLM_* aliases" block; move these canonical GEN_AI_*
definitions out of that legacy section into the main canonical constants area
(or create a separate "Canonical GEN_AI constants" section) so canonical names
are clearly separated from legacy aliases, while keeping any LLM_* alias
assignments below (or referencing the moved constants) to preserve
backward-compatible aliases.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/__init__.py`:
- Around line 159-161: The three canonical constants GEN_AI_INPUT_MESSAGES,
GEN_AI_OUTPUT_MESSAGES, and GEN_AI_SYSTEM_INSTRUCTIONS are currently placed
inside the "Legacy LLM_* aliases" block; move these canonical GEN_AI_*
definitions out of that legacy section into the main canonical constants area
(or create a separate "Canonical GEN_AI constants" section) so canonical names
are clearly separated from legacy aliases, while keeping any LLM_* alias
assignments below (or referencing the moved constants) to preserve
backward-compatible aliases.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d66b5513-eab7-44ad-a787-3acc10217c21

📥 Commits

Reviewing files that changed from the base of the PR and between b80f109 and ec62de1.

📒 Files selected for processing (2)
  • packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/__init__.py
  • packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/_testing.py

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.

🐛 Bug Report: span attributes gen_ai.prompt and gen_ai.completion are deprecated in the latest OpenTelemetry Semantic Conventions

2 participants