Class: Temporalio::Metric::Meter

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

Overview

Meter for creating metrics to record values on. This 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.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.nullMeter

Returns A no-op instance of Temporalio::Metric::Meter.

Returns:



66
67
68
# File 'lib/temporalio/metric.rb', line 66

def self.null
  Internal::Metric::NullMeter.instance
end

Instance Method Details

#create_metric(metric_type, name, description: nil, unit: nil, value_type: :integer) ⇒ Metric

Create a new metric. Only certain metric types are accepted and only value types can work with certain metric types.

Parameters:

  • metric_type (:counter, :histogram, :gauge)

    Metric type. Counters can only have ‘:integer` value types, histograms can have `:integer`, `:float`, or :duration` value types, and gauges can have `:integer` or `:float` value types.

  • name (String)

    Metric name.

  • description (String, nil) (defaults to: nil)

    Metric description.

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

    Metric unit.

  • value_type (:integer, :float, :duration) (defaults to: :integer)

    Metric value type. ‘:integer` works for all metric types, `:float` works for `:histogram` and `:gauge` metric types, and `:duration` only works for `:histogram` metric types.

Returns:

  • (Metric)

    Created metric.

Raises:

  • (NotImplementedError)


88
89
90
91
92
93
94
95
96
# File 'lib/temporalio/metric.rb', line 88

def create_metric(
  metric_type,
  name,
  description: nil,
  unit: nil,
  value_type: :integer
)
  raise NotImplementedError
end

#with_additional_attributes(additional_attributes) ⇒ Meter

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

Parameters:

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

    Attributes to set on the resulting meter.

Returns:

  • (Meter)

    Copy of this meter with the additional attributes.

Raises:

  • (NotImplementedError)


104
105
106
# File 'lib/temporalio/metric.rb', line 104

def with_additional_attributes(additional_attributes)
  raise NotImplementedError
end