Skip to content

Default OpenAI and Anthropic instrumentation to new version=2 - #2363

Merged
alexmojaki merged 7 commits into
mainfrom
codex/add-semconv-version-2
Sep 4, 2026
Merged

Default OpenAI and Anthropic instrumentation to new version=2#2363
alexmojaki merged 7 commits into
mainfrom
codex/add-semconv-version-2

Conversation

@alexmojaki

Copy link
Copy Markdown
Contributor

Summary

  • add numeric semantic-convention version 2 for OpenAI and Anthropic instrumentation
  • freeze the current latest telemetry behavior as version 2 and normalize latest to it internally
  • make version 2 the public and provider-internal default while retaining version 1 and dual emission
  • document the migration path and update the logfire-api generated signature surface

Tests

  • uv run pytest tests/otel_integrations/test_openai.py tests/otel_integrations/test_anthropic.py
  • uv run pytest tests/test_docs.py::test_formatting
  • repository-wide Ruff, Ruff format, and Pyright checks via pre-commit

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: bfa95f53-2eb0-4aa3-855a-14163cc363e3

📥 Commits

Reviewing files that changed from the base of the PR and between f795ab1 and e5785da.

📒 Files selected for processing (9)
  • docs/integrations/llms/anthropic.md
  • docs/integrations/llms/openai.md
  • logfire-api/logfire_api/_internal/main.pyi
  • logfire/_internal/integrations/llm_providers/anthropic.py
  • logfire/_internal/integrations/llm_providers/openai.py
  • logfire/_internal/integrations/llm_providers/semconv.py
  • logfire/_internal/main.py
  • tests/otel_integrations/test_anthropic.py
  • tests/otel_integrations/test_openai.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • pydantic/logfire (manual)
  • pydantic/pydantic-ai (manual)

Included review availability: Your plan provides up to 8 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

OpenAI and Anthropic instrumentation now default to semantic convention version 2. Version latest normalizes to version 2. Version 1 remains available, including dual emission with version 2. Endpoint, streaming, and response attributes use normalized version selection. Public signatures and documentation reflect the new default. Tests cover defaults, endpoint attributes, streaming output, absent inputs, normalization, and agent-span suppression.

Merge Risk: ⚪ Minimal · up to e5785

OpenAI and Anthropic instrumentation now defaults to semantic-convention version 2 while retaining version 1 and dual emission. No material current-head merge-readiness risk remains.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the primary change: making semantic-convention version 2 the default for OpenAI and Anthropic instrumentation.
Description check ✅ Passed The description accurately summarizes version 2 support, latest-version normalization, retained compatibility, documentation updates, and test coverage.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/add-semconv-version-2

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

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 9 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

Comment thread docs/integrations/llms/anthropic.md Outdated
Comment on lines +105 to +108
```python skip-run="true" skip-reason="migration configuration example"
import logfire

logfire.instrument_anthropic(version=[1, 2])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
```python skip-run="true" skip-reason="migration configuration example"
import logfire
logfire.instrument_anthropic(version=[1, 2])
```python
import logfire
logfire.configure()
logfire.instrument_anthropic(version=[1, 2])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

(AI) Addressed in a6db4fb

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

same for openai

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

(AI) Addressed in 586dda5

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

why are you still skipping running

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

(AI) Addressed in e3f9c24

Comment thread docs/integrations/llms/anthropic.md Outdated

### Keep legacy attributes during migration

Logfire uses instrumentation version 2 by default. If your queries or dashboards still depend

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

revert to the previous naming to match the types

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

(AI) Addressed in 1c4e2cb

@alexmojaki alexmojaki changed the title Add stable GenAI semantic convention version 2 Default OpenAI and Anthropic instrumentation to new version=2 Sep 4, 2026
@alexmojaki
alexmojaki added this pull request to the merge queue Sep 4, 2026
Merged via the queue into main with commit ef6be7c Sep 4, 2026
22 checks passed
@alexmojaki
alexmojaki deleted the codex/add-semconv-version-2 branch September 4, 2026 11:50
lohun added a commit to lohun/logfire that referenced this pull request Sep 4, 2026
Default OpenAI and Anthropic instrumentation to new `version=2` (pydantic#2363)
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