20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/skywalking/plugins/sinatra.rb', line 20
def dispatch!(*args, &block)
req_method = @request.request_method if @request.respond_to?(:request_method)
carrier = Tracing::Carrier.new
carrier.each do |item|
item.value = request.env["HTTP_#{item.key.upcase}"]
end
Tracing::ContextManager.new_entry_span(
operation: "#{req_method}:#{request.env['REQUEST_URI']}",
carrier: carrier
) do |span|
span&.tag(Tracing::TagHttpMethod.new(req_method))
span&.tag(Tracing::TagHttpURL.new(request.env['REQUEST_URI']))
span&.layer = Tracing::Layer::Http
span&.peer = "#{request.env['SERVER_NAME']}:#{request.env['SERVER_PORT']}"
span&.component = Tracing::Component::Sinatra
super(*args, &block)
rescue
span&.error_occurred = true
end
end
|