Skip to content

Conversation

mubashir1osmani
Copy link
Collaborator

@mubashir1osmani mubashir1osmani commented Sep 14, 2025

Title

Added these metrics in datadog logging

  • litellm_spend_metric
  • litellm_api_key_max_budget_value
  • litellm_api_key_budget_reset_at
Screenshot 2025-09-14 at 1 45 51 PM Screenshot 2025-09-14 at 2 38 40 PM Screenshot 2025-09-14 at 2 49 45 PM

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🆕 New Feature

Copy link

vercel bot commented Sep 14, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
litellm Ready Ready Preview Comment Sep 17, 2025 4:32am

@krrishdholakia
Copy link
Contributor

can you fix this test? @mubashir1osmani
Screenshot 2025-09-15 at 9 06 00 PM

Copy link
Contributor

@ishaan-jaff ishaan-jaff left a comment

Choose a reason for hiding this comment

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

import json
from datetime import datetime, date

def custom_json_encoder(obj):
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a bad idea - we already have safe_dumps in the codebase

# Get response cost for litellm_spend_metric
response_cost = standard_logging_payload.get("response_cost", 0.0)
if response_cost > 0:
spend_metrics["litellm_spend_metric"] = response_cost
Copy link
Contributor

Choose a reason for hiding this comment

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

this is confusing to ready. response_cost should get sent as response_cost

metadata = standard_logging_payload.get("metadata", {})

# API key max budget
user_api_key_max_budget = metadata.get("user_api_key_max_budget")
Copy link
Contributor

Choose a reason for hiding this comment

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

we must send user_api_key_spend too

@mubashir1osmani
Copy link
Collaborator Author

mubashir1osmani commented Sep 17, 2025

thx @ishaan-jaff changes made

Screenshot 2025-09-17 at 12 08 21 AM Screenshot 2025-09-17 at 12 08 55 AM Screenshot 2025-09-17 at 12 20 39 AM

@krrishdholakia krrishdholakia merged commit fcf8402 into BerriAI:main Sep 17, 2025
4 of 6 checks passed
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.

3 participants