instana 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/instana/activators/bunny.rb +23 -0
- data/lib/instana/config.rb +1 -0
- data/lib/instana/instrumentation/bunny.rb +129 -0
- data/lib/instana/instrumentation/instrumented_request.rb +2 -0
- data/lib/instana/instrumentation/net-http.rb +2 -1
- data/lib/instana/instrumentation/rack.rb +86 -66
- data/lib/instana/trace/span_context.rb +10 -2
- data/lib/instana/trace/span_kind.rb +3 -3
- data/lib/instana/trace/tracer.rb +0 -21
- data/lib/instana/util.rb +13 -0
- data/lib/instana/version.rb +1 -1
- metadata +4 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 16fe1ce82ea4a8d0324dd72d015792e88af0389d8faecc54dfffe587ccb6ec50
|
|
4
|
+
data.tar.gz: 7a8f22ed404bcede4d89fc8a2e5dc47f15617c3084ee6a4d7242545fca2e2e6f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e3a2941ff94173b97d8967d74be38f9f2a5776f38e19b6c2eaa4e4a8af827b3f2c126d58620a6843aae8d342229a6e227f9cb88a1508082b51d89fb00150818e
|
|
7
|
+
data.tar.gz: bd6fedc2ae15e7533d703e09efdc128af3a9d6be5eb780ce83d3f42f4db91304bb40ab08fb962fc07eba05cee6b6dd587c380d49a8014aafc7f3792f157e380c
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# (c) Copyright IBM Corp. 2025
|
|
2
|
+
|
|
3
|
+
module Instana
|
|
4
|
+
module Activators
|
|
5
|
+
class Bunny < Activator
|
|
6
|
+
def can_instrument?
|
|
7
|
+
defined?(::Bunny) &&
|
|
8
|
+
defined?(::Bunny::Queue) &&
|
|
9
|
+
defined?(::Bunny::Exchange) &&
|
|
10
|
+
::Instana.config[:bunny][:enabled]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def instrument
|
|
14
|
+
require 'instana/instrumentation/bunny'
|
|
15
|
+
|
|
16
|
+
::Bunny::Exchange.prepend(::Instana::Instrumentation::BunnyProducer)
|
|
17
|
+
::Bunny::Queue.prepend(::Instana::Instrumentation::BunnyConsumer)
|
|
18
|
+
|
|
19
|
+
true
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
data/lib/instana/config.rb
CHANGED
|
@@ -64,6 +64,7 @@ module Instana
|
|
|
64
64
|
@config[:action_controller] = { :enabled => true }
|
|
65
65
|
@config[:action_view] = { :enabled => true }
|
|
66
66
|
@config[:active_record] = { :enabled => true }
|
|
67
|
+
@config[:bunny] = { :enabled => true }
|
|
67
68
|
@config[:dalli] = { :enabled => true }
|
|
68
69
|
@config[:excon] = { :enabled => true }
|
|
69
70
|
@config[:grpc] = { :enabled => true }
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# (c) Copyright IBM Corp. 2025
|
|
2
|
+
|
|
3
|
+
module Instana
|
|
4
|
+
module Instrumentation
|
|
5
|
+
module BunnyProducer
|
|
6
|
+
def publish(payload, options = {})
|
|
7
|
+
if ::Instana.tracer.tracing?
|
|
8
|
+
exchange_name = name.empty? ? 'default' : name
|
|
9
|
+
routing_key = options[:routing_key] || ''
|
|
10
|
+
|
|
11
|
+
kvs = {
|
|
12
|
+
rabbitmq: {
|
|
13
|
+
sort: 'publish',
|
|
14
|
+
address: channel.connection.host,
|
|
15
|
+
key: routing_key,
|
|
16
|
+
exchange: exchange_name
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
::Instana.tracer.in_span(:rabbitmq, attributes: kvs) do |span|
|
|
21
|
+
# Inject trace context into message headers
|
|
22
|
+
options[:headers] ||= {}
|
|
23
|
+
options[:headers]['X-Instana-T'] = span.context.trace_id
|
|
24
|
+
options[:headers]['X-Instana-S'] = span.context.span_id
|
|
25
|
+
options[:headers]['X-Instana-L'] = span.context.level.to_s
|
|
26
|
+
|
|
27
|
+
super(payload, options)
|
|
28
|
+
end
|
|
29
|
+
else
|
|
30
|
+
super(payload, options)
|
|
31
|
+
end
|
|
32
|
+
rescue => e
|
|
33
|
+
::Instana.logger.debug { "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" }
|
|
34
|
+
raise
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
module BunnyConsumer
|
|
39
|
+
def pop(options = {})
|
|
40
|
+
delivery_info, properties, payload = super(options)
|
|
41
|
+
|
|
42
|
+
return [delivery_info, properties, payload] unless delivery_info
|
|
43
|
+
|
|
44
|
+
trace_rabbitmq_consume(delivery_info, properties) do
|
|
45
|
+
[delivery_info, properties, payload]
|
|
46
|
+
end
|
|
47
|
+
rescue => e
|
|
48
|
+
log_error(e)
|
|
49
|
+
raise
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def subscribe(options = {}, &block)
|
|
53
|
+
if block_given?
|
|
54
|
+
wrapped_block = lambda do |delivery_info, properties, payload|
|
|
55
|
+
trace_rabbitmq_consume(delivery_info, properties) do
|
|
56
|
+
block.call(delivery_info, properties, payload)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
super(options, &wrapped_block)
|
|
61
|
+
else
|
|
62
|
+
super(options, &block)
|
|
63
|
+
end
|
|
64
|
+
rescue => e
|
|
65
|
+
log_error(e)
|
|
66
|
+
raise
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
private
|
|
70
|
+
|
|
71
|
+
def trace_rabbitmq_consume(delivery_info, properties, &block)
|
|
72
|
+
return yield unless ::Instana.tracer.tracing? || extract_context_from_headers(properties)
|
|
73
|
+
|
|
74
|
+
kvs = build_consume_attributes(delivery_info)
|
|
75
|
+
context = extract_context_from_headers(properties)
|
|
76
|
+
|
|
77
|
+
if context[:trace_id]
|
|
78
|
+
trace_with_context(context, kvs, &block)
|
|
79
|
+
else
|
|
80
|
+
::Instana.tracer.in_span(:rabbitmq, attributes: kvs, &block)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def build_consume_attributes(delivery_info)
|
|
85
|
+
queue_name = name
|
|
86
|
+
exchange_name = delivery_info.exchange.empty? ? 'default' : delivery_info.exchange
|
|
87
|
+
|
|
88
|
+
{
|
|
89
|
+
rabbitmq: {
|
|
90
|
+
sort: 'consume',
|
|
91
|
+
address: channel.connection.host,
|
|
92
|
+
queue: queue_name,
|
|
93
|
+
exchange: exchange_name,
|
|
94
|
+
key: delivery_info.routing_key
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def trace_with_context(context, kvs, &block)
|
|
100
|
+
instana_context = ::Instana::SpanContext.new(
|
|
101
|
+
trace_id: context[:trace_id],
|
|
102
|
+
span_id: context[:span_id],
|
|
103
|
+
level: context[:level]
|
|
104
|
+
)
|
|
105
|
+
span = OpenTelemetry::Trace.non_recording_span(instana_context)
|
|
106
|
+
|
|
107
|
+
Trace.with_span(span) do
|
|
108
|
+
::Instana.tracer.in_span(:rabbitmq, attributes: kvs, &block)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def extract_context_from_headers(properties)
|
|
113
|
+
return {} unless properties && properties.headers
|
|
114
|
+
|
|
115
|
+
headers = properties.headers
|
|
116
|
+
{
|
|
117
|
+
trace_id: headers['X-Instana-T'],
|
|
118
|
+
span_id: headers['X-Instana-S'],
|
|
119
|
+
level: headers['X-Instana-L']&.to_i
|
|
120
|
+
}.reject { |_, v| v.nil? }
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def log_error(error)
|
|
124
|
+
# Log errors on to console if INSTANA_DEBUG is enabled
|
|
125
|
+
::Instana.logger.debug { "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{error.message}" }
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
@@ -122,6 +122,7 @@ module Instana
|
|
|
122
122
|
long_instana_id: long_instana_id? ? sanitized_t : nil,
|
|
123
123
|
external_trace_id: external_trace_id,
|
|
124
124
|
external_state: @env['HTTP_TRACESTATE'],
|
|
125
|
+
external_trace_flags: context_from_trace_parent[:external_trace_flags],
|
|
125
126
|
from_w3c: false
|
|
126
127
|
}.reject { |_, v| v.nil? }
|
|
127
128
|
end
|
|
@@ -140,6 +141,7 @@ module Instana
|
|
|
140
141
|
external_state: @env['HTTP_TRACESTATE'],
|
|
141
142
|
trace_id: trace_id,
|
|
142
143
|
span_id: span_id,
|
|
144
|
+
external_trace_flags: matches['flags'],
|
|
143
145
|
from_w3c: true
|
|
144
146
|
}
|
|
145
147
|
end
|
|
@@ -56,7 +56,8 @@ module Instana
|
|
|
56
56
|
# without a backtrace (no exception)
|
|
57
57
|
current_span.record_exception(nil)
|
|
58
58
|
end
|
|
59
|
-
|
|
59
|
+
extra_headers = ::Instana::Util.extra_header_tags(response)&.merge(::Instana::Util.extra_header_tags(request))
|
|
60
|
+
kv_payload[:http][:header] = extra_headers unless extra_headers&.empty?
|
|
60
61
|
response
|
|
61
62
|
rescue => e
|
|
62
63
|
current_span&.record_exception(e)
|
|
@@ -10,7 +10,7 @@ module Instana
|
|
|
10
10
|
@app = app
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def call(env)
|
|
13
|
+
def call(env)
|
|
14
14
|
req = InstrumentedRequest.new(env)
|
|
15
15
|
kvs = {
|
|
16
16
|
http: req.request_tags
|
|
@@ -26,75 +26,14 @@ module Instana
|
|
|
26
26
|
@trace_token = OpenTelemetry::Context.attach(trace_ctx)
|
|
27
27
|
status, headers, response = @app.call(env)
|
|
28
28
|
|
|
29
|
-
if ::Instana.tracer.tracing?
|
|
30
|
-
|
|
31
|
-
current_span[:crid] = req.correlation_data[:id]
|
|
32
|
-
current_span[:crtp] = req.correlation_data[:type]
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
if !req.instana_ancestor.empty? && req.continuing_from_trace_parent?
|
|
36
|
-
current_span[:ia] = req.instana_ancestor
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
if req.continuing_from_trace_parent?
|
|
40
|
-
current_span[:tp] = true
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
if req.external_trace_id?
|
|
44
|
-
current_span[:lt] = req.external_trace_id
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
if req.synthetic?
|
|
48
|
-
current_span[:sy] = true
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# In case some previous middleware returned a string status, make sure that we're dealing with
|
|
52
|
-
# an integer. In Ruby nil.to_i, "asdfasdf".to_i will always return 0 from Ruby versions 1.8.7 and newer.
|
|
53
|
-
# So if an 0 status is reported here, it indicates some other issue (e.g. no status from previous middleware)
|
|
54
|
-
# See Rack Spec: https://www.rubydoc.info/github/rack/rack/file/SPEC#label-The+Status
|
|
55
|
-
kvs[:http][:status] = status.to_i
|
|
56
|
-
|
|
57
|
-
if status.to_i >= 500
|
|
58
|
-
# Because of the 5xx response, we flag this span as errored but
|
|
59
|
-
# without a backtrace (no exception)
|
|
60
|
-
::Instana.tracer.log_error(nil)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# If the framework instrumentation provides a path template,
|
|
64
|
-
# pass it into the span here.
|
|
65
|
-
# See: https://www.instana.com/docs/tracing/custom-best-practices/#path-templates-visual-grouping-of-http-endpoints
|
|
66
|
-
kvs[:http][:path_tpl] = env['INSTANA_HTTP_PATH_TEMPLATE'] if env['INSTANA_HTTP_PATH_TEMPLATE']
|
|
67
|
-
|
|
68
|
-
# Save the span context before the trace ends so we can place
|
|
69
|
-
# them in the response headers in the ensure block
|
|
70
|
-
trace_context = ::Instana.tracer.current_span.context
|
|
71
|
-
end
|
|
72
|
-
|
|
29
|
+
trace_context = process_span_tags(req, current_span, kvs, status, env) if ::Instana.tracer.tracing?
|
|
30
|
+
merge_response_headers(kvs, headers)
|
|
73
31
|
[status, headers, response]
|
|
74
32
|
rescue Exception => e
|
|
75
33
|
current_span.record_exception(e) if ::Instana.tracer.tracing?
|
|
76
34
|
raise
|
|
77
35
|
ensure
|
|
78
|
-
if ::Instana.tracer.tracing?
|
|
79
|
-
if headers
|
|
80
|
-
# Set response headers; encode as hex string
|
|
81
|
-
if trace_context.active?
|
|
82
|
-
headers['X-Instana-T'] = trace_context.trace_id_header
|
|
83
|
-
headers['X-Instana-S'] = trace_context.span_id_header
|
|
84
|
-
headers['X-Instana-L'] = '1'
|
|
85
|
-
|
|
86
|
-
headers['Tracestate'] = trace_context.trace_state_header
|
|
87
|
-
else
|
|
88
|
-
headers['X-Instana-L'] = '0'
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
headers['Traceparent'] = trace_context.trace_parent_header
|
|
92
|
-
headers['Server-Timing'] = "intid;desc=#{trace_context.trace_id_header}"
|
|
93
|
-
end
|
|
94
|
-
current_span.set_tags(kvs)
|
|
95
|
-
OpenTelemetry::Context.detach(@trace_token) if @trace_token
|
|
96
|
-
current_span.finish
|
|
97
|
-
end
|
|
36
|
+
finalize_trace(current_span, kvs, headers, trace_context) if ::Instana.tracer.tracing?
|
|
98
37
|
end
|
|
99
38
|
|
|
100
39
|
private
|
|
@@ -112,7 +51,8 @@ module Instana
|
|
|
112
51
|
level: incoming_context[:level],
|
|
113
52
|
baggage: {
|
|
114
53
|
external_trace_id: incoming_context[:external_trace_id],
|
|
115
|
-
external_state: incoming_context[:external_state]
|
|
54
|
+
external_state: incoming_context[:external_state],
|
|
55
|
+
external_trace_flags: incoming_context[:external_trace_flags]
|
|
116
56
|
}
|
|
117
57
|
)
|
|
118
58
|
end
|
|
@@ -121,5 +61,85 @@ module Instana
|
|
|
121
61
|
end
|
|
122
62
|
parent_context
|
|
123
63
|
end
|
|
64
|
+
|
|
65
|
+
def process_span_tags(req, current_span, kvs, status, env)
|
|
66
|
+
add_correlation_data(req, current_span)
|
|
67
|
+
add_trace_parent_data(req, current_span)
|
|
68
|
+
add_status_and_error(kvs, status)
|
|
69
|
+
add_path_template(kvs, env)
|
|
70
|
+
|
|
71
|
+
# Save the span context before the trace ends so we can place
|
|
72
|
+
# them in the response headers in the ensure block
|
|
73
|
+
::Instana.tracer.current_span.context
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def add_correlation_data(req, current_span)
|
|
77
|
+
return if req.correlation_data.empty?
|
|
78
|
+
|
|
79
|
+
current_span[:crid] = req.correlation_data[:id]
|
|
80
|
+
current_span[:crtp] = req.correlation_data[:type]
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def add_trace_parent_data(req, current_span)
|
|
84
|
+
if !req.instana_ancestor.empty? && req.continuing_from_trace_parent?
|
|
85
|
+
current_span[:ia] = req.instana_ancestor
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
current_span[:tp] = true if req.continuing_from_trace_parent?
|
|
89
|
+
current_span[:lt] = req.external_trace_id if req.external_trace_id?
|
|
90
|
+
current_span[:sy] = true if req.synthetic?
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def add_status_and_error(kvs, status)
|
|
94
|
+
# In case some previous middleware returned a string status, make sure that we're dealing with
|
|
95
|
+
# an integer. In Ruby nil.to_i, "asdfasdf".to_i will always return 0 from Ruby versions 1.8.7 and newer.
|
|
96
|
+
# So if an 0 status is reported here, it indicates some other issue (e.g. no status from previous middleware)
|
|
97
|
+
# See Rack Spec: https://www.rubydoc.info/github/rack/rack/file/SPEC#label-The+Status
|
|
98
|
+
kvs[:http][:status] = status.to_i
|
|
99
|
+
|
|
100
|
+
return unless status.to_i >= 500
|
|
101
|
+
|
|
102
|
+
# Because of the 5xx response, we flag this span as errored but
|
|
103
|
+
# without a backtrace (no exception)
|
|
104
|
+
::Instana.tracer.log_error(nil)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def add_path_template(kvs, env)
|
|
108
|
+
# If the framework instrumentation provides a path template,
|
|
109
|
+
# pass it into the span here.
|
|
110
|
+
# See: https://www.instana.com/docs/tracing/custom-best-practices/#path-templates-visual-grouping-of-http-endpoints
|
|
111
|
+
kvs[:http][:path_tpl] = env['INSTANA_HTTP_PATH_TEMPLATE'] if env['INSTANA_HTTP_PATH_TEMPLATE']
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def merge_response_headers(kvs, headers)
|
|
115
|
+
extra_response_headers = ::Instana::Util.extra_header_tags(headers)
|
|
116
|
+
if kvs[:http][:header].nil?
|
|
117
|
+
kvs[:http][:header] = extra_response_headers
|
|
118
|
+
else
|
|
119
|
+
kvs[:http][:header].merge!(extra_response_headers)
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def finalize_trace(current_span, kvs, headers, trace_context)
|
|
124
|
+
set_response_headers(headers, trace_context) if headers
|
|
125
|
+
current_span.set_tags(kvs)
|
|
126
|
+
OpenTelemetry::Context.detach(@trace_token) if @trace_token
|
|
127
|
+
current_span.finish
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def set_response_headers(headers, trace_context)
|
|
131
|
+
# Set response headers; encode as hex string
|
|
132
|
+
if trace_context.active?
|
|
133
|
+
headers['X-Instana-T'] = trace_context.trace_id_header
|
|
134
|
+
headers['X-Instana-S'] = trace_context.span_id_header
|
|
135
|
+
headers['X-Instana-L'] = '1'
|
|
136
|
+
headers['Tracestate'] = trace_context.trace_state_header
|
|
137
|
+
else
|
|
138
|
+
headers['X-Instana-L'] = '0'
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
headers['Traceparent'] = trace_context.trace_parent_header
|
|
142
|
+
headers['Server-Timing'] = "intid;desc=#{trace_context.trace_id_header}"
|
|
143
|
+
end
|
|
124
144
|
end
|
|
125
145
|
end
|
|
@@ -42,8 +42,16 @@ module Instana
|
|
|
42
42
|
def trace_parent_header
|
|
43
43
|
trace = (@baggage[:external_trace_id] || trace_id_header).rjust(32, '0')
|
|
44
44
|
parent = span_id_header.rjust(16, '0')
|
|
45
|
-
flags = @
|
|
46
|
-
|
|
45
|
+
flags = if @baggage[:external_trace_flags]
|
|
46
|
+
# Parse external flags as 8-bit hex, clear LSB, then set LSB based on level
|
|
47
|
+
external_flags = @baggage[:external_trace_flags].to_i(16) & 0xFE # Clear LSB
|
|
48
|
+
combined_flags = external_flags | (@level == 1 ? 1 : 0) # Set LSB based on level
|
|
49
|
+
combined_flags = [combined_flags, 0xFF].min # Cap at 8-bit max
|
|
50
|
+
format('%02x', combined_flags)
|
|
51
|
+
else
|
|
52
|
+
@level == 1 ? "03" : "02"
|
|
53
|
+
end
|
|
54
|
+
flags = "03" if flags > "03"
|
|
47
55
|
"00-#{trace}-#{parent}-#{flags}"
|
|
48
56
|
end
|
|
49
57
|
|
|
@@ -9,13 +9,13 @@ module Instana
|
|
|
9
9
|
module SpanKind
|
|
10
10
|
# Instana specific spans
|
|
11
11
|
REGISTERED_SPANS = [:actioncontroller, :actionview, :activerecord, :excon,
|
|
12
|
-
:memcache, :'net-http', :rack, :render, :'rpc-client',
|
|
12
|
+
:memcache, :'net-http', :rack, :rabbitmq, :render, :'rpc-client',
|
|
13
13
|
:'rpc-server', :'sidekiq-client', :'sidekiq-worker',
|
|
14
14
|
:redis, :'resque-client', :'resque-worker', :'graphql.server', :dynamodb, :s3, :sns, :sqs, :'aws.lambda.entry', :activejob, :log, :"mail.actionmailer",
|
|
15
15
|
:"aws.lambda.invoke", :mongo, :sequel].freeze
|
|
16
|
-
ENTRY_SPANS = [:rack, :'resque-worker', :'rpc-server', :'sidekiq-worker', :'graphql.server', :sqs,
|
|
16
|
+
ENTRY_SPANS = [:rack, :rabbitmq, :'resque-worker', :'rpc-server', :'sidekiq-worker', :'graphql.server', :sqs,
|
|
17
17
|
:'aws.lambda.entry'].freeze
|
|
18
|
-
EXIT_SPANS = [:activerecord, :excon, :'net-http', :'resque-client',
|
|
18
|
+
EXIT_SPANS = [:activerecord, :excon, :'net-http', :rabbitmq, :'resque-client',
|
|
19
19
|
:'rpc-client', :'sidekiq-client', :redis, :dynamodb, :s3, :sns, :sqs, :log, :"mail.actionmailer",
|
|
20
20
|
:"aws.lambda.invoke", :mongo, :sequel].freeze
|
|
21
21
|
HTTP_SPANS = [:rack, :excon, :'net-http'].freeze
|
data/lib/instana/trace/tracer.rb
CHANGED
|
@@ -307,27 +307,6 @@ module Instana
|
|
|
307
307
|
self.current_span = nil
|
|
308
308
|
end
|
|
309
309
|
|
|
310
|
-
# Creates a span that is active during the execution of the provided block.
|
|
311
|
-
# The span is automatically closed when the block completes, whether it completes
|
|
312
|
-
# normally or with an exception.
|
|
313
|
-
#
|
|
314
|
-
# @param name [String, Symbol] the name of the span to create
|
|
315
|
-
# @param attributes [Hash, nil] optional attributes to set on the span
|
|
316
|
-
# @param links [Array<Link>, nil] optional links to associate with the span
|
|
317
|
-
# @param start_timestamp [Integer, nil] optional start time for the span in milliseconds
|
|
318
|
-
# @param kind [Symbol, nil] optional span kind (e.g., :internal, :client, :server)
|
|
319
|
-
#
|
|
320
|
-
# @return [Object] the return value of the block
|
|
321
|
-
#
|
|
322
|
-
# @note This method is a wrapper around the parent class implementation and
|
|
323
|
-
# will only create a span if the Instana agent is ready and tracing is enabled.
|
|
324
|
-
#
|
|
325
|
-
def in_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil)
|
|
326
|
-
return if !::Instana.agent.ready? || !::Instana.config[:tracing][:enabled]
|
|
327
|
-
|
|
328
|
-
super
|
|
329
|
-
end
|
|
330
|
-
|
|
331
310
|
# Starts a new span with the given parameters.
|
|
332
311
|
#
|
|
333
312
|
# @param name [String, Symbol] the name of the span to create (defaults to 'empty' if nil)
|
data/lib/instana/util.rb
CHANGED
|
@@ -181,6 +181,19 @@ module Instana
|
|
|
181
181
|
timeout -= (timeout_timestamp - start_time)
|
|
182
182
|
timeout.positive? ? timeout : 0
|
|
183
183
|
end
|
|
184
|
+
|
|
185
|
+
def extra_header_tags(req_res_headers)
|
|
186
|
+
return {} if req_res_headers.nil?
|
|
187
|
+
return nil unless ::Instana.agent.extra_headers
|
|
188
|
+
|
|
189
|
+
headers = {}
|
|
190
|
+
|
|
191
|
+
::Instana.agent.extra_headers.each do |custom_header|
|
|
192
|
+
headers[custom_header.to_sym] = req_res_headers[custom_header] if req_res_headers.key?(custom_header)
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
headers
|
|
196
|
+
end
|
|
184
197
|
end
|
|
185
198
|
end
|
|
186
199
|
end
|
data/lib/instana/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: instana
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Peter Giacomo Lombardo
|
|
@@ -9,20 +9,6 @@ bindir: exe
|
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
|
-
- !ruby/object:Gem::Dependency
|
|
13
|
-
name: bundler
|
|
14
|
-
requirement: !ruby/object:Gem::Requirement
|
|
15
|
-
requirements:
|
|
16
|
-
- - "~>"
|
|
17
|
-
- !ruby/object:Gem::Version
|
|
18
|
-
version: '2.0'
|
|
19
|
-
type: :development
|
|
20
|
-
prerelease: false
|
|
21
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
-
requirements:
|
|
23
|
-
- - "~>"
|
|
24
|
-
- !ruby/object:Gem::Version
|
|
25
|
-
version: '2.0'
|
|
26
12
|
- !ruby/object:Gem::Dependency
|
|
27
13
|
name: rake
|
|
28
14
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -245,6 +231,7 @@ files:
|
|
|
245
231
|
- lib/instana/activators/aws_sdk_s3.rb
|
|
246
232
|
- lib/instana/activators/aws_sdk_sns.rb
|
|
247
233
|
- lib/instana/activators/aws_sdk_sqs.rb
|
|
234
|
+
- lib/instana/activators/bunny.rb
|
|
248
235
|
- lib/instana/activators/cuba.rb
|
|
249
236
|
- lib/instana/activators/dalli.rb
|
|
250
237
|
- lib/instana/activators/excon.rb
|
|
@@ -291,6 +278,7 @@ files:
|
|
|
291
278
|
- lib/instana/instrumentation/aws_sdk_s3.rb
|
|
292
279
|
- lib/instana/instrumentation/aws_sdk_sns.rb
|
|
293
280
|
- lib/instana/instrumentation/aws_sdk_sqs.rb
|
|
281
|
+
- lib/instana/instrumentation/bunny.rb
|
|
294
282
|
- lib/instana/instrumentation/dalli.rb
|
|
295
283
|
- lib/instana/instrumentation/excon.rb
|
|
296
284
|
- lib/instana/instrumentation/graphql.rb
|
|
@@ -360,7 +348,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
360
348
|
- !ruby/object:Gem::Version
|
|
361
349
|
version: '0'
|
|
362
350
|
requirements: []
|
|
363
|
-
rubygems_version:
|
|
351
|
+
rubygems_version: 4.0.2
|
|
364
352
|
specification_version: 4
|
|
365
353
|
summary: Ruby Distributed Tracing & Metrics Sensor for Instana
|
|
366
354
|
test_files: []
|