fix(llmobs): fix missing estimated cost on Bedrock LLM spans [MLOB-7008]#17293
Conversation
Codeowners resolved as |
e0d0215 to
928513f
Compare
|
Codex Review: Didn't find any major issues. Keep them coming! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Pass the original model_id through the execution context to LLMObs instead of the split values from parse_model_id(). Set model_provider to "amazon_bedrock" for all Bedrock spans. All Bedrock models tested were impacted - either with no cost data match, or a direct API provider match resulting in incorrect pricing.
928513f to
2c51872
Compare
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🔗 Commit SHA: 75d46d4 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
Yun-Kim
left a comment
There was a problem hiding this comment.
Great change! Just a small comment on the release note but otherwise LGTM 👍
|
/merge |
|
View all feedbacks in Devflow UI.
This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
The expected merge time in
The merge request has been interrupted because the build 106012690 took longer than expected. The current limit for the base branch 'main' is 120 minutes. |
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
005967b
into
main
…08] (#17293) ## Problem Estimated cost is missing or incorrect on Bedrock LLM spans. All Bedrock models tested were impacted - either with no cost data match, or matched direct-API pricing instead of Bedrock pricing. ## Root Cause `parse_model_id()` splits model IDs like `"amazon.nova-lite-v1:0"` into `model_provider="amazon"` and `model_name="nova-lite-v1:0"` for APM span tags. The LLMObs integration passed these split values through to the backend cost estimator, which couldn't match either: - Provider `"amazon"` doesn't match the AWS Bedrock provider (`provider_match: contains "bedrock"`) - Model name `"nova-lite-v1:0"` doesn't match pricing entries (`match: contains "amazon.nova-lite"`) For vendors with their own direct-API provider (anthropic, mistral, deepseek, openai), the split provider name matched the wrong provider, resulting in direct-API pricing instead of Bedrock pricing. ## Fix Pass the original `model_id` through the execution context to LLMObs instead of the split values. Set `model_provider` to `"amazon_bedrock"` for all Bedrock LLM spans. - `model_provider`: `"amazon"` -> `"amazon_bedrock"` (matches backend cost estimator and existing UI icon mapping) - `model_name`: `"nova-lite-v1:0"` -> `"amazon.nova-lite-v1:0"` (matches backend pricing entries) `"amazon_bedrock"` was chosen over `"bedrock"` because the frontend already maps `"amazon_bedrock"` to the `LlmType.AMAZON_BEDROCK` icon ([source](https://github.com/DataDog/web-ui/blob/prod/packages/apps/llm/lib/utils/get-llm-type-from-source.ts)). Using `"bedrock"` would have required a separate frontend change. APM span tags `bedrock.request.model_provider` and `bedrock.request.model` are unchanged. ## Testing Updated assertions in `tests/contrib/botocore/test_bedrock_llmobs.py` (44 passed, 9 skipped - botocore version gating). Tested 29 Bedrock models across 7 vendors (amazon, anthropic, meta, mistral, deepseek, openai, qwen) with AWS Bedrock calls. Fix validated locally - confirmed correct cost estimation and UI icon rendering in LLMObs traces explorer. Codex automated review completed on final commit - no blocking issues found. **Before change:** <img width="1057" height="598" alt="image" src="https://github.com/user-attachments/assets/8dfc3403-bc78-4f8f-b08b-028c8253dba0" /> <img width="1114" height="621" alt="image" src="https://github.com/user-attachments/assets/3893f580-51c6-4849-b091-24f428d81552" /> **After change:** <img width="1058" height="614" alt="image" src="https://github.com/user-attachments/assets/a37c65e8-47f1-41a1-8348-077313adfefa" /> <img width="1116" height="671" alt="image" src="https://github.com/user-attachments/assets/061f75e6-d01a-4b1b-a42f-076bccfee083" /> ## Risks - Changes `meta.model_provider` and `meta.model_name` on LLMObs span events. Customers filtering by `@meta.model_provider:anthropic` for Bedrock models would need to update to `@meta.model_provider:amazon_bedrock`. However, those customers were getting incorrect pricing, so the filter was already misleading. - Internal telemetry `model_provider` tag changes from vendor names to `amazon_bedrock` for Bedrock spans, but again before it was not being marked as Bedrock at all. - ARN-format model IDs (e.g., `arn:aws:bedrock:us-west-2:...:inference-profile/...`) will see the full ARN string as `model_name` in the LLMObs UI. Cost matching still works for system inference profiles (the model name is embedded in the ARN and matched via `contains` clauses). Release note included. Co-authored-by: Yun-Kim <35776586+Yun-Kim@users.noreply.github.com> Co-authored-by: yun.kim <yun.kim@datadoghq.com>
Pass the full modelId and "amazon_bedrock" as model_provider to LLMObs instead of the split values from parseModelId(). The split values prevented the backend cost estimator from matching Bedrock pricing entries. Mirrors the Python tracer fix in DataDog/dd-trace-py#17293.
Pass the full modelId and "amazon_bedrock" as model_provider to LLMObs instead of the split values from parseModelId(). The split values prevented the backend cost estimator from matching Bedrock pricing entries. Mirrors the Python tracer fix in DataDog/dd-trace-py#17293.
Pass the full modelId and "amazon_bedrock" as model_provider to LLMObs instead of the split values from parseModelId(). The split values prevented the backend cost estimator from matching Bedrock pricing entries. Mirrors the Python tracer fix in DataDog/dd-trace-py#17293.
Pass the full modelId and "amazon_bedrock" as model_provider to LLMObs instead of the split values from parseModelId(). The split values prevented the backend cost estimator from matching Bedrock pricing entries. Mirrors the Python tracer fix in DataDog/dd-trace-py#17293.
Problem
Estimated cost is missing or incorrect on Bedrock LLM spans. All Bedrock models tested were impacted - either with no cost data match, or matched direct-API pricing instead of Bedrock pricing.
Root Cause
parse_model_id()splits model IDs like"amazon.nova-lite-v1:0"intomodel_provider="amazon"andmodel_name="nova-lite-v1:0"for APM span tags. The LLMObs integration passed these split values through to the backend cost estimator, which couldn't match either:"amazon"doesn't match the AWS Bedrock provider (provider_match: contains "bedrock")"nova-lite-v1:0"doesn't match pricing entries (match: contains "amazon.nova-lite")For vendors with their own direct-API provider (anthropic, mistral, deepseek, openai), the split provider name matched the wrong provider, resulting in direct-API pricing instead of Bedrock pricing.
Fix
Pass the original
model_idthrough the execution context to LLMObs instead of the split values. Setmodel_providerto"amazon_bedrock"for all Bedrock LLM spans.model_provider:"amazon"->"amazon_bedrock"(matches backend cost estimator and existing UI icon mapping)model_name:"nova-lite-v1:0"->"amazon.nova-lite-v1:0"(matches backend pricing entries)"amazon_bedrock"was chosen over"bedrock"because the frontend already maps"amazon_bedrock"to theLlmType.AMAZON_BEDROCKicon (source). Using"bedrock"would have required a separate frontend change.APM span tags
bedrock.request.model_providerandbedrock.request.modelare unchanged.Testing
Updated assertions in
tests/contrib/botocore/test_bedrock_llmobs.py(44 passed, 9 skipped - botocore version gating).Tested 29 Bedrock models across 7 vendors (amazon, anthropic, meta, mistral, deepseek, openai, qwen) with AWS Bedrock calls. Fix validated locally - confirmed correct cost estimation and UI icon rendering in LLMObs traces explorer.
Codex automated review completed on final commit - no blocking issues found.
Before change:

After change:

Risks
meta.model_providerandmeta.model_nameon LLMObs span events. Customers filtering by@meta.model_provider:anthropicfor Bedrock models would need to update to@meta.model_provider:amazon_bedrock. However, those customers were getting incorrect pricing, so the filter was already misleading.model_providertag changes from vendor names toamazon_bedrockfor Bedrock spans, but again before it was not being marked as Bedrock at all.arn:aws:bedrock:us-west-2:...:inference-profile/...) will see the full ARN string asmodel_namein the LLMObs UI.Cost matching still works for system inference profiles (the model name is embedded in the ARN and matched via
containsclauses).Release note included.