Skip to content

Commit

Permalink
Merge pull request #2365 from DataDog/zarir/spankind-server-client
Browse files Browse the repository at this point in the history
Unified tagging `span.kind` as `server` and `client`
  • Loading branch information
TonyCTHsu authored Nov 17, 2022
2 parents dc92156 + 74d982b commit ade3d37
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 0 deletions.
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') }

it 'has component and operation tags' do
expect(span.get_tag(Datadog::Tracing::Metadata::Ext::TAG_COMPONENT)).to eq('grpc')
Expand Down Expand Up @@ -80,6 +81,7 @@
expect(span).to have_error_type('TestError')
expect(span).to have_error_stack(include('server_spec.rb'))
expect(span.get_tag('rpc.system')).to eq 'grpc'
expect(span.get_tag('span.kind')).to eq('server')
end
end

Expand All @@ -97,6 +99,7 @@
expect(span).to_not have_error
expect(span.get_tag('custom.handler')).to eq('Got error test error, but ignored it')
expect(span.get_tag('rpc.system')).to eq('grpc')
expect(span.get_tag('span.kind')).to eq('server')
end
end
end
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('span.kind')).to eq('client')
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('span.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('span.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('span.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('span.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('span.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('span.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('span.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('span.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('span.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('span.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('span.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('span.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('span.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('span.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('span.kind')).to eq('server')
end
end
end
Expand Down

0 comments on commit ade3d37

Please sign in to comment.