open-telemetry / open-telemetry/opentelemetry-python-genai
Cohere V2 instrumentation: continue `scaffold + chat completions` from my previous work `opentelemetry-python-contrib#4418`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 39
- Forks
- 63
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 175
Description
Background
Continuation of Cohere instrumentation work that started in open-telemetry/opentelemetry-python-contrib:
- contrib #4418 (scaffolding) - closed unmerged on 2026-05-13, "moving to new repo"
- contrib #4421 (streaming) - closed unmerged on 2026-05-13, same reason
- Original tracking issue: contrib #3050
@lmolkova closure message: "We are moving GenAI instrumentations to the new repository... I am closing this PR here, but you are welcome to reopen it in the new repo."
Filing this issue to lay out the staged-PR roadmap and open questions before opening any PR.
Note on numbering:
PR 1/PR 2/PR 3/PR 4below are the planned PRs against this repo for this work. They are written without#so GitHub does not auto-link them to unrelated existing items in this repo.
Roadmap
| Step | Title | Status | Depends on | Origin |
|---|---|---|---|---|
| PR 1 | Scaffold only --> Now PR #102 | Ready to merge | - | port of contrib #4418 |
| PR 2 | Chat completions (sync + async) | Not started | PR 1 | new (was deferred in contrib per reviewer guidance) |
| PR 3 | Streaming (chat_stream sync + async) |
Code ported, not adapted | PR 2, #13 |
port of contrib #4421 |
| PR 4 | RAG / citations attribute extraction | Blocked on semconv proposal | PR 2, semconv-genai issue (separate) | new |
Each PR lands before the next is opened. Single logical change per PR, per AGENTS.md.
PR 1: Scaffold only (direct port of contrib #4418) --> Now PR #102
What's here:
- Package directory
instrumentation/opentelemetry-instrumentation-genai-cohere/mirroring theopentelemetry-instrumentation-genai-anthropiclayout CohereInstrumentor(BaseInstrumentor)with empty_instrument/_uninstrument+ TODO comment;patch.pyis a placeholderpyproject.toml(cohere >= 5.13.0instruments extra, Python 3.10-3.14, entry point underopentelemetry_instrumentor)- Workspace registration in root
pyproject.toml,tox.ini,uv.lock tests/with smoke tests only (instantiation, dependency reporting, instrument/uninstrument lifecycle)examples/{manual,zero-code}/placeholders with scaffold disclaimer- Towncrier fragment
Not in this PR: any wrap_function_wrapper calls, semconv emission, real example traces.
Fixes part of this issue (scaffolding only).
PR 2: Chat completions (sync + async)
What's planned:
- Wrap
cohere.client_v2.ClientV2.chatandcohere.client_v2.AsyncClientV2.chatviawrap_function_wrapper - Spans + metrics through
opentelemetry.util.genai.handler.TelemetryHandlerandInferenceInvocation(same handler the existing provider packages use) - All attributes sourced from
opentelemetry.semconv._incubating.attributes.gen_ai_attributes(no hardcoded names): request model, max output tokens, temperature, top_p, top_k, stop sequences, frequency / presence penalty, seed, response id, response model, finish reasons, input/output tokens, operation name, provider name - Content capture via
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT(default off; span-only and event-only modes) - Error path: re-raise unmodified, span carries
error.type+ exception event
Tests: VCR happy-path sync + async, error-path, multi-turn message history, exact semconv attribute-name assertions.
Not in this PR: streaming, RAG/citations, V1 client, embed/classify/rerank/tokenize.
Depends on PR 1.
PR 3: Streaming (port of contrib #4421)
What's planned:
- Wrap
chat_stream(sync + async) with SSE iterator + per-chunk timing viaopentelemetry.util.genai.stream - VCR streaming happy-path sync + async, chunk-count + finish-reason assertions
Depends on PR 2 landing, and on #13 (the streaming helpers PR 3 builds on).
PR 4: RAG / citations attribute extraction
What's planned:
- Extract
documentsandcitationsfrom Cohere V2 chat responses intogen_ai.rag.documents.*andgen_ai.response.citations.*
Blocked on a separate semconv proposal landing in open-telemetry/semantic-conventions-genai for those attribute namespaces (no such namespace exists today). I will file that proposal separately so the convention is portable across providers.
Additional Context
Compatibility matrix
| Axis | Pin |
|---|---|
cohere |
>= 5.13.0 (V2 GA) |
| Python | 3.10, 3.11, 3.12, 3.13, 3.14 |
opentelemetry-api, -sdk, -instrumentation, -semantic-conventions |
match other instrumentations in this repo |
opentelemetry-util-genai |
>= 1.0b0.dev (matches anthropic, claude-agent-sdk, etc.) |
Open questions
- Is V2-only acceptable as the initial scope, consistent with how
openai-v2(nowgenai-openai) is structured? - Anything in the migration from
opentelemetry-python-contribI should be aware of beyond the directory move and thegenai-prefix rename?
Plan
Scaffold is ready locally as a direct port of contrib #4418 (adapted to the current genai- prefix and module-path conventions). Unless concerns surface, I will open PR 1 in the next few days. PR 2 -> PR 4 follow sequentially.
cc @lmolkova, @lzchen, @JWinermaSplunk, @eternalcuriouslearner
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing PR #102, AGENTS.md, and the scaffold at instrumentation/opentelemetry-instrumentation-genai-cohere/. Then inspect the existing provider packages and the planned ClientV2.chat and AsyncClientV2.chat entry points. Done means the staged chat-completion scope is implemented with the listed VCR, error-path, history, and semantic-convention tests passing; streaming and RAG remain separate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100