Skip to content

fix(semconv): revert deleted semconv attributes#3750

Merged
galkleinman merged 5 commits intomainfrom
gk/revert-deleted-semconv
Mar 2, 2026
Merged

fix(semconv): revert deleted semconv attributes#3750
galkleinman merged 5 commits intomainfrom
gk/revert-deleted-semconv

Conversation

@galkleinman
Copy link
Contributor

@galkleinman galkleinman commented Mar 2, 2026

Important

Reverts deletion of several semantic convention attributes in SpanAttributes class made in this PR to maintain backward compatibility.

  • Attributes Reversion:
    • Reverts deletion of attributes in SpanAttributes class in __init__.py.
    • Restores attributes like LLM_SYSTEM, LLM_REQUEST_MODEL, LLM_REQUEST_MAX_TOKENS, and others for backward compatibility.
    • Affects attributes related to LLM cache, request, response, and usage metrics.

This description was created by Ellipsis for 0b3e3f6. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • New Features

    • Added new public GenAI span attributes covering system, request parameters (model, max tokens, temperature, top_p, structured output schema, reasoning summary), prompts/completions, response model, token type, and token usage metrics.
  • Chores

    • Bumped package version to 0.4.15.

fix #3748
fix #3712

@galkleinman galkleinman requested a review from dinmukhamedm March 2, 2026 14:54
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to 0b3e3f6 in 9 seconds. Click for details.
  • Reviewed 29 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.

Workflow ID: wflow_piqclBsa3Za6OS4K

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@coderabbitai
Copy link

coderabbitai bot commented Mar 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e6a2ae3 and e4c7e43.

📒 Files selected for processing (2)
  • packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/version.py
  • packages/opentelemetry-semantic-conventions-ai/pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/opentelemetry-semantic-conventions-ai/pyproject.toml
  • packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/version.py

📝 Walkthrough

Walkthrough

Adds multiple new GenAI-related public span attribute constants to SpanAttributes and bumps the package version from 0.4.14 to 0.4.15; no removals or signature changes.

Changes

Cohort / File(s) Summary
GenAI Semantic Attributes
packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/__init__.py
Added new span attribute constants mapped to gen_ai.*: LLM_SYSTEM, LLM_REQUEST_MODEL, LLM_REQUEST_MAX_TOKENS, LLM_REQUEST_TEMPERATURE, LLM_REQUEST_TOP_P, LLM_PROMPTS, LLM_COMPLETIONS, LLM_RESPONSE_MODEL, LLM_USAGE_COMPLETION_TOKENS, LLM_USAGE_PROMPT_TOKENS, LLM_TOKEN_TYPE, LLM_REQUEST_STRUCTURED_OUTPUT_SCHEMA, LLM_REQUEST_REASONING_SUMMARY, LLM_RESPONSE_REASONING_EFFORT. Existing cache-related attributes retained.
Version bump
packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/version.py, packages/opentelemetry-semantic-conventions-ai/pyproject.toml
Updated package/module version from 0.4.14 to 0.4.15; no other API or signature changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I nibble on keys beneath moonlight,
New GenAI labels twinkle bright.
Prompts and tokens, model and more,
I hop, I stamp—these names I store. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(semconv): revert deleted semconv attributes' accurately and concisely describes the main change: restoring previously deleted semantic convention attributes to fix compatibility issues.
Linked Issues check ✅ Passed The PR successfully addresses both linked issues by restoring all missing SpanAttributes (LLM_SYSTEM, LLM_REQUEST_REASONING_SUMMARY, and 12 others) that were removed in a prior version, fixing AttributeError crashes in downstream instrumentations.
Out of Scope Changes check ✅ Passed All changes are directly scoped to restoring missing attributes and updating version numbers; no unrelated modifications or external dependencies were altered.
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 docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch gk/revert-deleted-semconv

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

Copy link

@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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/__init__.py`:
- Around line 79-87: Two class attributes in SpanAttributes are duplicated
(LLM_USAGE_REASONING_TOKENS and LLM_REQUEST_REASONING_EFFORT) causing the later
definitions to override the earlier restored semconv constants; rename one set
so the semconv and legacy keys are unique (e.g., prefix restored semconv
constants with SEMCONV_ or suffix legacy_ for the older keys), update the
attribute names in SpanAttributes (references: LLM_USAGE_REASONING_TOKENS,
LLM_REQUEST_REASONING_EFFORT, and any other duplicated LLM_* symbols), and then
update any import sites or usage to reference the new unique names so both
semconv and legacy constants are available.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7a572e8 and 0b3e3f6.

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

Comment on lines +79 to +87
LLM_USAGE_REASONING_TOKENS = "gen_ai.usage.reasoning_tokens"
LLM_USAGE_PROMPT_TOKENS = "gen_ai.usage.prompt_tokens"
LLM_USAGE_CACHE_CREATION_INPUT_TOKENS = "gen_ai.usage.cache_creation_input_tokens"
LLM_USAGE_CACHE_READ_INPUT_TOKENS = "gen_ai.usage.cache_read_input_tokens"
LLM_TOKEN_TYPE = "gen_ai.token.type"
LLM_REQUEST_STRUCTURED_OUTPUT_SCHEMA = "gen_ai.request.structured_output_schema"
LLM_REQUEST_REASONING_EFFORT = "gen_ai.request.reasoning_effort"
LLM_REQUEST_REASONING_SUMMARY = "gen_ai.request.reasoning_summary"
LLM_RESPONSE_REASONING_EFFORT = "gen_ai.response.reasoning_effort"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# First, let's read the file to see its actual structure
wc -l packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/__init__.py

Repository: traceloop/openllmetry

Length of output: 152


🏁 Script executed:

# Read the relevant section around lines 70-110 to verify the duplicate attributes
sed -n '70,110p' packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/__init__.py | cat -n

Repository: traceloop/openllmetry

Length of output: 2437


🏁 Script executed:

# Run the AST verification script from the review to confirm duplicate attribute names
python - <<'PY'
import ast
from pathlib import Path
p = Path("packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/__init__.py")
tree = ast.parse(p.read_text())

for node in tree.body:
    if isinstance(node, ast.ClassDef) and node.name == "SpanAttributes":
        seen = {}
        for stmt in node.body:
            if isinstance(stmt, ast.Assign):
                for t in stmt.targets:
                    if isinstance(t, ast.Name):
                        seen.setdefault(t.id, []).append(stmt.lineno)
        dups = {k: v for k, v in seen.items() if len(v) > 1}
        print("=== Duplicate attributes found ===")
        for name, lines in sorted(dups.items()):
            print(f"{name}: lines {lines}")
        if not dups:
            print("No duplicate attributes found.")
PY

Repository: traceloop/openllmetry

Length of output: 189


Duplicate class attributes are overriding restored semconv constants.

Lines 79 (LLM_USAGE_REASONING_TOKENS) and 85 (LLM_REQUEST_REASONING_EFFORT) are redefined later in the same SpanAttributes class at lines 106 and 105. In Python, the later class assignment wins, so these newly restored gen_ai.* constants are not actually accessible via SpanAttributes.

Proposed fix (make symbol names unique for semconv vs legacy keys)
-    LLM_USAGE_REASONING_TOKENS = "gen_ai.usage.reasoning_tokens"
+    LLM_GEN_AI_USAGE_REASONING_TOKENS = "gen_ai.usage.reasoning_tokens"
-    LLM_REQUEST_REASONING_EFFORT = "gen_ai.request.reasoning_effort"
+    LLM_GEN_AI_REQUEST_REASONING_EFFORT = "gen_ai.request.reasoning_effort"
🤖 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 79 - 87, Two class attributes in SpanAttributes are duplicated
(LLM_USAGE_REASONING_TOKENS and LLM_REQUEST_REASONING_EFFORT) causing the later
definitions to override the earlier restored semconv constants; rename one set
so the semconv and legacy keys are unique (e.g., prefix restored semconv
constants with SEMCONV_ or suffix legacy_ for the older keys), update the
attribute names in SpanAttributes (references: LLM_USAGE_REASONING_TOKENS,
LLM_REQUEST_REASONING_EFFORT, and any other duplicated LLM_* symbols), and then
update any import sites or usage to reference the new unique names so both
semconv and legacy constants are available.

Copy link
Collaborator

@dinmukhamedm dinmukhamedm left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/version.py`:
- Line 1: Update the backport release on the 0.4.x line by adding a 0.4.15
release and changing the package version constant: modify
opentelemetry/semconv_ai/version.py to set __version__ = "0.4.15" (instead of
only bumping to 0.5.0), create a 0.4.15 release branch or tag, and ensure any
packaging/metadata (if present) that reads version.py is consistent so the
compatibility fix is published on the 0.4.x line without touching the 0.5.0
release.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0b3e3f6 and e6a2ae3.

📒 Files selected for processing (3)
  • packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/__init__.py
  • packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/version.py
  • packages/opentelemetry-semantic-conventions-ai/pyproject.toml
✅ Files skipped from review due to trivial changes (1)
  • packages/opentelemetry-semantic-conventions-ai/pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/init.py

@galkleinman galkleinman merged commit bba3090 into main Mar 2, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants