Skip to content

Commit

Permalink
Merge branch 'revert-338-use_rack_compliant_keys' into 0.12-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
delner committed Mar 7, 2018
2 parents 41c0785 + 92daf6a commit b784857
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/ddtrace/contrib/grape/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def self.endpoint_run(name, start, finish, id, payload)
span.resource = resource

# set the request span resource if it's a `rack.request` span
request_span = payload[:env][Datadog::Contrib::Rack::TraceMiddleware::RACK_REQUEST_SPAN]
request_span = payload[:env][:datadog_rack_request_span]
if !request_span.nil? && request_span.name == 'rack.request'
request_span.resource = resource
end
Expand Down
4 changes: 1 addition & 3 deletions lib/ddtrace/contrib/rack/middlewares.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ module Rack
# application. If request tags are not set by the app, they will be set using
# information available at the Rack level.
class TraceMiddleware
RACK_REQUEST_SPAN = 'datadog.rack_request_span'.freeze

def initialize(app)
@app = app
end
Expand All @@ -37,7 +35,7 @@ def call(env)
# start a new request span and attach it to the current Rack environment;
# we must ensure that the span `resource` is set later
request_span = tracer.trace('rack.request', trace_options)
env[RACK_REQUEST_SPAN] = request_span
env[:datadog_rack_request_span] = request_span

# Copy the original env, before the rest of the stack executes.
# Values may change; we want values before that happens.
Expand Down
6 changes: 3 additions & 3 deletions test/contrib/rack/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def app
run(proc do |env|
# this should be considered a web framework that can alter
# the request span after routing / controller processing
request_span = env['datadog.rack_request_span']
request_span = env[:datadog_rack_request_span]
request_span.resource = 'GET /app/'
request_span.set_tag('http.method', 'GET_V2')
request_span.set_tag('http.status_code', 201)
Expand All @@ -54,7 +54,7 @@ def app
run(proc do |env|
# this should be considered a web framework that can alter
# the request span after routing / controller processing
request_span = env[Datadog::Contrib::Rack::TraceMiddleware::RACK_REQUEST_SPAN]
request_span = env[:datadog_rack_request_span]
request_span.status = 1
request_span.set_tag('error.stack', 'Handled exception')

Expand All @@ -66,7 +66,7 @@ def app
run(proc do |env|
# this should be considered a web framework that can alter
# the request span after routing / controller processing
request_span = env[Datadog::Contrib::Rack::TraceMiddleware::RACK_REQUEST_SPAN]
request_span = env[:datadog_rack_request_span]
request_span.set_tag('error.stack', 'Handled exception')

[500, { 'Content-Type' => 'text/html' }, 'OK']
Expand Down

0 comments on commit b784857

Please sign in to comment.