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

Change span types for HTTP, web, and some datastore integrations #751

Merged
merged 1 commit into from
May 10, 2019
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
1 change: 1 addition & 0 deletions lib/ddtrace/contrib/dalli/ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module Ext
QUANTIZE_MAX_CMD_LENGTH = 100
SERVICE_NAME = 'memcached'.freeze
SPAN_COMMAND = 'memcached.command'.freeze
SPAN_TYPE_COMMAND = 'memcached'.freeze
TAG_COMMAND = 'memcached.command'.freeze
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/ddtrace/contrib/dalli/instrumentation.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'ddtrace/ext/app_types'
require 'ddtrace/ext/net'
require 'ddtrace/contrib/analytics'
require 'ddtrace/contrib/dalli/ext'
require 'ddtrace/contrib/dalli/quantize'

module Datadog
Expand Down Expand Up @@ -35,7 +35,7 @@ def request(op, *args)
tracer.trace(Datadog::Contrib::Dalli::Ext::SPAN_COMMAND) do |span|
span.resource = op.to_s.upcase
span.service = datadog_configuration[:service_name]
span.span_type = Datadog::Ext::AppTypes::CACHE
span.span_type = Datadog::Contrib::Dalli::Ext::SPAN_TYPE_COMMAND

# Set analytics sample rate
if Contrib::Analytics.enabled?(datadog_configuration[:analytics_enabled])
Expand Down
1 change: 1 addition & 0 deletions lib/ddtrace/contrib/elasticsearch/ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Ext
ENV_ANALYTICS_SAMPLE_RATE = 'DD_ELASTICSEARCH_ANALYTICS_SAMPLE_RATE'.freeze
SERVICE_NAME = 'elasticsearch'.freeze
SPAN_QUERY = 'elasticsearch.query'.freeze
SPAN_TYPE_QUERY = 'elasticsearch'.freeze
TAG_BODY = 'elasticsearch.body'.freeze
TAG_METHOD = 'elasticsearch.method'.freeze
TAG_PARAMS = 'elasticsearch.params'.freeze
Expand Down
2 changes: 1 addition & 1 deletion lib/ddtrace/contrib/elasticsearch/patcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def perform_request(*args)
port = connection.host[:port] if connection

span.service = pin.service
span.span_type = Datadog::Ext::AppTypes::DB
span.span_type = Datadog::Contrib::Elasticsearch::Ext::SPAN_TYPE_QUERY

# load JSON for the following fields unless they're already strings
params = JSON.generate(params) if params && !params.is_a?(String)
Expand Down
2 changes: 1 addition & 1 deletion lib/ddtrace/contrib/excon/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def split_by_domain?
def annotate!(span, datum)
span.resource = datum[:method].to_s.upcase
span.service = service_name(datum)
span.span_type = Datadog::Ext::HTTP::TYPE
span.span_type = Datadog::Ext::HTTP::TYPE_OUTBOUND

# Set analytics sample rate
if analytics_enabled?
Expand Down
2 changes: 1 addition & 1 deletion lib/ddtrace/contrib/faraday/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def call(env)
def annotate!(span, env)
span.resource = env[:method].to_s.upcase
span.service = service_name(env)
span.span_type = Datadog::Ext::HTTP::TYPE
span.span_type = Datadog::Ext::HTTP::TYPE_OUTBOUND

# Set analytics sample rate
if analytics_enabled?
Expand Down
6 changes: 3 additions & 3 deletions lib/ddtrace/contrib/grape/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def endpoint_start_process(*)
tracer.trace(
Ext::SPAN_ENDPOINT_RUN,
service: service_name,
span_type: Datadog::Ext::HTTP::TYPE
span_type: Datadog::Ext::HTTP::TYPE_INBOUND
)

Thread.current[KEY_RUN] = true
Expand Down Expand Up @@ -107,7 +107,7 @@ def endpoint_start_render(*)
tracer.trace(
Ext::SPAN_ENDPOINT_RENDER,
service: service_name,
span_type: Datadog::Ext::HTTP::TYPE
span_type: Datadog::Ext::HTTP::TEMPLATE
)

Thread.current[KEY_RENDER] = true
Expand Down Expand Up @@ -147,7 +147,7 @@ def endpoint_run_filters(name, start, finish, id, payload)
span = tracer.trace(
Ext::SPAN_ENDPOINT_RUN_FILTERS,
service: service_name,
span_type: Datadog::Ext::HTTP::TYPE
span_type: Datadog::Ext::HTTP::TYPE_INBOUND
)

begin
Expand Down
2 changes: 1 addition & 1 deletion lib/ddtrace/contrib/grpc/datadog_interceptor/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def trace(keywords)
keywords[:metadata] ||= {}

options = {
span_type: Datadog::Ext::HTTP::TYPE,
span_type: Datadog::Ext::HTTP::TYPE_OUTBOUND,
service: service_name,
resource: format_resource(keywords[:method])
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module DatadogInterceptor
class Server < Base
def trace(keywords)
options = {
span_type: Datadog::Ext::HTTP::TYPE,
span_type: Datadog::Ext::HTTP::TYPE_INBOUND,
service: service_name,
resource: format_resource(keywords[:method])
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ddtrace/contrib/http/instrumentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def request(req, body = nil, &block) # :yield: +response+
pin.tracer.trace(Ext::SPAN_REQUEST) do |span|
begin
span.service = pin.service
span.span_type = Datadog::Ext::HTTP::TYPE
span.span_type = Datadog::Ext::HTTP::TYPE_OUTBOUND
span.resource = req.method

if pin.tracer.enabled && !Datadog::Contrib::HTTP.should_skip_distributed_tracing?(pin)
Expand Down
3 changes: 2 additions & 1 deletion lib/ddtrace/contrib/rack/middlewares.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def compute_queue_time(env, tracer)

tracer.trace(
Ext::SPAN_HTTP_SERVER_QUEUE,
span_type: Datadog::Ext::HTTP::TYPE_PROXY,
start_time: request_start,
service: configuration[:web_service_name]
)
Expand All @@ -57,7 +58,7 @@ def call(env)
trace_options = {
service: configuration[:service_name],
resource: nil,
span_type: Datadog::Ext::HTTP::TYPE
span_type: Datadog::Ext::HTTP::TYPE_INBOUND
}

# start a new request span and attach it to the current Rack environment;
Expand Down
2 changes: 1 addition & 1 deletion lib/ddtrace/contrib/rails/action_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def self.start_processing(payload)
# trace the execution
tracer = Datadog.configuration[:rails][:tracer]
service = Datadog.configuration[:rails][:controller_service]
type = Datadog::Ext::HTTP::TYPE
type = Datadog::Ext::HTTP::TYPE_INBOUND
span = tracer.trace(Ext::SPAN_ACTION_CONTROLLER, service: service, span_type: type)

# attach the current span to the tracing context
Expand Down
2 changes: 1 addition & 1 deletion lib/ddtrace/contrib/rest_client/request_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def datadog_tag_request(uri, span)
def datadog_trace_request(uri)
span = datadog_configuration[:tracer].trace(Ext::SPAN_REQUEST,
service: datadog_configuration[:service_name],
span_type: Datadog::Ext::AppTypes::WEB)
span_type: Datadog::Ext::HTTP::TYPE_OUTBOUND)

datadog_tag_request(uri, span)

Expand Down
2 changes: 1 addition & 1 deletion lib/ddtrace/contrib/sinatra/tracer_middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def call(env)
tracer.trace(
Ext::SPAN_REQUEST,
service: configuration[:service_name],
span_type: Datadog::Ext::HTTP::TYPE
span_type: Datadog::Ext::HTTP::TYPE_INBOUND
) do |span|
Sinatra::Env.set_datadog_span(env, span)

Expand Down
4 changes: 3 additions & 1 deletion lib/ddtrace/ext/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ module HTTP
METHOD = 'http.method'.freeze
STATUS_CODE = 'http.status_code'.freeze
TEMPLATE = 'template'.freeze
TYPE = 'http'.freeze
TYPE_INBOUND = 'web'.freeze
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, I like this distinction "inbound" vs "outbound", makes more sense than "web" vs "http"

TYPE_OUTBOUND = 'http'.freeze
TYPE_PROXY = 'proxy'.freeze
URL = 'http.url'.freeze

# General header functionality
Expand Down
1 change: 1 addition & 0 deletions spec/ddtrace/contrib/dalli/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def all_spans
expect(all_spans.size).to eq(1)
expect(span.service).to eq('memcached')
expect(span.name).to eq('memcached.command')
expect(span.span_type).to eq('memcached')
expect(span.resource).to eq('SET')
expect(span.get_tag('memcached.command')).to eq('set abc 123 0 0')
expect(span.get_tag('out.host')).to eq(test_host)
Expand Down
3 changes: 3 additions & 0 deletions spec/ddtrace/contrib/elasticsearch/patcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
it { expect(span.name).to eq('elasticsearch.query') }
it { expect(span.service).to eq('elasticsearch') }
it { expect(span.resource).to eq('GET _cluster/health') }
it { expect(span.span_type).to eq('elasticsearch') }
it { expect(span.parent_id).not_to be_nil }
it { expect(span.trace_id).not_to be_nil }
end
Expand All @@ -80,6 +81,7 @@
it { expect(span.name).to eq('elasticsearch.query') }
it { expect(span.service).to eq('elasticsearch') }
it { expect(span.resource).to eq('GET _cluster/health') }
it { expect(span.span_type).to eq('elasticsearch') }
it { expect(span.parent_id).not_to be_nil }
it { expect(span.trace_id).not_to be_nil }
end
Expand Down Expand Up @@ -120,6 +122,7 @@

it { expect(span.name).to eq('elasticsearch.query') }
it { expect(span.service).to eq('elasticsearch') }
it { expect(span.span_type).to eq('elasticsearch') }
it { expect(span.resource).to eq('PUT some_index/type/?') }

it { expect(span.parent_id).not_to be_nil }
Expand Down
4 changes: 2 additions & 2 deletions spec/ddtrace/contrib/excon/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
expect(request_span.get_tag(Datadog::Ext::HTTP::URL)).to eq('/success')
expect(request_span.get_tag(Datadog::Ext::NET::TARGET_HOST)).to eq('example.com')
expect(request_span.get_tag(Datadog::Ext::NET::TARGET_PORT)).to eq('80')
expect(request_span.span_type).to eq(Datadog::Ext::HTTP::TYPE)
expect(request_span.span_type).to eq(Datadog::Ext::HTTP::TYPE_OUTBOUND)
expect(request_span.status).to_not eq(Datadog::Ext::Errors::STATUS)
end
end
Expand All @@ -112,7 +112,7 @@
expect(request_span.get_tag(Datadog::Ext::HTTP::STATUS_CODE)).to eq('500')
expect(request_span.get_tag(Datadog::Ext::NET::TARGET_HOST)).to eq('example.com')
expect(request_span.get_tag(Datadog::Ext::NET::TARGET_PORT)).to eq('80')
expect(request_span.span_type).to eq(Datadog::Ext::HTTP::TYPE)
expect(request_span.span_type).to eq(Datadog::Ext::HTTP::TYPE_OUTBOUND)
expect(request_span.status).to eq(Datadog::Ext::Errors::STATUS)
expect(request_span.get_tag(Datadog::Ext::Errors::TYPE)).to eq('Error 500')
expect(request_span.get_tag(Datadog::Ext::Errors::MSG)).to eq('Boom!')
Expand Down
4 changes: 2 additions & 2 deletions spec/ddtrace/contrib/faraday/middleware_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
expect(request_span.get_tag(Datadog::Ext::HTTP::URL)).to eq('/success')
expect(request_span.get_tag(Datadog::Ext::NET::TARGET_HOST)).to eq('example.com')
expect(request_span.get_tag(Datadog::Ext::NET::TARGET_PORT)).to eq('80')
expect(request_span.span_type).to eq(Datadog::Ext::HTTP::TYPE)
expect(request_span.span_type).to eq(Datadog::Ext::HTTP::TYPE_OUTBOUND)
expect(request_span.status).to_not eq(Datadog::Ext::Errors::STATUS)
end
end
Expand All @@ -85,7 +85,7 @@
expect(request_span.get_tag(Datadog::Ext::HTTP::STATUS_CODE)).to eq('500')
expect(request_span.get_tag(Datadog::Ext::NET::TARGET_HOST)).to eq('example.com')
expect(request_span.get_tag(Datadog::Ext::NET::TARGET_PORT)).to eq('80')
expect(request_span.span_type).to eq(Datadog::Ext::HTTP::TYPE)
expect(request_span.span_type).to eq(Datadog::Ext::HTTP::TYPE_OUTBOUND)
expect(request_span.status).to eq(Datadog::Ext::Errors::STATUS)
expect(request_span.get_tag(Datadog::Ext::Errors::TYPE)).to eq('Error 500')
expect(request_span.get_tag(Datadog::Ext::Errors::MSG)).to eq('Boom!')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

shared_examples 'span data contents' do
specify { expect(span.name).to eq 'grpc.service' }
specify { expect(span.span_type).to eq 'http' }
specify { expect(span.span_type).to eq 'web' }
specify { expect(span.service).to eq 'rspec' }
specify { expect(span.resource).to eq 'my.server.endpoint' }
specify { expect(span.get_tag('error.stack')).to be_nil }
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/grpc/interception_context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
context 'when intercepting on the server' do
shared_examples 'span data contents' do
specify { expect(span.name).to eq 'grpc.service' }
specify { expect(span.span_type).to eq 'http' }
specify { expect(span.span_type).to eq 'web' }
specify { expect(span.service).to eq 'rspec' }
specify { expect(span.resource).to eq 'my.server.endpoint' }
specify { expect(span.get_tag('error.stack')).to be_nil }
Expand Down
5 changes: 3 additions & 2 deletions spec/ddtrace/contrib/rack/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
expect(spans).to have(2).items

expect(queue_span.name).to eq('http_server.queue')
expect(queue_span.span_type).to eq('proxy')
expect(queue_span.service).to eq(Datadog.configuration[:rack][:web_service_name])
expect(queue_span.start_time.to_i).to eq(queue_time)
# Queue span gets tagged for runtime metrics because its a local root span.
Expand All @@ -81,7 +82,7 @@
expect(queue_span.get_tag(Datadog::Ext::Runtime::TAG_RUNTIME_ID)).to eq(Datadog::Runtime::Identity.id)

expect(rack_span.name).to eq('rack.request')
expect(rack_span.span_type).to eq('http')
expect(rack_span.span_type).to eq('web')
expect(rack_span.service).to eq(Datadog.configuration[:rack][:service_name])
expect(rack_span.resource).to eq('GET 200')
expect(rack_span.get_tag('http.method')).to eq('GET')
Expand All @@ -102,7 +103,7 @@

expect(span).to_not be nil
expect(span.name).to eq('rack.request')
expect(span.span_type).to eq('http')
expect(span.span_type).to eq('web')
expect(span.service).to eq(Datadog.configuration[:rack][:service_name])
expect(span.resource).to eq('GET 200')
expect(span.get_tag('http.method')).to eq('GET')
Expand Down
Loading