class NewRelic::Agent::Llm::ChatCompletionSummary
Constants
- ATTRIBUTES
- ATTRIBUTE_NAME_EXCEPTIONS
- ERROR_COMPLETION_ID
- EVENT_NAME
Public Instance Methods
attribute_name_exceptions()
click to toggle source
# File lib/new_relic/agent/llm/chat_completion_summary.rb, line 31 def attribute_name_exceptions # TODO: OLD RUBIES < 2.6 # Hash#merge accepts multiple arguments in 2.6 # Remove condition once support for Ruby <2.6 is dropped if RUBY_VERSION >= '2.6.0' LlmEvent::ATTRIBUTE_NAME_EXCEPTIONS.merge(ResponseHeaders::ATTRIBUTE_NAME_EXCEPTIONS, ATTRIBUTE_NAME_EXCEPTIONS) else LlmEvent::ATTRIBUTE_NAME_EXCEPTIONS.merge(ResponseHeaders::ATTRIBUTE_NAME_EXCEPTIONS).merge(ATTRIBUTE_NAME_EXCEPTIONS) end end
attributes()
click to toggle source
# File lib/new_relic/agent/llm/chat_completion_summary.rb, line 27 def attributes LlmEvent::ATTRIBUTES + ResponseHeaders::ATTRIBUTES + ATTRIBUTES end
error_attributes(exception)
click to toggle source
# File lib/new_relic/agent/llm/chat_completion_summary.rb, line 46 def error_attributes(exception) attrs = {ERROR_COMPLETION_ID => id} error_attributes_from_response(exception, attrs) end
event_name()
click to toggle source
# File lib/new_relic/agent/llm/chat_completion_summary.rb, line 42 def event_name EVENT_NAME end
Private Instance Methods
error_attributes_from_response(exception, attrs)
click to toggle source
# File lib/new_relic/agent/llm/chat_completion_summary.rb, line 54 def error_attributes_from_response(exception, attrs) return attrs unless exception.respond_to?(:response) attrs[ERROR_ATTRIBUTE_STATUS_CODE] = exception.response.dig(:status) attrs[ERROR_ATTRIBUTE_CODE] = exception.response.dig(:body, ERROR_STRING, CODE_STRING) attrs[ERROR_ATTRIBUTE_PARAM] = exception.response.dig(:body, ERROR_STRING, PARAM_STRING) attrs end