Module: Sentry::Metrics

Defined in:
lib/sentry/metrics.rb

Class Method Summary collapse

Class Method Details

.count(name, value: 1, attributes: nil, integration: nil) ⇒ void

This method returns an undefined value.

Increments a counter metric

Parameters:

  • name (String) —

    the metric name

  • value (Numeric) (defaults to: 1) —

    the value to increment by (default: 1)

  • attributes (Hash, nil) (defaults to: nil) —

    additional attributes for the metric (optional)

  • integration (String, Symbol, nil) (defaults to: nil) —

    registered integration emitting the metric (optional)



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/sentry/metrics.rb', line 14

def count(name, value: 1, attributes: nil, integration: nil)
  return unless Sentry.initialized?

  Sentry.get_current_hub.capture_metric(
    name: name,
    type: :counter,
    value: value,
    attributes: attributes,
    integration: integration
  )
end

.distribution(name, value, unit: nil, attributes: nil, integration: nil) ⇒ void

This method returns an undefined value.

Records a distribution metric

Parameters:

  • name (String) —

    the metric name

  • value (Numeric) —

    the distribution value

  • unit (String, nil) (defaults to: nil) —

    the metric unit (optional)

  • attributes (Hash, nil) (defaults to: nil) —

    additional attributes for the metric (optional)

  • integration (String, Symbol, nil) (defaults to: nil) —

    registered integration emitting the metric (optional)



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/sentry/metrics.rb', line 53

def distribution(name, value, unit: nil, attributes: nil, integration: nil)
  return unless Sentry.initialized?

  Sentry.get_current_hub.capture_metric(
    name: name,
    type: :distribution,
    value: value,
    unit: unit,
    attributes: attributes,
    integration: integration
  )
end

.gauge(name, value, unit: nil, attributes: nil, integration: nil) ⇒ void

This method returns an undefined value.

Records a gauge metric

Parameters:

  • name (String) —

    the metric name

  • value (Numeric) —

    the gauge value

  • unit (String, nil) (defaults to: nil) —

    the metric unit (optional)

  • attributes (Hash, nil) (defaults to: nil) —

    additional attributes for the metric (optional)

  • integration (String, Symbol, nil) (defaults to: nil) —

    registered integration emitting the metric (optional)



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

def gauge(name, value, unit: nil, attributes: nil, integration: nil)
  return unless Sentry.initialized?

  Sentry.get_current_hub.capture_metric(
    name: name,
    type: :gauge,
    value: value,
    unit: unit,
    attributes: attributes,
    integration: integration
  )
end