Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ def test_increment_token_metrics(prometheus_logger):
team_alias="test_team_alias",
requested_model=None,
model="gpt-3.5-turbo",
model_id="model-123",
)
prometheus_logger.litellm_tokens_metric.labels().inc.assert_called_once_with(100)

Expand All @@ -243,6 +244,7 @@ def test_increment_token_metrics(prometheus_logger):
team_alias="test_team_alias",
requested_model=None,
model="gpt-3.5-turbo",
model_id="model-123",
)
prometheus_logger.litellm_input_tokens_metric.labels().inc.assert_called_once_with(
50
Expand All @@ -258,6 +260,7 @@ def test_increment_token_metrics(prometheus_logger):
team_alias="test_team_alias",
requested_model=None,
model="gpt-3.5-turbo",
model_id="model-123",
)
prometheus_logger.litellm_output_tokens_metric.labels().inc.assert_called_once_with(
50
Expand Down Expand Up @@ -435,6 +438,7 @@ def test_set_latency_metrics(prometheus_logger):
team_alias="test_team_alias",
requested_model="openai-gpt",
model="gpt-3.5-turbo",
model_id="model-123",
)
prometheus_logger.litellm_llm_api_latency_metric.labels().observe.assert_called_once_with(
1.5
Expand Down Expand Up @@ -656,6 +660,7 @@ async def test_async_log_failure_event(prometheus_logger):
"test_team",
"test_team_alias",
"test_user",
"model-123",
)
prometheus_logger.litellm_llm_api_failed_requests_metric.labels().inc.assert_called_once()

Expand All @@ -680,6 +685,8 @@ async def test_async_log_failure_event(prometheus_logger):
api_key_alias="test_alias",
team="test_team",
team_alias="test_team_alias",
client_ip="127.0.0.1", # from standard logging payload
user_agent=None,
)
prometheus_logger.litellm_deployment_failure_responses.labels().inc.assert_called_once()

Expand All @@ -694,6 +701,8 @@ async def test_async_log_failure_event(prometheus_logger):
api_key_alias="test_alias",
team="test_team",
team_alias="test_team_alias",
client_ip="127.0.0.1", # from standard logging payload
user_agent=None,
)
prometheus_logger.litellm_deployment_total_requests.labels().inc.assert_called_once()

Expand Down Expand Up @@ -747,6 +756,8 @@ async def test_async_post_call_failure_hook(prometheus_logger):
exception_class="Openai.RateLimitError",
route=user_api_key_dict.request_route,
model_id=None,
client_ip=None,
user_agent=None,
)
prometheus_logger.litellm_proxy_failed_requests_metric.labels().inc.assert_called_once()

Expand All @@ -763,6 +774,8 @@ async def test_async_post_call_failure_hook(prometheus_logger):
user_email=None,
route=user_api_key_dict.request_route,
model_id=None,
client_ip=None,
user_agent=None,
)
prometheus_logger.litellm_proxy_total_requests_metric.labels().inc.assert_called_once()

Expand Down Expand Up @@ -810,6 +823,8 @@ async def test_async_post_call_success_hook(prometheus_logger):
user_email=None,
route=user_api_key_dict.request_route,
model_id=None,
client_ip=None,
user_agent=None,
)
prometheus_logger.litellm_proxy_total_requests_metric.labels().inc.assert_called_once()

Expand Down Expand Up @@ -875,6 +890,7 @@ def test_set_llm_deployment_success_metrics(prometheus_logger):
litellm_model_name="gpt-3.5-turbo", # actual model used - litellm model name
hashed_api_key=standard_logging_payload["metadata"]["user_api_key_hash"],
api_key_alias=standard_logging_payload["metadata"]["user_api_key_alias"],
model_id="model-123",
)

prometheus_logger.litellm_remaining_requests_metric.labels().set.assert_called_once_with(
Expand All @@ -889,6 +905,7 @@ def test_set_llm_deployment_success_metrics(prometheus_logger):
hashed_api_key=standard_logging_payload["metadata"]["user_api_key_hash"],
litellm_model_name="gpt-3.5-turbo",
model_group="my_custom_model_group",
model_id="model-123",
)

prometheus_logger.litellm_remaining_tokens_metric.labels().set.assert_called_once_with(
Expand All @@ -914,6 +931,8 @@ def test_set_llm_deployment_success_metrics(prometheus_logger):
api_key_alias=standard_logging_payload["metadata"]["user_api_key_alias"],
team=standard_logging_payload["metadata"]["user_api_key_team_id"],
team_alias=standard_logging_payload["metadata"]["user_api_key_team_alias"],
client_ip=None,
user_agent=None,
)
prometheus_logger.litellm_deployment_success_responses.labels().inc.assert_called_once()

Expand All @@ -928,6 +947,8 @@ def test_set_llm_deployment_success_metrics(prometheus_logger):
api_key_alias=standard_logging_payload["metadata"]["user_api_key_alias"],
team=standard_logging_payload["metadata"]["user_api_key_team_id"],
team_alias=standard_logging_payload["metadata"]["user_api_key_team_alias"],
client_ip=None,
user_agent=None,
)
prometheus_logger.litellm_deployment_total_requests.labels().inc.assert_called_once()

Expand All @@ -949,6 +970,7 @@ def test_set_llm_deployment_success_metrics(prometheus_logger):
hashed_api_key=standard_logging_payload["metadata"]["user_api_key_hash"],
litellm_model_name="gpt-3.5-turbo",
model_group="my_custom_model_group",
model_id="model-123",
)

# Calculate expected latency per token (1 second / 10 tokens = 0.1 seconds per token)
Expand Down Expand Up @@ -991,6 +1013,7 @@ async def test_log_success_fallback_event(prometheus_logger):
team_alias="test_team_alias",
exception_status="429",
exception_class="Openai.RateLimitError",
model_id=None,
)
prometheus_logger.litellm_deployment_successful_fallbacks.labels().inc.assert_called_once()

Expand Down Expand Up @@ -1028,6 +1051,7 @@ async def test_log_failure_fallback_event(prometheus_logger):
team_alias="test_team_alias",
exception_status="429",
exception_class="Openai.RateLimitError",
model_id=None,
)
prometheus_logger.litellm_deployment_failed_fallbacks.labels().inc.assert_called_once()

Expand Down
Loading