Module: Sentry::Metrics
- Defined in:
- lib/sentry/metrics.rb,
lib/sentry/metrics/metric.rb,
lib/sentry/metrics/timing.rb,
lib/sentry/metrics/aggregator.rb,
lib/sentry/metrics/set_metric.rb,
lib/sentry/metrics/gauge_metric.rb,
lib/sentry/metrics/configuration.rb,
lib/sentry/metrics/counter_metric.rb,
lib/sentry/metrics/local_aggregator.rb,
lib/sentry/metrics/distribution_metric.rb more...
Defined Under Namespace
Modules: Timing Classes: Aggregator, Configuration, CounterMetric, DistributionMetric, GaugeMetric, LocalAggregator, Metric, SetMetric
Constant Summary collapse
- DURATION_UNITS =
%w[nanosecond microsecond millisecond second minute hour day week]
- INFORMATION_UNITS =
%w[bit byte kilobyte kibibyte megabyte mebibyte gigabyte gibibyte terabyte tebibyte petabyte pebibyte exabyte exbibyte]
- FRACTIONAL_UNITS =
%w[ratio percent]
- OP_NAME =
"metric.timing"
- SPAN_ORIGIN =
"auto.metric.timing"
Class Method Summary collapse
- .distribution(key, value, unit: "none", tags: {}, timestamp: nil) ⇒ Object
- .gauge(key, value, unit: "none", tags: {}, timestamp: nil) ⇒ Object
- .increment(key, value = 1.0, unit: "none", tags: {}, timestamp: nil) ⇒ Object
- .set(key, value, unit: "none", tags: {}, timestamp: nil) ⇒ Object
- .timing(key, unit: "second", tags: {}, timestamp: nil, &block) ⇒ Object
Class Method Details
permalink .distribution(key, value, unit: "none", tags: {}, timestamp: nil) ⇒ Object
[View source]
25 26 27 |
# File 'lib/sentry/metrics.rb', line 25 def distribution(key, value, unit: "none", tags: {}, timestamp: nil) Sentry.metrics_aggregator&.add(:d, key, value, unit: unit, tags: , timestamp: ) end |
permalink .gauge(key, value, unit: "none", tags: {}, timestamp: nil) ⇒ Object
[View source]
33 34 35 |
# File 'lib/sentry/metrics.rb', line 33 def gauge(key, value, unit: "none", tags: {}, timestamp: nil) Sentry.metrics_aggregator&.add(:g, key, value, unit: unit, tags: , timestamp: ) end |
permalink .increment(key, value = 1.0, unit: "none", tags: {}, timestamp: nil) ⇒ Object
[View source]
21 22 23 |
# File 'lib/sentry/metrics.rb', line 21 def increment(key, value = 1.0, unit: "none", tags: {}, timestamp: nil) Sentry.metrics_aggregator&.add(:c, key, value, unit: unit, tags: , timestamp: ) end |
permalink .set(key, value, unit: "none", tags: {}, timestamp: nil) ⇒ Object
[View source]
29 30 31 |
# File 'lib/sentry/metrics.rb', line 29 def set(key, value, unit: "none", tags: {}, timestamp: nil) Sentry.metrics_aggregator&.add(:s, key, value, unit: unit, tags: , timestamp: ) end |
permalink .timing(key, unit: "second", tags: {}, timestamp: nil, &block) ⇒ Object
[View source]
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/sentry/metrics.rb', line 37 def timing(key, unit: "second", tags: {}, timestamp: nil, &block) return unless block_given? return yield unless DURATION_UNITS.include?(unit) result, value = Sentry.with_child_span(op: OP_NAME, description: key, origin: SPAN_ORIGIN) do |span| .each { |k, v| span.set_tag(k, v.is_a?(Array) ? v.join(", ") : v.to_s) } if span start = Timing.send(unit.to_sym) result = yield value = Timing.send(unit.to_sym) - start [result, value] end Sentry.metrics_aggregator&.add(:d, key, value, unit: unit, tags: , timestamp: ) result end |