Skip to content

feat: Add streaming support to Cohere instrumentation#4421

Draft
Nik-Reddy wants to merge 2 commits intoopen-telemetry:mainfrom
Nik-Reddy:feat/cohere-streaming-3050
Draft

feat: Add streaming support to Cohere instrumentation#4421
Nik-Reddy wants to merge 2 commits intoopen-telemetry:mainfrom
Nik-Reddy:feat/cohere-streaming-3050

Conversation

@Nik-Reddy
Copy link
Copy Markdown

Description

Adds streaming support to the Cohere instrumentation introduced in #4418. This PR wraps V2Client.chat_stream and AsyncV2Client.chat_stream with CohereStreamWrapper / AsyncCohereStreamWrapper.

Split from #4418 per reviewer feedback from @JWinermaSplunk.

Depends on #4418 (chat completions base).

Ref #3050

Changes

  • patch.py: Added CohereStreamWrapper and AsyncCohereStreamWrapper for streaming chat responses
  • __init__.py: Added chat_stream wrapping for both V2Client and AsyncV2Client
  • Tests: Added streaming test cases for sync and async chat_stream

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

All 23 tests pass (21 from base chat + 2 streaming tests).

cd instrumentation-genai/opentelemetry-instrumentation-cohere
pytest tests/ -v

Does This PR Require a Core Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added

@Nik-Reddy
Copy link
Copy Markdown
Author

Hi, this is the streaming companion to #4418 (Cohere chat completions), split per reviewer request. It adds SSE-based streaming support with token-level metric collection. Would appreciate a review when #4418 has been looked at. Thanks!

Implements initial Cohere instrumentation following the GenAI semantic
conventions. Supports sync and async chat completions with token usage,
content capture, and error handling.

Streaming support will follow in a separate PR.

Ref open-telemetry#3050
Extends the Cohere instrumentation with streaming chat support.
Adds CohereStreamWrapper and AsyncCohereStreamWrapper for
chat_stream operations.

Ref open-telemetry#3050
@Nik-Reddy Nik-Reddy force-pushed the feat/cohere-streaming-3050 branch from 1ceb6f4 to 8f9740c Compare April 15, 2026 01:08
@Nik-Reddy
Copy link
Copy Markdown
Author

Hi @lzchen (issue #3050 assignee), @lmolkova, @MikeGoldsmith - this PR adds streaming support (chat_stream) to the Cohere instrumentation, building on top of #4418 (chat completions). Split per @JWinermaSplunk's review feedback. Would appreciate a review when you have bandwidth. Thanks!

@MikeGoldsmith
Copy link
Copy Markdown
Member

As this depends on #4418 - let's move this PR into draft until that one is accepted and merged so you don't have to rework this PR with any subsequent changes.

@MikeGoldsmith MikeGoldsmith added instrumentation gen-ai Related to generative AI labels Apr 15, 2026
@Nik-Reddy Nik-Reddy marked this pull request as draft April 15, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gen-ai Related to generative AI instrumentation

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants