instana 2.2.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/trace/span_kind.rb +3 -3
- 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
|
|
@@ -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.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: []
|