-
Notifications
You must be signed in to change notification settings - Fork 256
/
Copy pathobservable_counter.rb
41 lines (36 loc) · 1.51 KB
/
observable_counter.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# frozen_string_literal: true
# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0
module OpenTelemetry
module SDK
module Metrics
module Instrument
# {ObservableCounter} is the SDK implementation of {OpenTelemetry::SDK::Metrics::Instrument::AsynchronousInstrument}.
# Asynchronous Counter is an asynchronous Instrument which reports monotonically increasing value(s) when the instrument is being observed.
class ObservableCounter < OpenTelemetry::SDK::Metrics::Instrument::AsynchronousInstrument
# Returns the instrument kind as a Symbol
#
# @return [Symbol]
def instrument_kind
:observable_counter
end
# Observe the ObservableCounter with fixed timeout duartion.
#
# @param [int] timeout The timeout duration for callback to run, which MUST be a non-negative numeric value.
# @param [Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}] attributes
# Values must be non-nil and (array of) string, boolean or numeric type.
# Array values must not contain nil elements and all elements must be of
# the same basic type (string, numeric, boolean).
def observe(timeout: nil, attributes: {})
update(timeout, attributes)
end
private
def default_aggregation
OpenTelemetry::SDK::Metrics::Aggregation::Sum.new
end
end
end
end
end
end