Namespace should use a copy of the arrays when creating a sub space

Fix: #5510

Fixes #5513
This commit is contained in:
Pier-Hugues Pellerin 2016-06-16 13:55:23 -04:00 committed by Jordan Sissel
parent 74672c994b
commit 73c1e68050
2 changed files with 8 additions and 1 deletions

View file

@ -45,7 +45,7 @@ module LogStash module Instrument
end
def namespace(name)
NamespacedMetric.new(metric, namespace_name.concat(Array(name)))
NamespacedMetric.new(metric, namespace_name + Array(name))
end
private

View file

@ -22,4 +22,11 @@ describe LogStash::Instrument::NamespacedMetric do
it "returns the value of the block" do
expect(subject.time(:duration_ms) { "hello" }).to eq("hello")
end
it "its doesnt change the original `namespace` when creating a subnamespace" do
new_namespace = subject.namespace(:wally)
expect(subject.namespace_name).to eq([namespace])
expect(new_namespace.namespace_name).to eq([:stats, :wally])
end
end