Make sure the namespace metric is send to the plugin correctly and MetricType#To_hash wont return all the values

Fixes: #5529

Fixes #5532
This commit is contained in:
Pier-Hugues Pellerin 2016-06-21 16:12:23 -04:00
parent 72b277404b
commit 1dd44383c7
5 changed files with 6 additions and 15 deletions

View file

@ -22,7 +22,7 @@ module LogStash
# Scope the metrics to the plugin
namespaced_metric = metric.namespace(@filter.plugin_unique_name.to_sym)
@filter.metric = metric
@filter.metric = namespaced_metric
@metric_events = namespaced_metric.namespace(:events)
namespaced_metric.gauge(:name, config_name)

View file

@ -17,10 +17,7 @@ module LogStash module Instrument module MetricType
def to_hash
{
"namespaces" => namespaces,
"key" => key,
"type" => type,
"value" => value
key => value
}
end

View file

@ -27,6 +27,8 @@ module LogStash class OutputDelegator
# Scope the metrics to the plugin
namespaced_metric = metric.namespace(output.plugin_unique_name.to_sym)
output.metric = namespaced_metric
@metric_events = namespaced_metric.namespace(:events)
namespaced_metric.gauge(:name, config_name)

View file

@ -28,12 +28,7 @@ describe LogStash::Instrument::MetricType::Counter do
context "When creating a hash " do
it "creates the hash from all the values" do
metric_hash = {
"key" => key,
"namespaces" => namespaces,
"value" => 0,
"type" => "counter"
}
metric_hash = { key => 0 }
expect(subject.to_hash).to match(metric_hash)
end
end

View file

@ -29,10 +29,7 @@ describe LogStash::Instrument::MetricType::Gauge do
context "When creating a hash " do
it "creates the hash from all the values" do
metric_hash = {
"key" => key,
"namespaces" => namespaces,
"value" => value,
"type" => "gauge"
key => value
}
expect(subject.to_hash).to match(metric_hash)
end