Skip to content

Add version parameter to LLM instrumentation#1702

Merged
dmontagu merged 3 commits intojulian/semconvs-messagefrom
dm/semconv-version-param-v2
Feb 11, 2026
Merged

Add version parameter to LLM instrumentation#1702
dmontagu merged 3 commits intojulian/semconvs-messagefrom
dm/semconv-version-param-v2

Conversation

@dmontagu
Copy link
Copy Markdown
Contributor

Summary

  • Adds a version parameter to instrument_openai() and instrument_anthropic() that accepts 1, 2, or [1, 2]
  • version=1 (default): legacy request_data/response_data format
  • version=2: structured OTel Gen AI semconv messages (gen_ai.input.messages, gen_ai.output.messages, gen_ai.system_instructions)
  • version=[1, 2]: both formats simultaneously for migration/testing

Stacked on

Test plan

  • Existing OpenAI and Anthropic tests pass with default version=1
  • New tests for version=2 verify only semconv attributes emitted
  • New tests for version=[1, 2] verify both formats emitted
  • logfire-api stub updated and passing

Adds a `version` parameter that accepts `1`, `2`, or `[1, 2]`:
- version=1 (default): legacy request_data/response_data format
- version=2: structured OTel Gen AI semconv messages (gen_ai.input.messages, gen_ai.output.messages, gen_ai.system_instructions)
- version=[1, 2]: both formats simultaneously for migration/testing

Built on top of PR #1666 (julian/semconvs-message).
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Feb 10, 2026

Deploying logfire-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 21fff4e
Status: ✅  Deploy successful!
Preview URL: https://cce1bd7d.logfire-docs.pages.dev
Branch Preview URL: https://dm-semconv-version-param-v2.logfire-docs.pages.dev

View logs

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

Devin Review found 3 potential issues.

View 6 additional findings in Devin Review.

Open in Devin Review

@dmontagu dmontagu changed the base branch from main to julian/semconvs-message February 10, 2026 23:50
Remove v2 semconv attributes (gen_ai.input.messages, gen_ai.system_instructions,
gen_ai.output.messages) from the bedrock test snapshot since the default version=1
no longer emits them.
OpenaiChatCompletionStreamState and AnthropicMessageStreamState now emit
gen_ai.output.messages when version=2 is active, matching the non-streaming
behavior.
Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

Devin Review found 2 new potential issues.

View 9 additional findings in Devin Review.

Open in Devin Review

@dmontagu dmontagu merged commit 7e5d733 into julian/semconvs-message Feb 11, 2026
25 of 27 checks passed
@dmontagu dmontagu deleted the dm/semconv-version-param-v2 branch February 11, 2026 00:28
dmontagu added a commit to brightsparc/logfire that referenced this pull request Feb 11, 2026
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