Addressing some feedback.

This commit is contained in:
Josh Bonczkowski 2026-03-13 16:53:25 -04:00
parent 24c20be337
commit 2c69838130

View file

@ -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)