class NewRelic::Agent::LLM
Constants
- CONTENT
- INPUT
- SEGMENT_PATTERN
Public Class Methods
exempt_event_attribute?(type, key)
click to toggle source
LLM
content-related attributes are exempt from the 4095 byte limit
# File lib/new_relic/agent/llm.rb, line 23 def self.exempt_event_attribute?(type, key) return false unless instrumentation_enabled? (type == NewRelic::Agent::Llm::Embedding::EVENT_NAME && key == INPUT) || (type == NewRelic::Agent::Llm::ChatCompletionMessage::EVENT_NAME && key == CONTENT) end
instrumentation_enabled?()
click to toggle source
# File lib/new_relic/agent/llm.rb, line 18 def self.instrumentation_enabled? NewRelic::Agent.config[:'ai_monitoring.enabled'] end
openai?()
click to toggle source
# File lib/new_relic/agent/llm.rb, line 30 def self.openai? @openai ||= %i[prepend chain].include?(NewRelic::Agent.config[:'instrumentation.ruby_openai']) && NewRelic::Agent.config[:'ai_monitoring.enabled'] end
openai_parent?(segment)
click to toggle source
Used in NetHTTP instrumentation
# File lib/new_relic/agent/llm.rb, line 36 def self.openai_parent?(segment) return false unless openai? segment&.parent&.name&.match?(SEGMENT_PATTERN) end
populate_openai_response_headers(response, parent)
click to toggle source
# File lib/new_relic/agent/llm.rb, line 42 def self.populate_openai_response_headers(response, parent) return unless parent.instance_variable_defined?(:@llm_event) parent.llm_event.populate_openai_response_headers(response.to_hash) end