Class: OpenTelemetry::SDK::Logs::LogRecord

Inherits:
Logs::LogRecord
  • Object
show all
Defined in:
lib/opentelemetry/sdk/logs/log_record.rb

Overview

Implementation of OpenTelemetry::Logs::LogRecord that records log events.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(timestamp: nil, observed_timestamp: nil, severity_text: nil, severity_number: nil, body: nil, attributes: nil, event_name: nil, trace_id: nil, span_id: nil, trace_flags: nil, resource: nil, instrumentation_scope: nil, log_record_limits: nil) ⇒ LogRecord

Parameters:

  • timestamp (optional Time) (defaults to: nil) —

    Time when the event occurred.

  • observed_timestamp (optional Time) (defaults to: nil) —

    Time when the event was observed by the collection system. If nil, will first attempt to set to timestamp. If timestamp is nil, will set to Time.now.

  • span_context (optional OpenTelemetry::Trace::SpanContext) —

    The OpenTelemetry::Trace::SpanContext to associate with the LogRecord.

  • severity_text (optional String) (defaults to: nil) —

    The log severity, also known as log level.

  • severity_number (optional Integer) (defaults to: nil) —

    The numerical value of the log severity.

  • body (optional String, Numeric, Boolean, Array<String, Numeric, Boolean>, Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}) (defaults to: nil) —
  • attributes (optional Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}) (defaults to: nil) —

    Attributes to associate with the OpenTelemetry::SDK::Logs::LogRecord.

  • event_name (optional String) (defaults to: nil) —

    A name that identifies the class or the type of the event.

  • trace_id (optional String) (defaults to: nil) —

    The trace ID associated with the current context.

  • span_id (optional String) (defaults to: nil) —

    The span ID associated with the current context.

  • trace_flags (optional OpenTelemetry::Trace::TraceFlags) (defaults to: nil) —

    The trace flags associated with the current context.

  • resource (optional OpenTelemetry::SDK::Resources::Resource) (defaults to: nil) —

    The source of the log, desrived from the LoggerProvider.

  • instrumentation_scope (optional OpenTelemetry::SDK::InstrumentationScope) (defaults to: nil) —

    The instrumentation scope, derived from the emitting Logger

  • OpenTelemetry::SDK::LogRecordLimits] (optional) —

    log_record_limits Attribute limits



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/opentelemetry/sdk/logs/log_record.rb', line 65

def initialize(
  timestamp: nil,
  observed_timestamp: nil,
  severity_text: nil,
  severity_number: nil,
  body: nil,
  attributes: nil,
  event_name: nil,
  trace_id: nil,
  span_id: nil,
  trace_flags: nil,
  resource: nil,
  instrumentation_scope: nil,
  log_record_limits: nil
)
  @timestamp = timestamp
  @observed_timestamp = observed_timestamp || timestamp || Time.now
  @severity_text = severity_text
  @severity_number = severity_number
  @body = body
  @event_name = event_name
  @trace_id = trace_id
  @span_id = span_id
  @trace_flags = trace_flags
  @resource = resource
  @instrumentation_scope = instrumentation_scope
  @log_record_limits = log_record_limits || LogRecordLimits::DEFAULT
  @dropped_attributes_count = 0
  self.attributes = attributes
end

Instance Attribute Details

#attributes ⇒ Object

Returns the value of attribute attributes.



28
29
30
# File 'lib/opentelemetry/sdk/logs/log_record.rb', line 28

def attributes
  @attributes
end

#body ⇒ Object

Returns the value of attribute body.



16
17
18
# File 'lib/opentelemetry/sdk/logs/log_record.rb', line 16

def body
  @body
end

#event_name ⇒ Object

Returns the value of attribute event_name.



16
17
18
# File 'lib/opentelemetry/sdk/logs/log_record.rb', line 16

def event_name
  @event_name
end

#instrumentation_scope ⇒ Object

Returns the value of attribute instrumentation_scope.



16
17
18
# File 'lib/opentelemetry/sdk/logs/log_record.rb', line 16

def instrumentation_scope
  @instrumentation_scope
end

#observed_timestamp ⇒ Object

Returns the value of attribute observed_timestamp.



16
17
18
# File 'lib/opentelemetry/sdk/logs/log_record.rb', line 16

def observed_timestamp
  @observed_timestamp
end

#resource ⇒ Object

Returns the value of attribute resource.



16
17
18
# File 'lib/opentelemetry/sdk/logs/log_record.rb', line 16

def resource
  @resource
end

#severity_number ⇒ Object

Returns the value of attribute severity_number.



16
17
18
# File 'lib/opentelemetry/sdk/logs/log_record.rb', line 16

def severity_number
  @severity_number
end

#severity_text ⇒ Object

Returns the value of attribute severity_text.



16
17
18
# File 'lib/opentelemetry/sdk/logs/log_record.rb', line 16

def severity_text
  @severity_text
end

#span_id ⇒ Object

Returns the value of attribute span_id.



16
17
18
# File 'lib/opentelemetry/sdk/logs/log_record.rb', line 16

def span_id
  @span_id
end

#timestamp ⇒ Object

Returns the value of attribute timestamp.



16
17
18
# File 'lib/opentelemetry/sdk/logs/log_record.rb', line 16

def timestamp
  @timestamp
end

#trace_flags ⇒ Object

Returns the value of attribute trace_flags.



16
17
18
# File 'lib/opentelemetry/sdk/logs/log_record.rb', line 16

def trace_flags
  @trace_flags
end

#trace_id ⇒ Object

Returns the value of attribute trace_id.



16
17
18
# File 'lib/opentelemetry/sdk/logs/log_record.rb', line 16

def trace_id
  @trace_id
end

Instance Method Details

#to_log_record_data ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/opentelemetry/sdk/logs/log_record.rb', line 106

def to_log_record_data
  LogRecordData.new(
    to_integer_nanoseconds(@timestamp),
    to_integer_nanoseconds(@observed_timestamp),
    @severity_text,
    @severity_number,
    @body,
    @attributes,
    @event_name,
    @trace_id,
    @span_id,
    @trace_flags,
    @resource,
    @instrumentation_scope,
    @dropped_attributes_count
  )
end