Skip to content

fix(llamaindex): add safety for "None" attributes, and add key fallback - #4430

Open
christabella wants to merge 1 commit into
traceloop:mainfrom
christabella:main
Open

fix(llamaindex): add safety for "None" attributes, and add key fallback#4430
christabella wants to merge 1 commit into
traceloop:mainfrom
christabella:main

Conversation

@christabella

@christabella christabella commented Aug 19, 2026

Copy link
Copy Markdown
  • Replace raw span.set_attribute(...) calls with the existing _set_span_attribute helper that guards against None
  • Read model_dict.get("model") or model_dict.get("model_name") for the request model, since LlamaIndex populates model_name on LLM model dicts

This prevents OTEL collectors e.g. Datadog from emitting warnings when llamaIndex emits an LLM chat event and model_dict keys "model" and "temperature" are absent.

Summary by CodeRabbit

  • Bug Fixes
    • Improved model information captured for LLM chat requests by using the available model value and a fallback when needed.
    • Prevented blank or missing model details from being recorded.
    • Removed request temperature instrumentation.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bcdd61cc-7151-46e4-a632-b74471473907

📥 Commits

Reviewing files that changed from the base of the PR and between 62e24c2 and a22fa37.

📒 Files selected for processing (1)
  • packages/opentelemetry-instrumentation-llamaindex/opentelemetry/instrumentation/llamaindex/span_utils.py

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


📝 Walkthrough

Walkthrough

The LLamaIndex span utility now records the request model from model or model_name. It skips unset or empty model values and no longer records request temperature.

Changes

LLamaIndex instrumentation

Layer / File(s) Summary
Request attribute handling
packages/opentelemetry-instrumentation-llamaindex/.../span_utils.py
Request model attribution uses model with model_name as a fallback. _set_span_attribute suppresses unset and empty values. Request temperature attribution was removed.

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

Merge Risk: ⚪ Minimal · up to a22fa

This localized change safely handles missing attributes and adds a model-name fallback for LlamaIndex telemetry; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: safe handling of None attributes and fallback key support in LlamaIndex instrumentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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