Skip to content

fix(cohere): record penalties under gen_ai.request.* attributes - #4615

Open
reyhaan07 wants to merge 2 commits into
traceloop:mainfrom
reyhaan07:fix/cohere-penalty-attributes
Open

reyhaan07 wants to merge 2 commits into
traceloop:mainfrom
reyhaan07:fix/cohere-penalty-attributes

Conversation

@reyhaan07

@reyhaan07 reyhaan07 commented Oct 12, 2026 •

Copy link
Copy Markdown

The Cohere instrumentation still wrote frequency_penalty and presence_penalty with the legacy SpanAttributes aliases, which emit llm.frequency_penalty / llm.presence_penalty instead of the OTel GenAI names. Use the GenAIAttributes constants, as the Groq, OpenAI and Anthropic packages already do, and drop the resolved TODO.

  • [ x] 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.

Summary by CodeRabbit

  • Bug Fixes
    • Cohere chat spans now record frequency and presence penalties using GenAI request attributes.

The Cohere instrumentation still wrote frequency_penalty and
presence_penalty with the legacy SpanAttributes aliases, which emit
llm.frequency_penalty / llm.presence_penalty instead of the OTel GenAI
names. Use the GenAIAttributes constants, as the Groq, OpenAI and
Anthropic packages already do, and drop the resolved TODO.
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 354d1df4-187f-4509-bfba-640a21748b57
📥 Commits

Reviewing files that changed from the base of the PR and between eaf23ce and 3c61930.

📒 Files selected for processing (2)
  • packages/opentelemetry-instrumentation-cohere/opentelemetry/instrumentation/cohere/span_utils.py
  • packages/opentelemetry-instrumentation-cohere/tests/test_chat.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

The Cohere instrumentation now records frequency and presence penalties with GenAI request attributes. Synchronous and asynchronous chat tests verify the recorded values.

Changes: Cohere request penalties

Layer / File(s) Summary
Record and test penalty attributes
packages/opentelemetry-instrumentation-cohere/opentelemetry/instrumentation/cohere/span_utils.py, packages/opentelemetry-instrumentation-cohere/tests/test_chat.py
The span utility records frequency and presence penalties with GenAI request attributes. Synchronous and asynchronous tests check values of 0.1 and 0.2.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 3c619

The Cohere instrumentation records both penalties under the intended GenAI request attributes in synchronous and asynchronous chat paths; no material merge risk remains.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to 3c619

The change renames two existing telemetry fields without expanding access, collecting additional request data, or changing production request handling. No introduced or worsened security concern was identified. Consumers of the legacy field names may need to update their queries.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The introduced production effect is confined to the names of two already-recorded Cohere request attributes. The complete PR diff shows no additional collection, new production caller, export destination, credential authority, or deployment change that would expand attacker-controlled reachability.

Trust Boundaries and Controls

  • observed — The penalty values continue to originate from the same request keyword arguments and pass through the same span-attribute setter. The changed block alters neither value handling nor a trust or identity transition.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed 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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: recording Cohere penalty attributes under gen_ai.request.* attributes.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@CLAassistant

CLAassistant commented Oct 12, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

2 participants