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 }
- 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 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.
-
#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_hash ⇒ Object
Constructor Details
#initialize(configuration: Sentry.configuration, **options) ⇒ LogEvent
Returns a new instance of LogEvent.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/sentry/log_event.rb', line 70 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] || {} @contexts = {} end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
43 44 45 |
# File 'lib/sentry/log_event.rb', line 43 def attributes @attributes end |
#body ⇒ Object
Returns the value of attribute body.
43 44 45 |
# File 'lib/sentry/log_event.rb', line 43 def body @body end |
#level ⇒ Object
Returns the value of attribute level.
43 44 45 |
# File 'lib/sentry/log_event.rb', line 43 def level @level end |
#template ⇒ Object
Returns the value of attribute template.
43 44 45 |
# File 'lib/sentry/log_event.rb', line 43 def template @template end |
#user ⇒ Object
Returns the value of attribute user.
43 44 45 |
# File 'lib/sentry/log_event.rb', line 43 def user @user end |
Instance Method Details
#to_hash ⇒ Object
85 86 87 88 89 |
# File 'lib/sentry/log_event.rb', line 85 def to_hash SERIALIZEABLE_ATTRIBUTES.each_with_object({}) do |name, memo| memo[name] = serialize(name) end end |