Class: OpenCensus::Stats::MeasureRegistry

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/opencensus/stats/measure_registry.rb

Overview

MeasureRegistry

Measure registry is a collection of uniq measures.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#measuresHash<String, Measure> (readonly)

Returns:



17
18
19
# File 'lib/opencensus/stats/measure_registry.rb', line 17

def measures
  @measures
end

Class Method Details

.clearObject

Clear measures registry



54
55
56
# File 'lib/opencensus/stats/measure_registry.rb', line 54

def clear
  instance.measures.clear
end

.get(name) ⇒ Measure

Get registered measure

Returns:



60
61
62
# File 'lib/opencensus/stats/measure_registry.rb', line 60

def get name
  instance.measures[name]
end

.measuresArray<Measure>

List of registered measures

Returns:



66
67
68
# File 'lib/opencensus/stats/measure_registry.rb', line 66

def measures
  instance.measures.values
end

.register(name:, unit:, type:, description: nil) ⇒ Measure?

Register measure.

Parameters:

  • name (String)

    Name of measure

  • unit (String)

    Unit name of measure

  • type (String)

    Date type unit of measure. integer or float.

  • description (String) (defaults to: nil)

    Description of measure

Returns:



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/opencensus/stats/measure_registry.rb', line 33

def register name:, unit:, type:, description: nil
  return if instance.measures.key? name

  measure = Measure.new(
    name: name,
    unit: unit,
    type: type,
    description: description
  )

  instance.measures[name] = measure
end

.unregister(name) ⇒ Object

Un register measure

Parameters:

  • name (String)

    Name of the registered view



49
50
51
# File 'lib/opencensus/stats/measure_registry.rb', line 49

def unregister name
  instance.measures.delete name
end