Skip to content

Commit

Permalink
use SpanOperation#set_tags, do not synchronize methods that set multi…
Browse files Browse the repository at this point in the history
…ple tags one by one
  • Loading branch information
anmarchenko committed Nov 24, 2023
1 parent c60cf73 commit 93138cf
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
8 changes: 0 additions & 8 deletions lib/datadog/ci/concurrent_span.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@ def set_tags(tags)
synchronize { super }
end

def set_environment_runtime_tags
synchronize { super }
end

def set_default_tags
synchronize { super }
end

def synchronize
@mutex.synchronize { yield }
end
Expand Down
4 changes: 1 addition & 3 deletions lib/datadog/ci/span.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ def finish
# @param [Hash[String, String]] tags the tags to set.
# @return [void]
def set_tags(tags)
tags.each do |key, value|
tracer_span.set_tag(key, value)
end
tracer_span.set_tags(tags)
end

def set_environment_runtime_tags
Expand Down
3 changes: 1 addition & 2 deletions spec/datadog/ci/span_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@

describe "#set_tags" do
it "sets the tags" do
expect(tracer_span).to receive(:set_tag).with("foo", "bar")
expect(tracer_span).to receive(:set_tag).with("baz", "qux")
expect(tracer_span).to receive(:set_tags).with({"foo" => "bar", "baz" => "qux"})

span.set_tags("foo" => "bar", "baz" => "qux")
end
Expand Down

0 comments on commit 93138cf

Please sign in to comment.