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

Unified tagging span.kind as server and client #2365

Merged
merged 6 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def annotate!(span, metadata)
span.set_tag(header, value)
end

span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_SERVER)

span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_SERVICE)

Expand Down
2 changes: 2 additions & 0 deletions lib/datadog/tracing/contrib/mongodb/subscribers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def started(event)

span.set_tag(Contrib::Ext::DB::TAG_SYSTEM, Ext::TAG_SYSTEM)

span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CLIENT)

span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_COMMAND)

Expand Down
2 changes: 2 additions & 0 deletions lib/datadog/tracing/contrib/rack/middlewares.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def compute_queue_time(env)
# Tag this span as belonging to Rack
frontend_span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
frontend_span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_HTTP_SERVER_QUEUE)
frontend_span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_SERVER)

# Set peer service (so its not believed to belong to this app)
frontend_span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, configuration[:web_service_name])
Expand Down Expand Up @@ -157,6 +158,7 @@ def set_request_tags!(trace, request_span, env, status, headers, response, origi

request_span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
request_span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_REQUEST)
request_span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_SERVER)

# Set analytics sample rate
if Contrib::Analytics.enabled?(configuration[:analytics_enabled])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
it { expect(span.get_tag('rpc.system')).to eq 'grpc' }
it { expect(span.get_tag('rpc.service')).to eq 'My::Server' }
it { expect(span.get_tag('rpc.method')).to eq 'endpoint' }
it { expect(span.get_tag('span.kind')).to eq('server') }
zarirhamza marked this conversation as resolved.
Show resolved Hide resolved

it 'has component and operation tags' do
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT)).to eq('grpc')
Expand Down
1 change: 1 addition & 0 deletions spec/datadog/tracing/contrib/mongodb/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
expect(span.get_tag('out.port')).to eq(port)
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT)).to eq('mongodb')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION)).to eq('command')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_KIND)).to eq('client')
zarirhamza marked this conversation as resolved.
Show resolved Hide resolved
end

it_behaves_like 'analytics for integration' do
Expand Down
26 changes: 26 additions & 0 deletions spec/datadog/tracing/contrib/rack/integration_test_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
expect(span.status).to eq(0)
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT)).to eq('rack')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION)).to eq('request')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_KIND)).to eq('server')
end
end

Expand Down Expand Up @@ -77,6 +78,8 @@
.to eq('rack')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION))
.to eq('request')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_KIND))
.to eq('server')
end
end
end
Expand Down Expand Up @@ -286,6 +289,8 @@
.to eq('rack')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION))
.to eq('request')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_KIND))
.to eq('server')
end
end
end
Expand Down Expand Up @@ -322,6 +327,8 @@
expect(web_server_span.get_tag('operation')).to eq('queue')
expect(web_server_span.get_tag('peer.service')).to eq('web-server')
expect(web_server_span.status).to eq(0)
expect(web_server_span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_KIND))
.to eq('server')

expect(rack_span.span_type).to eq('web')
expect(rack_span.service).to eq(tracer.default_service)
Expand All @@ -331,6 +338,8 @@
expect(rack_span.status).to eq(0)
expect(rack_span.get_tag('component')).to eq('rack')
expect(rack_span.get_tag('operation')).to eq('request')
expect(rack_span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_KIND))
.to eq('server')
end
end
end
Expand Down Expand Up @@ -367,6 +376,8 @@
.to eq('rack')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION))
.to eq('request')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_KIND))
.to eq('server')
end
end
end
Expand Down Expand Up @@ -404,6 +415,8 @@
.to eq('rack')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION))
.to eq('request')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_KIND))
.to eq('server')
end
end
end
Expand Down Expand Up @@ -444,6 +457,8 @@
.to eq('rack')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION))
.to eq('request')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_KIND))
.to eq('server')
end
end
end
Expand Down Expand Up @@ -483,6 +498,8 @@
.to eq('rack')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION))
.to eq('request')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_KIND))
.to eq('server')
end
end
end
Expand Down Expand Up @@ -538,6 +555,8 @@
.to eq('rack')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION))
.to eq('request')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_KIND))
.to eq('server')
end
end
end
Expand Down Expand Up @@ -582,6 +601,7 @@
expect(web_server_span.get_tag('operation')).to eq('queue')
expect(web_server_span.get_tag('peer.service')).to eq('web-server')
expect(web_server_span.status).to eq(0)
expect(web_server_span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_KIND)).to eq('server')

expect(rack_span.span_type).to eq('web')
expect(rack_span.service).to eq(tracer.default_service)
Expand All @@ -591,6 +611,7 @@
expect(rack_span.status).to eq(0)
expect(rack_span.get_tag('component')).to eq('rack')
expect(rack_span.get_tag('operation')).to eq('request')
expect(rack_span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_KIND)).to eq('server')

expect(nested_app_span.resource).to eq('UserController#show')
end
Expand Down Expand Up @@ -640,6 +661,8 @@
.to eq('rack')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION))
.to eq('request')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_KIND))
.to eq('server')
end
end
end
Expand Down Expand Up @@ -681,6 +704,8 @@
.to eq('rack')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION))
.to eq('request')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_KIND))
.to eq('server')
end
end
end
Expand Down Expand Up @@ -891,6 +916,7 @@
expect(span.status).to eq(0)
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT)).to eq('rack')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_OPERATION)).to eq('request')
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_KIND)).to eq('server')
end
end
end
Expand Down