Skip to content

Commit

Permalink
Fix default_tags, replace += with <<
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyCTHsu committed Dec 6, 2022
1 parent 87f1a7e commit 6758b47
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/datadog/tracing/contrib/patcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ def on_patch_error(e)
Datadog.health_metrics.error_instrumentation_patch(1, tags: tags)
end

private

def default_tags
["patcher:#{patch_name}"].tap do |tags|
tags << "target_version:#{target_version}" if respond_to?(:target_version) && !target_version.nil?
tags += super if defined?(super)
super.each { |t| tags << t } if defined?(super)
end
end

private

def patch_only_once
# NOTE: This is not thread-safe
@patch_only_once ||= Core::Utils::OnlyOnce.new
Expand Down
23 changes: 23 additions & 0 deletions spec/datadog/tracing/contrib/redis/patcher_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# typed: ignore

require 'datadog/tracing/contrib/support/spec_helper'

require 'datadog/tracing/contrib/redis/patcher'

RSpec.describe Datadog::Tracing::Contrib::Redis::Patcher do
describe '.default_tags' do
it do
result = described_class.default_tags

expect(result).to include(start_with('patcher:'))

if Datadog::Tracing::Contrib::Redis::Integration.redis_version
expect(result).to include(start_with('target_redis_version:'))
end

if Datadog::Tracing::Contrib::Redis::Integration.redis_client_version
expect(result).to include(start_with('target_redis_client_version:'))
end
end
end
end

0 comments on commit 6758b47

Please sign in to comment.