Skip to content

Add llm cost_tags field to share tests#6829

Merged
XG-xin merged 8 commits intomainfrom
xinyuan/llm-cost-tags
May 4, 2026
Merged

Add llm cost_tags field to share tests#6829
XG-xin merged 8 commits intomainfrom
xinyuan/llm-cost-tags

Conversation

@XG-xin
Copy link
Copy Markdown
Contributor

@XG-xin XG-xin commented Apr 29, 2026

Motivation

Add system tests for parameter cost_tags.

  • dd-trace-py: PR is merged, likely included in v4.9
  • dd-trace-js: PR is open, need to merge this first to pass the tests.

Changes

Workflow

  1. ⚠️ Create your PR as draft ⚠️
  2. Work on you PR until the CI passes
  3. Mark it as ready for review
    • Test logic is modified? -> Get a review from RFC owner.
    • Framework is modified, or non obvious usage of it -> get a review from R&P team

🚀 Once your PR is reviewed and the CI green, you can merge it!

🛟 #apm-shared-testing 🛟

Reviewer checklist

  • Anything but tests/ or manifests/ is modified ? I have the approval from R&P team
  • A docker base image is modified?
    • the relevant build-XXX-image label is present
  • A scenario is added, removed or renamed?

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 29, 2026

CODEOWNERS have been resolved as:

manifests/java.yml                                                      @DataDog/asm-java @DataDog/apm-java
manifests/nodejs.yml                                                    @DataDog/dd-trace-js
manifests/python.yml                                                    @DataDog/apm-python @DataDog/asm-python
tests/parametric/test_llm_observability/test_llm_observability.py       @DataDog/ml-observability @DataDog/system-tests-core
utils/_features.py                                                      @DataDog/system-tests-core
utils/build/docker/java/parametric/src/main/java/com/datadoghq/trace/controller/LlmObsController.java  @DataDog/apm-java @DataDog/asm-java @DataDog/system-tests-core
utils/build/docker/nodejs/parametric/llmobs.js                          @DataDog/dd-trace-js @DataDog/system-tests-core
utils/build/docker/python/parametric/apm_test_client/llmobs.py          @DataDog/apm-python @DataDog/asm-python @DataDog/system-tests-core
utils/docker_fixtures/spec/llm_observability.py                         @DataDog/ml-observability @DataDog/system-tests-core

@datadog-prod-us1-3
Copy link
Copy Markdown
Contributor

datadog-prod-us1-3 Bot commented Apr 29, 2026

Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: b0d3ab8 | Docs | Datadog PR Page | Give us feedback!

Dev-mode check rejects manifest versions ahead of the current tested tracer
(4.9.0-rc1). The cost_tags PR is merged but not yet in any released version.
Use missing_feature for now; bump to a concrete version once released.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@XG-xin XG-xin marked this pull request as ready for review April 30, 2026 20:10
@XG-xin XG-xin requested review from a team as code owners April 30, 2026 20:10
@XG-xin XG-xin requested review from Kyle-Verhoog, avara1986, jandro996 and manuel-alvarez-alvarez and removed request for a team April 30, 2026 20:10
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b2177afdf9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread utils/docker_fixtures/spec/llm_observability.py
Copy link
Copy Markdown
Contributor

@sabrenner sabrenner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great, thanks for adding these tests! just a couple actionable things and one note for when (if?) we add Java cost tracking tags too

return span_event.get("meta", {}).get("metadata", {}).get("_dd", {}).get("cost_tags")


@features.llm_observability_sdk_enablement
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small request to make a different feature for this! let me know if you need help with that, i think i made a confluence page on it but i can follow up with you on slack!

Comment thread utils/docker_fixtures/spec/llm_observability.py
llmobs_request = LlmObsAnnotationContextRequest(
tags={"team": "ml", "feature": "chatbot"},
cost_tags=["team", "feature"],
children=[LlmObsSpanRequest(kind="llm")],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would say actually maybe having two children here and making sure each one gets the tags to make sure they are getting properly added would be a slightly better test, so like

children=[LlmObsSpanRequest(kind="llm"), LlmObsSpanRequest(kind="llm")],

# ...

assert _get_cost_tags(span_events[0]) == ["team", "feature"]
assert _get_cost_tags(span_events[1]) == ["team", "feature"]

just to be extra sure!

Comment thread tests/parametric/test_llm_observability/test_llm_observability.py
@XG-xin
Copy link
Copy Markdown
Contributor Author

XG-xin commented May 1, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 129254e0e3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread manifests/python.yml
tests/parametric/test_library_tracestats.py::Test_Library_Tracestats::test_sample_rate_0_TS007: missing_feature (failure 2.8.0) # Created by easy win activation script
tests/parametric/test_library_tracestats.py::Test_Library_Tracestats::test_successes_errors_recorded_separately_TS006: missing_feature (failure 2.8.0) # Created by easy win activation script
tests/parametric/test_library_tracestats.py::Test_Library_Tracestats::test_top_level_TS005: missing_feature (failure 2.8.0) # Created by easy win activation script
tests/parametric/test_llm_observability/test_llm_observability.py::Test_CostTags: missing_feature (cost_tags merged in dd-trace-py#17628, not yet in a released version — bump to the version once released)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Quote manifest values containing #

.cursor/rules/pr-review.mdc requires manifest values with special YAML characters, including #, to be quoted. This new Python manifest declaration includes dd-trace-py#17628 as an unquoted scalar, so it violates the repository manifest YAML syntax rule; wrap the whole value in quotes to keep the manifest compliant and avoid tooling/parsing surprises if the reason text is edited.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

@sabrenner sabrenner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two non-blocking comments, feel free to address! otherwise good to go, just looks like the linter is failing & blocking tests from running

Comment thread utils/build/docker/nodejs/parametric/llmobs.js Outdated
}
# cost_tags was added later — only forward when set so older SDK versions
# without the kwarg don't break unrelated tests in the same weblog.
if options.get("cost_tags") is None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think if we gate the tests that run cost tracking behind the version that it's released in, we don't need this line here, but not blocking

XG-xin and others added 2 commits May 1, 2026 11:23
Co-authored-by: Sam Brenner <106700075+sabrenner@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The prod tracer image runs python@4.8.0 (pre-#17628), which raises TypeError on
LLMObs.annotate(cost_tags=...). Restoring the defensive pop so unrelated
annotate-using tests (Test_Enablement, Test_Prompts) keep passing on prod.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants