Skip to content

[opentelemetry-instrumentation-genai-langchain] Capture top_k and choice count on chat - #684

Draft
rads-1996 wants to merge 2 commits into
open-telemetry:mainfrom
rads-1996:add-top_k-choice_count-langchain
Draft

[opentelemetry-instrumentation-genai-langchain] Capture top_k and choice count on chat#684
rads-1996 wants to merge 2 commits into
open-telemetry:mainfrom
rads-1996:add-top_k-choice_count-langchain

Conversation

@rads-1996

@rads-1996 rads-1996 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #581

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested?

Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. List any relevant details for your test
configuration.

  • Test A

Checklist

See CONTRIBUTING.md
for the style guide, changelog guidance, and more.

  • Followed the style guidelines of this project
  • Changelog updated if the change requires an entry
  • Unit tests added
  • Documentation updated

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 11, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-09-11 21:40 UTC

Move out of draft to request review.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@rads-1996
rads-1996 marked this pull request as ready for review September 11, 2026 21:25
@rads-1996
rads-1996 requested a review from a team as a code owner September 11, 2026 21:25
Copilot AI lite review requested due to automatic review settings September 11, 2026 21:25

Copilot AI 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.

🟡 Changes recommended

One or more issues must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds LangChain chat extraction for top_k and requested choice count.

Changes:

  • Captures top_k and n from invocation parameters.
  • Adds unit tests for populated and missing values.
  • Adds a changelog fragment.
File summaries
File Description
instrumentation/opentelemetry-instrumentation-genai-langchain/tests/test_callback_handler.py Updated as part of this pull request.
instrumentation/opentelemetry-instrumentation-genai-langchain/src/opentelemetry/instrumentation/genai/langchain/callback_handler.py Updated as part of this pull request.
instrumentation/opentelemetry-instrumentation-genai-langchain/.changelog/684.added Updated as part of this pull request.
Review details

Suppressed comments (1)

instrumentation/opentelemetry-instrumentation-genai-langchain/src/opentelemetry/instrumentation/genai/langchain/callback_handler.py:305

  • Please keep this consistent with the existing choice-count behavior: older ChatOpenAI requests can include the SDK default n=1, but this assignment reports it unconditionally. The OpenAI instrumentation intentionally omits gen_ai.request.choice.count for n=1 (openai/utils.py:137-140, test_chat_completions.py:461-485), so assign only a non-default integer count here and add a regression test for the default.
            request_choice_count = params.get("n")
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@rads-1996
rads-1996 marked this pull request as draft September 11, 2026 21:36
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.

[langchain] Capture top_k and choice count on chat

2 participants