Class: Cosmos::MetricModel
Constant Summary
collapse
- PRIMARY_KEY =
'__cosmos__metric'.freeze
Instance Attribute Summary
Attributes inherited from Model
#name, #plugin, #scope, #updated_at
Class Method Summary
collapse
Instance Method Summary
collapse
store
Methods inherited from Model
#as_config, #create, #deploy, #destroy, #destroyed?, filter, find_all_by_plugin, from_json, get_all_models, get_model, handle_config, set, store, #undeploy, #update
Constructor Details
#initialize(name:, scope:, metric_name:, label_list:) ⇒ MetricModel
44
45
46
47
48
|
# File 'lib/cosmos/models/metric_model.rb', line 44
def initialize(name:, scope:, metric_name:, label_list:)
super("#{scope}#{PRIMARY_KEY}", name: name, scope: scope)
@metric_name = metric_name
@label_list = label_list
end
|
Class Method Details
.all(scope:) ⇒ Object
36
37
38
|
# File 'lib/cosmos/models/metric_model.rb', line 36
def self.all(scope:)
super("#{scope}#{PRIMARY_KEY}")
end
|
.destroy(scope:, name:) ⇒ Object
40
41
42
|
# File 'lib/cosmos/models/metric_model.rb', line 40
def self.destroy(scope:, name:)
EphemeralStore.hdel("#{scope}#{PRIMARY_KEY}", name)
end
|
.get(name:, scope:) ⇒ Object
NOTE: The following three class methods are used by the ModelController and are reimplemented to enable various Model class methods to work
28
29
30
|
# File 'lib/cosmos/models/metric_model.rb', line 28
def self.get(name:, scope:)
super("#{scope}#{PRIMARY_KEY}", name: name)
end
|
.names(scope:) ⇒ Object
32
33
34
|
# File 'lib/cosmos/models/metric_model.rb', line 32
def self.names(scope:)
super("#{scope}#{PRIMARY_KEY}")
end
|
Instance Method Details
50
51
52
53
54
55
56
57
|
# File 'lib/cosmos/models/metric_model.rb', line 50
def as_json
{
'name' => @name,
'updated_at' => @updated_at,
'metric_name' => @metric_name,
'label_list' => @label_list
}
end
|