instana 2.2.0 → 2.4.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/trace/span.rb +8 -8
- data/lib/instana/trace/span_kind.rb +3 -3
- data/lib/instana/version.rb +1 -1
- metadata +18 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f3e1c637f9239bf92022943ba9bd659e92fce0a7030a37adc337754e06d08245
|
|
4
|
+
data.tar.gz: c17d71a2c480b163b37c3f18a4fa6a510a94b553d5777b8192535433835b56bc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 02fd637038f974a35d42f52f52878ccb27f9dd7b177b07e2bfd92b53c7f176fc8dd3ecf4cd40d088023e571c5d6f0976901cc828a7c9e826781d7e361538bc0a
|
|
7
|
+
data.tar.gz: eab1b63483157aa3e58f1aef240e90de08faeaf0edddc5c9905ebaccc89630e27d22e5431c6b3f5be84e135b082e2da8ce1738fbe62bf8eef1561f3b93bc1e77
|
|
@@ -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
|
data/lib/instana/trace/span.rb
CHANGED
|
@@ -83,14 +83,14 @@ module Instana
|
|
|
83
83
|
|
|
84
84
|
@attributes[:stack] = stack
|
|
85
85
|
.map do |call|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
end.take(limit
|
|
86
|
+
file, line, *method = call.split(':')
|
|
87
|
+
|
|
88
|
+
{
|
|
89
|
+
c: file,
|
|
90
|
+
n: line,
|
|
91
|
+
m: method.join(' ')
|
|
92
|
+
}
|
|
93
|
+
end.take([limit, 40].min)
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
# Log an error into the span
|
|
@@ -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/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.4.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
|
|
@@ -205,6 +191,20 @@ dependencies:
|
|
|
205
191
|
- - ">="
|
|
206
192
|
- !ruby/object:Gem::Version
|
|
207
193
|
version: '0'
|
|
194
|
+
- !ruby/object:Gem::Dependency
|
|
195
|
+
name: cgi
|
|
196
|
+
requirement: !ruby/object:Gem::Requirement
|
|
197
|
+
requirements:
|
|
198
|
+
- - ">="
|
|
199
|
+
- !ruby/object:Gem::Version
|
|
200
|
+
version: '0'
|
|
201
|
+
type: :runtime
|
|
202
|
+
prerelease: false
|
|
203
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
204
|
+
requirements:
|
|
205
|
+
- - ">="
|
|
206
|
+
- !ruby/object:Gem::Version
|
|
207
|
+
version: '0'
|
|
208
208
|
- !ruby/object:Gem::Dependency
|
|
209
209
|
name: oj
|
|
210
210
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -245,6 +245,7 @@ files:
|
|
|
245
245
|
- lib/instana/activators/aws_sdk_s3.rb
|
|
246
246
|
- lib/instana/activators/aws_sdk_sns.rb
|
|
247
247
|
- lib/instana/activators/aws_sdk_sqs.rb
|
|
248
|
+
- lib/instana/activators/bunny.rb
|
|
248
249
|
- lib/instana/activators/cuba.rb
|
|
249
250
|
- lib/instana/activators/dalli.rb
|
|
250
251
|
- lib/instana/activators/excon.rb
|
|
@@ -291,6 +292,7 @@ files:
|
|
|
291
292
|
- lib/instana/instrumentation/aws_sdk_s3.rb
|
|
292
293
|
- lib/instana/instrumentation/aws_sdk_sns.rb
|
|
293
294
|
- lib/instana/instrumentation/aws_sdk_sqs.rb
|
|
295
|
+
- lib/instana/instrumentation/bunny.rb
|
|
294
296
|
- lib/instana/instrumentation/dalli.rb
|
|
295
297
|
- lib/instana/instrumentation/excon.rb
|
|
296
298
|
- lib/instana/instrumentation/graphql.rb
|
|
@@ -360,7 +362,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
360
362
|
- !ruby/object:Gem::Version
|
|
361
363
|
version: '0'
|
|
362
364
|
requirements: []
|
|
363
|
-
rubygems_version:
|
|
365
|
+
rubygems_version: 4.0.4
|
|
364
366
|
specification_version: 4
|
|
365
367
|
summary: Ruby Distributed Tracing & Metrics Sensor for Instana
|
|
366
368
|
test_files: []
|