Class: Sentry::LogEvent
- Inherits:
- 
      Object
      
        - Object
- Sentry::LogEvent
 
- Defined in:
- lib/sentry/log_event.rb
Overview
Event type that represents a log entry with its attributes
Constant Summary collapse
- TYPE =
- "log"
- DEFAULT_PARAMETERS =
- [].freeze 
- DEFAULT_ATTRIBUTES =
- {}.freeze 
- SERIALIZEABLE_ATTRIBUTES =
- %i[ level body timestamp environment release server_name trace_id attributes contexts ] 
- SENTRY_ATTRIBUTES =
- { "sentry.trace.parent_span_id" => :parent_span_id, "sentry.environment" => :environment, "sentry.release" => :release, "sentry.address" => :server_name, "sentry.sdk.name" => :sdk_name, "sentry.sdk.version" => :sdk_version, "sentry.message.template" => :template, "sentry.origin" => :origin } 
- PARAMETER_PREFIX =
- "sentry.message.parameter"
- USER_ATTRIBUTES =
- { "user.id" => :user_id, "user.name" => :user_username, "user.email" => :user_email } 
- LEVELS =
- %i[trace debug info warn error fatal].freeze 
- SERIALIZERS =
- %i[ attributes body level parent_span_id sdk_name sdk_version template timestamp trace_id user_id user_username user_email ].map { |name| [name, :"serialize_#{name}"] }.to_h 
- VALUE_TYPES =
- Hash.new("string").merge!({ TrueClass => "boolean", FalseClass => "boolean", Integer => "integer", Float => "double" }).freeze 
- TOKEN_REGEXP =
- /%\{(\w+)\}/
Instance Attribute Summary collapse
- 
  
    
      #attributes  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute attributes. 
- 
  
    
      #body  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute body. 
- 
  
    
      #level  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute level. 
- 
  
    
      #origin  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute origin. 
- 
  
    
      #template  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute template. 
- 
  
    
      #user  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute user. 
Instance Method Summary collapse
- 
  
    
      #initialize(configuration: Sentry.configuration, **options)  ⇒ LogEvent 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of LogEvent. 
- #to_h ⇒ Object
Constructor Details
#initialize(configuration: Sentry.configuration, **options) ⇒ LogEvent
Returns a new instance of LogEvent.
| 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | # File 'lib/sentry/log_event.rb', line 74 def initialize(configuration: Sentry.configuration, **) @configuration = configuration @type = TYPE @server_name = configuration.server_name @environment = configuration.environment @release = configuration.release @timestamp = Sentry.utc_now @level = .fetch(:level) @body = [:body] @template = @body if is_template? @attributes = [:attributes] || DEFAULT_ATTRIBUTES @user = [:user] || {} @origin = [:origin] @contexts = {} end | 
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
| 46 47 48 | # File 'lib/sentry/log_event.rb', line 46 def attributes @attributes end | 
#body ⇒ Object
Returns the value of attribute body.
| 46 47 48 | # File 'lib/sentry/log_event.rb', line 46 def body @body end | 
#level ⇒ Object
Returns the value of attribute level.
| 46 47 48 | # File 'lib/sentry/log_event.rb', line 46 def level @level end | 
#origin ⇒ Object
Returns the value of attribute origin.
| 46 47 48 | # File 'lib/sentry/log_event.rb', line 46 def origin @origin end | 
#template ⇒ Object
Returns the value of attribute template.
| 46 47 48 | # File 'lib/sentry/log_event.rb', line 46 def template @template end | 
#user ⇒ Object
Returns the value of attribute user.
| 46 47 48 | # File 'lib/sentry/log_event.rb', line 46 def user @user end | 
Instance Method Details
#to_h ⇒ Object
| 90 91 92 93 94 | # File 'lib/sentry/log_event.rb', line 90 def to_h SERIALIZEABLE_ATTRIBUTES.each_with_object({}) do |name, memo| memo[name] = serialize(name) end end |