🐛 Bug Report: Incomplete cache token migration after #4243 breaks Bedrock and Groq instrumentation

Aperta Adatta ai principianti
#4,665 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Quantum-Enigma-dot ci sta già lavorando.

Dal 29/10/2026.

  • #4667 di @Quantum-Enigma-dot — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

Inizia dai file span_utils.py di Bedrock e Groq indicati nell’issue, poi cerca nel repository le due costanti dei token di cache rimosse e controlla le definizioni attuali di GenAIAttributes. Esegui il test di prompt caching e i test span-utils di Groq elencati nel report. Il lavoro è concluso quando l’utilizzo della cache viene registrato correttamente e i riferimenti rimanenti in fase di esecuzione e nei test non generano più errori rispetto alla fonte semantic conventions del workspace.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Which component is this bug for?

Bedrock Instrumentation

📜 Description

The semantic-convention migration in #4243 removed the following attributes from SpanAttributes:

  • SpanAttributes.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS
  • SpanAttributes.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS

However, the Bedrock and Groq instrumentations still reference these attributes in runtime code.

When a response contains prompt-cache usage data, accessing the removed attributes raises AttributeError. Several tests in Bedrock, Groq, Google Generative AI, and Mistral AI also continue to reference the removed attributes.

This appears to be an incomplete migration from SpanAttributes to GenAIAttributes.

👟 Reproduction steps
  1. Clone the repository and enter the Bedrock instrumentation package:
cd packages/opentelemetry-instrumentation-bedrock

2.Run the prompt-caching test using the workspace version of opentelemetry-semantic-conventions-ai:
uv run --group test python -c "import sys; sys.path.insert(0, '../opentelemetry-semantic-conventions-ai'); import pytest; sys.exit(pytest.main(['tests/traces/test_prompt_caching.py']))"

3.Alternatively, verify directly that the attributes are absent:
```python
from opentelemetry.semconv_ai import SpanAttributes

print(
    hasattr(
        SpanAttributes,
        "GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS",
    )
)
# False

print(
    hasattr(
        SpanAttributes,
        "GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS",
    )
)
# False

4.Bedrock still accesses the missing attributes inside converse_usage_record():

SpanAttributes.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS
SpanAttributes.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS

5.When cache usage is present, Python raises an AttributeError.

👍 Expected behavior
Bedrock and Groq should record prompt-cache token usage without raising an exception. All remaining references should use the current `GenAIAttributes` constants, or compatible aliases should remain available on `SpanAttributes` during the migration.

### 👎 Actual Behavior with Screenshots

When a cache-token code path accesses the removed constant, Python raises:

```text
AttributeError: type object 'SpanAttributes' has no attribute 'GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS'
The Bedrock prompt-caching test also fails when run against the current workspace version of opentelemetry-semantic-conventions-ai:
```text
FAILED tests/traces/test_prompt_caching.py::test_invoke_model_cache_tokens

The Groq span-utils suite produces six failures involving the same missing cache-read attribute.

🤖 Python Version

3.13.7

📃 Provide any additional context for the Bug.

I traced the regression to #4243.

That migration moved the cache-token constants to GenAIAttributes and removed them from SpanAttributes. Several packages were migrated, but remaining runtime references in Bedrock and Groq were not updated.

The issue can be masked when package-specific environments resolve the previously published opentelemetry-semantic-conventions-ai==0.5.1, where the attributes are still available. Running the tests against the current workspace semantic-conventions source exposes the regression.

Relevant runtime locations include:

  • packages/opentelemetry-instrumentation-bedrock/opentelemetry/instrumentation/bedrock/span_utils.py
  • packages/opentelemetry-instrumentation-groq/opentelemetry/instrumentation/groq/span_utils.py

A possible fix is to migrate the remaining runtime and test references to GenAIAttributes. Alternatively, compatibility aliases could be restored on SpanAttributes if backward compatibility is intended.

I searched the repository history and existing reports but did not find a later fix for these remaining references. I am willing to submit a PR.

👀 Have you spent some time to check if this bug has been raised before?
  • I checked and didn't find similar issue
Are you willing to submit PR?

Yes I am willing to submit a PR!

Lingua principale
Python
Stelle
7.5k
Fork
1.2k
Merge medio
2g 6h
PR unite (30g)
2

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di traceloop/openllmetry

Tutte le issue di traceloop/openllmetry

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.