Class: Sentry::LogEvent
- Inherits:
-
Object
- Object
- Sentry::LogEvent
- Includes:
- Utils::TelemetryAttributes
- 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
- PARAMETER_PREFIX =
"sentry.message.parameter"- LEVELS =
%i[trace debug info warn error fatal].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.
-
#span_id ⇒ Object
Returns the value of attribute span_id.
-
#template ⇒ Object
Returns the value of attribute template.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#trace_id ⇒ Object
Returns the value of attribute trace_id.
Instance Method Summary collapse
-
#initialize(**options) ⇒ LogEvent
constructor
A new instance of LogEvent.
- #to_h ⇒ Object
Constructor Details
#initialize(**options) ⇒ LogEvent
Returns a new instance of LogEvent.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sentry/log_event.rb', line 25 def initialize(**) @type = TYPE @timestamp = Sentry.utc_now @level = .fetch(:level) @body = [:body] @template = @body if is_template? @attributes = [:attributes] || {} @origin = [:origin] @trace_id = nil @span_id = nil end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
20 21 22 |
# File 'lib/sentry/log_event.rb', line 20 def attributes @attributes end |
#body ⇒ Object
Returns the value of attribute body.
20 21 22 |
# File 'lib/sentry/log_event.rb', line 20 def body @body end |
#level ⇒ Object
Returns the value of attribute level.
20 21 22 |
# File 'lib/sentry/log_event.rb', line 20 def level @level end |
#origin ⇒ Object
Returns the value of attribute origin.
20 21 22 |
# File 'lib/sentry/log_event.rb', line 20 def origin @origin end |
#span_id ⇒ Object
Returns the value of attribute span_id.
20 21 22 |
# File 'lib/sentry/log_event.rb', line 20 def span_id @span_id end |
#template ⇒ Object
Returns the value of attribute template.
20 21 22 |
# File 'lib/sentry/log_event.rb', line 20 def template @template end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
21 22 23 |
# File 'lib/sentry/log_event.rb', line 21 def @timestamp end |
#trace_id ⇒ Object
Returns the value of attribute trace_id.
20 21 22 |
# File 'lib/sentry/log_event.rb', line 20 def trace_id @trace_id end |
Instance Method Details
#to_h ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/sentry/log_event.rb', line 37 def to_h { level: level.to_s, timestamp: .to_f, trace_id: @trace_id, span_id: @span_id, body: serialize_body, attributes: serialize_attributes }.compact end |