17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/instrumentation/net_http.rb', line 17
def request(req, body = nil, &block)
return super(req, body, &block) unless started?
return super(req, body, &block) if config[:epsagon][:ignore_domains].any? {|d| @address.include? d}
attributes = Hash[OpenTelemetry::Common::HTTP::ClientContext.attributes]
path_with_params, query = req.path.split('?')
path, path_params = path_with_params.split(';')
attributes.merge!({
'type' => 'http',
'operation' => req.method,
'http.scheme' => USE_SSL_TO_SCHEME[use_ssl?],
'http.request.path' => path
})
unless config[:epsagon][:metadata_only]
= Hash[req..to_a]
attributes.merge!({
'http.request.path_params' => path_params,
'http.request.body' => body,
'http.request.headers' => Hash[],
'http.request.headers.User-Agent' => ['user-agent']
})
attributes.merge!(Util.epsagon_query_attributes(query))
end
tracer.in_span(
@address,
attributes: attributes,
kind: :client
) do |span|
OpenTelemetry.propagation.http.inject(req)
super(req, body, &block).tap do |response|
annotate_span_with_response!(span, response)
end
end
end
|