Skip to content

Deprecate bedrock instrumentation - #5266

Open
DylanRussell wants to merge 10 commits into
open-telemetry:mainfrom
DylanRussell:deprecate_bedrock
Open

DylanRussell wants to merge 10 commits into
open-telemetry:mainfrom
DylanRussell:deprecate_bedrock

Conversation

@DylanRussell

Copy link
Copy Markdown
Contributor

Description

Deprecate the Amazon Bedrock extension in opentelemetry-instrumentation-botocore in favor of opentelemetry-instrumentation-genai-bedrock.

Key changes:

  • Emit a DeprecationWarning when _BedrockRuntimeExtension is initialized.
  • Check if opentelemetry-instrumentation-genai-bedrock is installed and active; if so, suppress the extension's handled operations in __init__ so botocore only emits standard AWS SDK RPC spans, avoiding duplicate GenAI spans, events, and metrics.
  • Update README.rst with deprecation notice pointing users to the new package.
  • Add unit tests for deprecation warning, active instrumentor detection, and end-to-end suppression.
  • Add changelog entry.
    Fixes Deprecate bedrock instrumentation package once new instrumentation in opentelemetry-python-genai is ready #4999

Type of change

  • This change requires a documentation update

Checklist:

  • I am a human and not a bot
  • I have run tox -e precommit
  • I have run tox -e typecheck
  • I have run the relevant tests and linting tox environments

@DylanRussell
DylanRussell requested a review from a team as a code owner October 29, 2026 19:24
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-11-11 16:42 UTC

Two things need attention:

  • Required checks are failing — investigate the failures.
  • 1 review item — respond to each (e.g. link a commit, explain why not, ask a follow-up):
    • Top-level threads: 1
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.
  • Should this be with reviewers? Comment /dashboard route:reviewers to route it to them.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

@github-project-automation github-project-automation Bot moved this to Approved PRs in Python PR digest Nov 5, 2026
@xrmx

xrmx commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

@DylanRussell I've asked codex to review the difference and spotted the following (2. was about cohere R models but these are gone):

Case Difference from contrib
Nova InvokeModelWithResponseStream No handling for Nova’s messageStart, contentBlockDelta, messageStop, and metadata envelopes. Output messages, finish reason, and usage are lost for that stream format.
Nova InvokeModel settings Nested inferenceConfig.topP and inferenceConfig.stopSequences are missed.
Mistral InvokeModel settings Request stop is missed.

1. Nova streaming: most response telemetry disappears

This affects InvokeModelWithResponseStream with Nova models. Nova sends JSON payloads inside chunk.bytes, shaped like:

{"messageStart": {"role": "assistant"}}
{"contentBlockDelta": {"contentBlockIndex": 0, "delta": {"text": "Hello"}}}
{"messageStop": {"stopReason": "end_turn"}}
{"metadata": {"usage": {"inputTokens": 10, "outputTokens": 1}}}

Contrib explicitly handles these envelopes and accumulates text, tool calls, finish reason, and usage.

The standalone InvokeModel stream parser (/home/rm/src/opentelemetry-python-genai/instrumentation/opentelemetry-instrumentation-genai-bedrock/src/opentelemetry/instrumentation/genai/bedrock/stream.py:297) decodes the JSON, but its branches recognize Anthropic events and several legacy response formats. None recognize Nova’s envelopes.

For the example above:

Telemetry Contrib Standalone
Captured response text Hello Missing
Finish reason end_turn Missing
Input/output tokens 10 / 1 Missing
Token usage histogram Records usage No token measurements
Duration and chunk timing Duration Duration and chunk timing still recorded

Tool calls in Nova streams are also missed. The span can finish successfully despite having no response details, so ordinary error monitoring would not reveal the loss.

This gap is specific to Nova through InvokeModel streaming. Standalone’s separate ConverseStream parser handles these event shapes. Its InvokeModel streaming tests cover Anthropic, Titan, and some legacy formats, but contain no Nova case.

The fix would require handling Nova envelopes in this parser, potentially sharing the existing Converse stream accumulation logic, with text, tool-call, usage, and capture-disabled tests.

3. Nova request settings: nested top-p and stop sequences disappear

For an InvokeModel request containing:

{
  "inferenceConfig": {
    "temperature": 0.7,
    "topP": 0.9,
    "stopSequences": ["END"]
  }
}

Contrib extracts all three settings. Standalone’s request extractor (/home/rm/src/opentelemetry-python-genai/instrumentation/opentelemetry-instrumentation-genai-bedrock/src/opentelemetry/instrumentation/genai/bedrock/extractors.py:469):

  • Reads nested temperature correctly.
  • Looks for nested top_p, but misses nested topP.
  • Never checks nested stopSequences.

The resulting telemetry omits:

gen_ai.request.top_p
gen_ai.request.stop_sequences

This affects both streaming and non-streaming InvokeModel paths because they share the request extractor. Converse and ConverseStream use a different extractor and capture these settings.

The correction is small: add the missing nested aliases while preserving valid zero values and existing precedence.

4. Mistral request settings: stop disappears

Mistral’s InvokeModel request can contain:

{
  "prompt": "...",
  "max_tokens": 100,
  "stop": ["END"]
}

Contrib explicitly maps stop to gen_ai.request.stop_sequences. Standalone checks stop_sequences, stopSequences, and Titan’s nested configuration, but misses stop.

Other recognized settings and the response remain available; the missing output is the stop-sequences attribute. This also affects both InvokeModel variants. The existing Mistral request test does not include stop, so it cannot detect this omission.

Opened open-telemetry/opentelemetry-python-genai#1077 and open-telemetry/opentelemetry-python-genai#1076 for 3. and 4. 1. seems to be handled by open-telemetry/opentelemetry-python-genai#1016

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Approved PRs

Development

Successfully merging this pull request may close these issues.

Deprecate bedrock instrumentation package once new instrumentation in opentelemetry-python-genai is ready

3 participants