Class: Async::Utilization::Namespace

Inherits:
Object
  • Object
show all
Defined in:
lib/async/utilization/namespace.rb

Overview

A registry-like view that prefixes metric names.

Namespaces let components use generic metric names while applications decide how those names are composed in the shared registry.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(registry, name) ⇒ Namespace

Initialize a new namespace.



17
18
19
20
# File 'lib/async/utilization/namespace.rb', line 17

def initialize(registry, name)
	@registry = registry
	@name = name.to_sym
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



26
27
28
# File 'lib/async/utilization/namespace.rb', line 26

def name
  @name
end

#registryObject (readonly)

Returns the value of attribute registry.



23
24
25
# File 'lib/async/utilization/namespace.rb', line 23

def registry
  @registry
end

#The underlying registry.(underlyingregistry.) ⇒ Object (readonly)



23
# File 'lib/async/utilization/namespace.rb', line 23

attr :registry

Instance Method Details

#metric(name) ⇒ Object

Get a metric in this namespace.



32
33
34
# File 'lib/async/utilization/namespace.rb', line 32

def metric(name)
	@registry.metric(metric_name(name))
end

#namespace(name) ⇒ Object

Get a nested namespace.



40
41
42
# File 'lib/async/utilization/namespace.rb', line 40

def namespace(name)
	self.class.new(@registry, metric_name(name))
end

#The namespace name.=(namespacename. = (value)) ⇒ Object



26
# File 'lib/async/utilization/namespace.rb', line 26

attr :name