Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds span.kind as client for redis #2392

Merged
merged 1 commit into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/datadog/tracing/contrib/redis/instrumentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def call(*args, &block)
span.span_type = Contrib::Redis::Ext::TYPE
span.resource = get_command(args)
Contrib::Redis::Tags.set_common_tags(self, span)
span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CLIENT)

response = super
end
Expand All @@ -43,6 +44,7 @@ def call_pipeline(*args, &block)
span.resource = commands.any? ? commands.join("\n") : '(none)'
span.set_metric Contrib::Redis::Ext::METRIC_PIPELINE_LEN, commands.length
Contrib::Redis::Tags.set_common_tags(self, span)
span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CLIENT)

response = super
end
Expand Down
4 changes: 4 additions & 0 deletions spec/datadog/tracing/contrib/redis/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
port: test_port,
db: test_database
)

expect(span.get_tag('span.kind')).to eq('client')
end
end
end
Expand Down Expand Up @@ -147,6 +149,8 @@
port: test_port,
db: test_database
)

expect(span.get_tag('span.kind')).to eq('client')
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions spec/datadog/tracing/contrib/redis/miniapp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@
expect(redis_cmd1_span.parent_id).to eq(process_span.span_id)
expect(redis_cmd1_span.trace_id).to eq(publish_span.trace_id)
expect(redis_cmd1_span.get_tag('db.system')).to eq('redis')
expect(redis_cmd2_span.get_tag('span.kind')).to eq('client')

expect(redis_cmd2_span.name).to eq('redis.command')
expect(redis_cmd2_span.service).to eq('test-service')
expect(redis_cmd2_span.parent_id).to eq(process_span.span_id)
expect(redis_cmd2_span.trace_id).to eq(publish_span.trace_id)
expect(redis_cmd2_span.get_tag('db.system')).to eq('redis')
expect(redis_cmd2_span.get_tag('span.kind')).to eq('client')
end

it_behaves_like 'a peer service span' do
Expand Down
11 changes: 11 additions & 0 deletions spec/datadog/tracing/contrib/redis/redis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
expect(span.resource).to eq('SET FOO bar')
expect(span.get_tag('redis.raw_command')).to eq('SET FOO bar')
expect(span.get_tag('db.system')).to eq('redis')
expect(span.get_tag('span.kind')).to eq('client')
end

it_behaves_like 'a span with common tags'
Expand All @@ -104,6 +105,7 @@
expect(span.resource).to eq('GET FOO')
expect(span.get_tag('redis.raw_command')).to eq('GET FOO')
expect(span.get_tag('db.system')).to eq('redis')
expect(span.get_tag('span.kind')).to eq('client')
end

it_behaves_like 'a span with common tags'
Expand All @@ -127,6 +129,7 @@
expect(span.resource).to eq('SET FOO bar')
expect(span.get_tag('redis.raw_command')).to eq('SET FOO bar')
expect(span.get_tag('db.system')).to eq('redis')
expect(span.get_tag('span.kind')).to eq('client')
end
end
end
Expand All @@ -147,6 +150,7 @@
expect(span.resource).to eq('SET')
expect(span.get_tag('redis.raw_command')).to be_nil
expect(span.get_tag('db.system')).to eq('redis')
expect(span.get_tag('span.kind')).to eq('client')
end
end
end
Expand Down Expand Up @@ -179,6 +183,7 @@
expect(span.resource).to eq("SET v1 0\nSET v2 0\nINCR v1\nINCR v2\nINCR v2")
expect(span.get_tag('redis.raw_command')).to eq("SET v1 0\nSET v2 0\nINCR v1\nINCR v2\nINCR v2")
expect(span.get_tag('db.system')).to eq('redis')
expect(span.get_tag('span.kind')).to eq('client')
end

it_behaves_like 'a span with common tags'
Expand All @@ -199,6 +204,7 @@
expect(span.resource).to eq("SET\nSET\nINCR\nINCR\nINCR")
expect(span.get_tag('redis.raw_command')).to be_nil
expect(span.get_tag('db.system')).to eq('redis')
expect(span.get_tag('span.kind')).to eq('client')
end
end
end
Expand All @@ -225,6 +231,7 @@
expect(span.resource).to eq('(none)')
expect(span.get_tag('redis.raw_command')).to eq('(none)')
expect(span.get_tag('db.system')).to eq('redis')
expect(span.get_tag('span.kind')).to eq('client')
end

it_behaves_like 'a span with common tags'
Expand Down Expand Up @@ -257,6 +264,7 @@
expect(span.get_tag('error.msg')).to match(/ERR unknown command/)
expect(span.get_tag('error.type')).to eq('Redis::CommandError')
expect(span.get_tag('error.stack').length).to be >= 3
expect(span.get_tag('span.kind')).to eq('client')
end

it_behaves_like 'a span with common tags'
Expand All @@ -276,6 +284,7 @@
expect(span.resource).to eq("SET K #{'x' * 47}...")
expect(span.get_tag('db.system')).to eq('redis')
expect(span.get_tag('redis.raw_command')).to eq("SET K #{'x' * 47}...")
expect(span.get_tag('span.kind')).to eq('client')
end

it_behaves_like 'a span with common tags'
Expand All @@ -299,6 +308,7 @@
expect(span.resource).to eq('GET K')
expect(span.get_tag('redis.raw_command')).to eq('GET K')
expect(span.get_tag('db.system')).to eq('redis')
expect(span.get_tag('span.kind')).to eq('client')
end

it_behaves_like 'a span with common tags'
Expand All @@ -318,6 +328,7 @@
expect(span.resource).to eq('AUTH ?')
expect(span.get_tag('redis.raw_command')).to eq('AUTH ?')
expect(span.get_tag('db.system')).to eq('redis')
expect(span.get_tag('span.kind')).to eq('client')
end

it_behaves_like 'a peer service span' do
Expand Down