Class: Temporalio::Metric

Inherits:
Object
  • Object
show all
Defined in:
lib/temporalio/metric.rb

Overview

Metric that can be recorded from a metric meter. This is obtained via Meter#create_metric. The metric meter is obtained via workflow environment, activity context, or from the Runtime if in neither of those. This class is effectively abstract and will fail if ‘initialize` is attempted.

Defined Under Namespace

Classes: Meter

Instance Method Summary collapse

Instance Method Details

#descriptionString?

Returns Metric description.

Returns:

  • (String, nil)

    Metric description.

Raises:

  • (NotImplementedError)


47
48
49
# File 'lib/temporalio/metric.rb', line 47

def description
  raise NotImplementedError
end

#metric_type:counter, ...

Returns Metric type.

Returns:

  • (:counter, :histogram, :gauge)

    Metric type.

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/temporalio/metric.rb', line 37

def metric_type
  raise NotImplementedError
end

#nameString

Returns Metric name.

Returns:

  • (String)

    Metric name.

Raises:

  • (NotImplementedError)


42
43
44
# File 'lib/temporalio/metric.rb', line 42

def name
  raise NotImplementedError
end

#record(value, additional_attributes: nil) ⇒ Object

Record a value for the metric. For counters, this adds to any existing. For histograms, this records into proper buckets. For gauges, this sets the value. The value type must match the expectation.

Parameters:

  • value (Numeric)

    Value to record. For counters and duration-based histograms, this value cannot be negative.

  • additional_attributes (Hash{String, Symbol => String, Integer, Float, Boolean}, nil) (defaults to: nil)

    Additional attributes on this specific record. For better performance for attribute reuse, users are encouraged to use #with_additional_attributes to make a copy of this metric with those attributes.

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/temporalio/metric.rb', line 22

def record(value, additional_attributes: nil)
  raise NotImplementedError
end

#unitString?

Returns Metric unit.

Returns:

  • (String, nil)

    Metric unit.

Raises:

  • (NotImplementedError)


52
53
54
# File 'lib/temporalio/metric.rb', line 52

def unit
  raise NotImplementedError
end

#value_type:integer, ...

Returns Metric value type.

Returns:

  • (:integer, :float, :duration)

    Metric value type.

Raises:

  • (NotImplementedError)


57
58
59
# File 'lib/temporalio/metric.rb', line 57

def value_type
  raise NotImplementedError
end

#with_additional_attributes(additional_attributes) ⇒ Metric

Create a copy of this metric but with the given additional attributes. This is more performant than providing attributes on each #record call.

Parameters:

  • additional_attributes (Hash{String, Symbol => String, Integer, Float, Boolean})

    Attributes to set on the resulting metric.

Returns:

  • (Metric)

    Copy of this metric with the additional attributes.

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/temporalio/metric.rb', line 32

def with_additional_attributes(additional_attributes)
  raise NotImplementedError
end