Module: Sentry::Metrics

Defined in:
lib/sentry/metrics.rb

Class Method Summary collapse

Class Method Details

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

This method returns an undefined value.

Increments a counter metric

Parameters:

  • the metric name

  • (defaults to: 1)

    the value to increment by (default: 1)

  • (defaults to: nil)

    additional attributes for the metric (optional)



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

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

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

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

This method returns an undefined value.

Records a distribution metric

Parameters:

  • the metric name

  • the distribution value

  • (defaults to: nil)

    the metric unit (optional)

  • (defaults to: nil)

    additional attributes for the metric (optional)



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/sentry/metrics.rb', line 48

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

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

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

This method returns an undefined value.

Records a gauge metric

Parameters:

  • the metric name

  • the gauge value

  • (defaults to: nil)

    the metric unit (optional)

  • (defaults to: nil)

    additional attributes for the metric (optional)



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/sentry/metrics.rb', line 30

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

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