From 2c69838130c98ddc2f8799981acc1539703f45a3 Mon Sep 17 00:00:00 2001 From: Josh Bonczkowski Date: Fri, 13 Mar 2026 16:53:25 -0400 Subject: [PATCH] Addressing some feedback. --- litellm/integrations/newrelic/newrelic.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/litellm/integrations/newrelic/newrelic.py b/litellm/integrations/newrelic/newrelic.py index 5275125a21d..8b097799a27 100644 --- a/litellm/integrations/newrelic/newrelic.py +++ b/litellm/integrations/newrelic/newrelic.py @@ -544,6 +544,10 @@ class NewRelicLogger(CustomLogger): if app and app.enabled: app.record_custom_event("LlmChatCompletionSummary", event_data) + else: + verbose_logger.warning( + "New Relic application is not enabled; skipping summary event recording." + ) except Exception as e: verbose_logger.warning(f"Failed to record New Relic summary event: {e}") @@ -571,6 +575,12 @@ class NewRelicLogger(CustomLogger): app = newrelic.agent.application() + if not (app and app.enabled): + verbose_logger.warning( + "New Relic application is not enabled; skipping message event recording." + ) + return + for message in messages: sequence = message["sequence"] event_data = { @@ -606,8 +616,7 @@ class NewRelicLogger(CustomLogger): if "timestamp" in message: event_data["timestamp"] = message["timestamp"] - if app and app.enabled: - app.record_custom_event("LlmChatCompletionMessage", event_data) + app.record_custom_event("LlmChatCompletionMessage", event_data) except Exception as e: verbose_logger.warning(f"Failed to record New Relic message events: {e}") @@ -651,6 +660,9 @@ class NewRelicLogger(CustomLogger): # Get trace context trace_id, span_id = self._get_trace_context(kwargs) if not trace_id: + verbose_logger.warning( + "Failed to get trace context; skipping New Relic event recording." + ) return # Generate unique request ID for this request (used as Summary event id)