Class: Sentry::MetricEvent

Inherits:
Object
  • Object
show all
Includes:
Utils::TelemetryAttributes
Defined in:
lib/sentry/metric_event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, type:, value:, unit: nil, attributes: nil, integration_meta: nil) ⇒ MetricEvent

Returns a new instance of MetricEvent.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/sentry/metric_event.rb', line 12

def initialize(
  name:,
  type:,
  value:,
  unit: nil,
  attributes: nil,
  integration_meta: nil
)
  @name = name
  @type = type
  @value = value
  @unit = unit
  @attributes = attributes || {}
  @integration_meta = integration_meta

  @timestamp = Sentry.utc_now
  @trace_id = nil
  @span_id = nil
end

Instance Attribute Details

#attributes ⇒ Object

Returns the value of attribute attributes.



9
10
11
# File 'lib/sentry/metric_event.rb', line 9

def attributes
  @attributes
end

#integration_meta ⇒ Object (readonly)

Returns the value of attribute integration_meta.



9
10
11
# File 'lib/sentry/metric_event.rb', line 9

def integration_meta
  @integration_meta
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/sentry/metric_event.rb', line 9

def name
  @name
end

#span_id ⇒ Object

Returns the value of attribute span_id.



9
10
11
# File 'lib/sentry/metric_event.rb', line 9

def span_id
  @span_id
end

#timestamp ⇒ Object (readonly)

Returns the value of attribute timestamp.



9
10
11
# File 'lib/sentry/metric_event.rb', line 9

def timestamp
  @timestamp
end

#trace_id ⇒ Object

Returns the value of attribute trace_id.



9
10
11
# File 'lib/sentry/metric_event.rb', line 9

def trace_id
  @trace_id
end

#type ⇒ Object (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/sentry/metric_event.rb', line 9

def type
  @type
end

#unit ⇒ Object (readonly)

Returns the value of attribute unit.



9
10
11
# File 'lib/sentry/metric_event.rb', line 9

def unit
  @unit
end

#value ⇒ Object (readonly)

Returns the value of attribute value.



9
10
11
# File 'lib/sentry/metric_event.rb', line 9

def value
  @value
end

Instance Method Details

#to_h ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/sentry/metric_event.rb', line 32

def to_h
  {
    name: @name,
    type: @type,
    value: @value,
    unit: @unit,
    timestamp: @timestamp.to_f,
    trace_id: @trace_id,
    span_id: @span_id,
    attributes: serialize_attributes
  }.compact
end