feat(datadog): add 'team' tag to logs, metrics, and cost management#21449
Merged
Harshit28j merged 5 commits intoBerriAI:mainfrom Feb 18, 2026
Merged
feat(datadog): add 'team' tag to logs, metrics, and cost management#21449Harshit28j merged 5 commits intoBerriAI:mainfrom
Harshit28j merged 5 commits intoBerriAI:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Author
|
@greptile can you please review this PR ? |
Contributor
Greptile SummaryThis PR adds a
Confidence Score: 3/5
|
| Filename | Overview |
|---|---|
| litellm/integrations/datadog/datadog_handler.py | Adds team tag extraction via or-chaining on metadata fields. The team_alias and team_id fallbacks are currently dead code since those fields are never populated, but the primary user_api_key_team_alias path works correctly. |
| litellm/integrations/datadog/datadog_cost_management.py | Team tag extraction added with consistent or-chaining pattern. Has a duplicate # Add user info comment on line 172. Same dead-code fallbacks as datadog_handler.py. Improved user alias check from in to .get() which is a correctness fix. |
| litellm/types/utils.py | Adds team_alias and team_id fields to StandardLoggingMetadata, but no code path populates these fields with actual values. They are initialized to None in litellm_logging.py but never set from the proxy auth flow. |
| litellm/litellm_core_utils/litellm_logging.py | Adds team_alias=None and team_id=None initialization to StandardLoggingMetadata construction. Also includes whitespace-only formatting changes (line breaks for long conditionals). No functional issues with the formatting changes. |
| tests/test_litellm/integrations/datadog/test_datadog_tags_regression.py | New regression tests for team tag extraction. Tests use partial TypedDict construction that doesn't match production metadata shape. The async test may have fragility due to DatadogCostManagementLogger calling asyncio.create_task during init. |
| docs/my-website/docs/observability/datadog.md | Adds documentation for the automatic team and request_tag tags. Documents the team_alias and team_id sources which are not yet populated in production. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[LLM Request] --> B[Proxy Auth]
B --> C[UserAPIKeyAuth populates metadata]
C --> D{user_api_key_team_alias set?}
D -->|Yes| E[team tag = user_api_key_team_alias]
D -->|No| F{team_alias set?}
F -->|Yes - currently never| G[team tag = team_alias]
F -->|No| H{user_api_key_team_id set?}
H -->|Yes| I[team tag = user_api_key_team_id]
H -->|No| J{team_id set?}
J -->|Yes - currently never| K[team tag = team_id]
J -->|No| L[No team tag added]
E --> M[Datadog Handler / Cost Management]
G --> M
I --> M
K --> M
L --> M
M --> N[Tags sent to Datadog]
Last reviewed commit: 5755483
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relevant issues
Closes the need for team-based observability in Datadog integration.
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewCI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Type
🆕 New Feature
Changes
teamtag from request metadata. Logic prioritizesuser_api_key_team_alias->team_alias->user_api_key_team_id->team_id.teamtag extraction in _extract_tags to ensure cost metrics are properly attributed to teams.teamtag sources.