instana 1.217.1 → 2.0.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/.circleci/config.yml +101 -225
- data/.tekton/.currency/scripts/generate_report.py +194 -22
- data/.tekton/pipeline.yaml +65 -152
- data/.tekton/prepuller-restart-service-account.yaml +31 -0
- data/.tekton/ruby-tracer-prepuller-cronjob.yaml +20 -0
- data/.tekton/ruby-tracer-prepuller.yaml +27 -26
- data/.tekton/task.yaml +31 -27
- data/Gemfile +5 -0
- data/README.md +2 -1
- data/Rakefile +1 -1
- data/examples/otel.rb +98 -0
- data/examples/tracing.rb +1 -0
- data/gemfiles/rails_61.gemfile +1 -0
- data/gemfiles/rails_70.gemfile +1 -0
- data/instana.gemspec +5 -0
- data/lib/instana/base.rb +4 -2
- data/lib/instana/instrumentation/action_cable.rb +8 -4
- data/lib/instana/instrumentation/action_controller.rb +2 -4
- data/lib/instana/instrumentation/action_mailer.rb +1 -1
- data/lib/instana/instrumentation/action_view.rb +4 -4
- data/lib/instana/instrumentation/active_job.rb +20 -5
- data/lib/instana/instrumentation/active_record.rb +1 -1
- data/lib/instana/instrumentation/aws_sdk_dynamodb.rb +1 -1
- data/lib/instana/instrumentation/aws_sdk_lambda.rb +1 -1
- data/lib/instana/instrumentation/aws_sdk_s3.rb +1 -1
- data/lib/instana/instrumentation/aws_sdk_sns.rb +1 -1
- data/lib/instana/instrumentation/aws_sdk_sqs.rb +1 -1
- data/lib/instana/instrumentation/dalli.rb +1 -1
- data/lib/instana/instrumentation/excon.rb +2 -2
- data/lib/instana/instrumentation/graphql.rb +3 -3
- data/lib/instana/instrumentation/grpc.rb +14 -13
- data/lib/instana/instrumentation/mongo.rb +3 -3
- data/lib/instana/instrumentation/net-http.rb +5 -4
- data/lib/instana/instrumentation/rack.rb +36 -4
- data/lib/instana/instrumentation/redis.rb +1 -1
- data/lib/instana/instrumentation/resque.rb +10 -8
- data/lib/instana/instrumentation/rest-client.rb +4 -4
- data/lib/instana/instrumentation/sequel.rb +3 -3
- data/lib/instana/instrumentation/shoryuken.rb +4 -1
- data/lib/instana/instrumentation/sidekiq-client.rb +21 -19
- data/lib/instana/instrumentation/sidekiq-worker.rb +22 -21
- data/lib/instana/instrumented_logger.rb +1 -1
- data/lib/instana/samplers/result.rb +32 -0
- data/lib/instana/samplers/samplers.rb +76 -0
- data/lib/instana/serverless.rb +4 -2
- data/lib/instana/setup.rb +4 -5
- data/lib/instana/trace/export.rb +36 -0
- data/lib/instana/{tracing → trace}/processor.rb +19 -15
- data/lib/instana/trace/span.rb +532 -0
- data/lib/instana/{tracing → trace}/span_context.rb +17 -8
- data/lib/instana/trace/span_kind.rb +51 -0
- data/lib/instana/trace/span_limits.rb +63 -0
- data/lib/instana/{tracer.rb → trace/tracer.rb} +106 -54
- data/lib/instana/trace/tracer_provider.rb +198 -0
- data/lib/instana/trace.rb +74 -0
- data/lib/instana/util.rb +11 -0
- data/lib/instana/version.rb +1 -1
- data/test/instrumentation/aws_test.rb +7 -7
- data/test/instrumentation/dalli_test.rb +8 -8
- data/test/instrumentation/excon_test.rb +3 -3
- data/test/instrumentation/graphql_test.rb +4 -4
- data/test/instrumentation/grpc_test.rb +8 -8
- data/test/instrumentation/mongo_test.rb +1 -1
- data/test/instrumentation/net_http_test.rb +6 -6
- data/test/instrumentation/rails_action_cable_test.rb +2 -2
- data/test/instrumentation/rails_action_mailer_test.rb +1 -1
- data/test/instrumentation/rails_active_job_test.rb +1 -1
- data/test/instrumentation/rails_active_record_database_missing_test.rb +2 -3
- data/test/instrumentation/rails_active_record_test.rb +8 -7
- data/test/instrumentation/redis_test.rb +7 -7
- data/test/instrumentation/resque_test.rb +5 -5
- data/test/instrumentation/rest_client_test.rb +1 -2
- data/test/instrumentation/sequel_test.rb +12 -6
- data/test/instrumentation/sidekiq-client_test.rb +2 -2
- data/test/instrumentation/sidekiq-worker_test.rb +2 -2
- data/test/{tracing → trace}/custom_test.rb +32 -25
- data/test/{tracing → trace}/id_management_test.rb +0 -2
- data/test/{tracing → trace}/instrumented_logger_test.rb +1 -1
- data/test/{tracing → trace}/processor_test.rb +6 -6
- data/test/{tracing → trace}/span_context_test.rb +3 -3
- data/test/{tracing → trace}/span_test.rb +7 -7
- data/test/{tracing → trace}/tracer_async_test.rb +43 -30
- data/test/trace/tracer_provider_test.rb +148 -0
- data/test/{tracing → trace}/tracer_test.rb +48 -37
- metadata +105 -32
- data/examples/opentracing.rb +0 -35
- data/lib/instana/open_tracing/carrier.rb +0 -7
- data/lib/instana/open_tracing/instana_tracer.rb +0 -99
- data/lib/instana/tracing/span.rb +0 -431
- data/lib/opentracing.rb +0 -32
- data/test/tracing/opentracing_test.rb +0 -382
@@ -1,5 +1,19 @@
|
|
1
1
|
# (c) Copyright IBM Corp. 2021
|
2
2
|
# (c) Copyright Instana Inc. 2021
|
3
|
+
module OpenTelemetry
|
4
|
+
module Trace
|
5
|
+
module Propagation
|
6
|
+
module TraceContext
|
7
|
+
# A TraceParent is an implementation of the W3C trace context specification
|
8
|
+
# https://www.w3.org/TR/trace-context/
|
9
|
+
# {Trace::SpanContext}
|
10
|
+
class TraceParent
|
11
|
+
REGEXP = /^(?<version>[A-Fa-f0-9]{2})-(?<trace_id>[A-Fa-f0-9]{32})-(?<span_id>[A-Fa-f0-9]{32})-(?<flags>[A-Fa-f0-9]{2})(?<ignored>-.*)?$/
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
3
17
|
|
4
18
|
module Instana
|
5
19
|
module Instrumentation
|
@@ -15,7 +29,7 @@ module Instana
|
|
15
29
|
}
|
16
30
|
}
|
17
31
|
|
18
|
-
::Instana
|
32
|
+
::Instana.tracer.in_span(:activejob, attributes: tags) do
|
19
33
|
context = ::Instana.tracer.context
|
20
34
|
job.arguments.append({
|
21
35
|
instana_context: context ? context.to_hash : nil
|
@@ -37,11 +51,12 @@ module Instana
|
|
37
51
|
incoming_context = if job.arguments.is_a?(Array) && job.arguments.last.is_a?(Hash) && job.arguments.last.key?(:instana_context)
|
38
52
|
instana_context = job.arguments.last[:instana_context]
|
39
53
|
job.arguments.pop
|
40
|
-
instana_context ? ::Instana::SpanContext.new(instana_context[:trace_id], instana_context[:span_id]) : nil
|
54
|
+
instana_context ? ::Instana::SpanContext.new(trace_id: instana_context[:trace_id], span_id: instana_context[:span_id]) : nil
|
41
55
|
end
|
42
|
-
|
43
|
-
|
44
|
-
|
56
|
+
Trace.with_span(OpenTelemetry::Trace.non_recording_span(incoming_context)) do
|
57
|
+
::Instana.tracer.in_span(:activejob, attributes: tags) do
|
58
|
+
block.call
|
59
|
+
end
|
45
60
|
end
|
46
61
|
end
|
47
62
|
end
|
@@ -35,7 +35,7 @@ module Instana
|
|
35
35
|
|
36
36
|
def maybe_trace(call_payload, name, &blk)
|
37
37
|
if ::Instana.tracer.tracing? && !ignored?(call_payload, name)
|
38
|
-
::Instana.tracer.
|
38
|
+
::Instana.tracer.in_span(:activerecord, attributes: call_payload, &blk)
|
39
39
|
else
|
40
40
|
yield
|
41
41
|
end
|
@@ -11,7 +11,7 @@ module Instana
|
|
11
11
|
table: table_name_from(context)
|
12
12
|
}
|
13
13
|
|
14
|
-
::Instana.tracer.
|
14
|
+
::Instana.tracer.in_span(:dynamodb, attributes: {dynamodb: dynamo_tags}) { @handler.call(context) }
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
@@ -25,7 +25,7 @@ module Instana
|
|
25
25
|
type: context.params[:invocation_type]
|
26
26
|
}.reject { |_, v| v.nil? }
|
27
27
|
|
28
|
-
::Instana.tracer.
|
28
|
+
::Instana.tracer.in_span(:"aws.lambda.invoke", attributes: {aws: {lambda: {invoke: tags}}}) do
|
29
29
|
response = @handler.call(context)
|
30
30
|
if response.respond_to? :status_code
|
31
31
|
::Instana.tracer.log_info(:http => {:status => response.status_code })
|
@@ -12,7 +12,7 @@ module Instana
|
|
12
12
|
key: key_from_context(context)
|
13
13
|
}.reject { |_, v| v.nil? }
|
14
14
|
|
15
|
-
::Instana.tracer.
|
15
|
+
::Instana.tracer.in_span(:s3, attributes: {s3: s3_tags}) { @handler.call(context) }
|
16
16
|
end
|
17
17
|
|
18
18
|
private
|
@@ -14,7 +14,7 @@ module Instana
|
|
14
14
|
}.reject { |_, v| v.nil? }
|
15
15
|
|
16
16
|
if context.operation_name == :publish
|
17
|
-
::Instana.tracer.
|
17
|
+
::Instana.tracer.in_span(:sns, attributes: {sns: sns_tags}) { @handler.call(context) }
|
18
18
|
else
|
19
19
|
@handler.call(context)
|
20
20
|
end
|
@@ -15,7 +15,7 @@ module Instana
|
|
15
15
|
|
16
16
|
span_tags = tags_for(context.operation_name, context.params).reject { |_, v| v.nil? }
|
17
17
|
|
18
|
-
::Instana.tracer.
|
18
|
+
::Instana.tracer.in_span(:sqs, attributes: {sqs: span_tags}) do |span|
|
19
19
|
case context.operation_name
|
20
20
|
when :send_message
|
21
21
|
inject_instana_headers(span, context.params)
|
@@ -17,7 +17,7 @@ module Instana
|
|
17
17
|
entry_payload[:memcache][:command] = op
|
18
18
|
entry_payload[:memcache][:key] = key
|
19
19
|
|
20
|
-
::Instana.tracer.
|
20
|
+
::Instana.tracer.start_span(:memcache, attributes: entry_payload)
|
21
21
|
exit_payload = { :memcache => {} }
|
22
22
|
|
23
23
|
result = super(*args, &blk)
|
@@ -16,10 +16,10 @@ module Instana
|
|
16
16
|
if datum[:pipeline] == true
|
17
17
|
# Pass the context along in the datum so we get back on response
|
18
18
|
# and can close out the async span
|
19
|
-
datum[:instana_span] = ::Instana.tracer.
|
19
|
+
datum[:instana_span] = ::Instana.tracer.start_span(:excon, attributes: payload)
|
20
20
|
t_context = datum[:instana_span].context
|
21
21
|
else
|
22
|
-
::Instana.tracer.
|
22
|
+
::Instana.tracer.start_span(:excon, attributes: payload)
|
23
23
|
t_context = ::Instana.tracer.context
|
24
24
|
end
|
25
25
|
|
@@ -35,13 +35,13 @@ module Instana
|
|
35
35
|
}
|
36
36
|
|
37
37
|
begin
|
38
|
-
::Instana.tracer.
|
38
|
+
span = ::Instana.tracer.start_span(:'graphql.server', attributes: {graphql: payload})
|
39
39
|
yield
|
40
40
|
rescue Exception => e
|
41
|
-
|
41
|
+
span.record_exception(e)
|
42
42
|
raise e
|
43
43
|
ensure
|
44
|
-
|
44
|
+
span.finish
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -22,7 +22,7 @@ module Instana
|
|
22
22
|
kvs[:rpc][:call] = method
|
23
23
|
kvs[:rpc][:call_type] = call_type
|
24
24
|
|
25
|
-
::Instana.tracer.
|
25
|
+
current_span = ::Instana.tracer.start_span(:'rpc-client', attributes: kvs)
|
26
26
|
|
27
27
|
context = ::Instana.tracer.context
|
28
28
|
if context
|
@@ -35,11 +35,11 @@ module Instana
|
|
35
35
|
super(method, *others, **options)
|
36
36
|
rescue => e
|
37
37
|
kvs[:rpc][:error] = true
|
38
|
-
|
39
|
-
|
38
|
+
current_span.set_tags(kvs)
|
39
|
+
current_span.record_exception(e)
|
40
40
|
raise
|
41
41
|
ensure
|
42
|
-
|
42
|
+
current_span.finish
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -60,9 +60,9 @@ module Instana
|
|
60
60
|
|
61
61
|
incoming_context = {}
|
62
62
|
if metadata.key?('x-instana-t')
|
63
|
-
incoming_context
|
64
|
-
|
65
|
-
|
63
|
+
incoming_context = SpanContext.new(trace_id: ::Instana::Util.header_to_id(metadata['x-instana-t']),
|
64
|
+
span_id: metadata.key?('x-instana-s') ? ::Instana::Util.header_to_id(metadata['x-instana-s']) : nil,
|
65
|
+
level: metadata.key?('x-instana-l') ? metadata['x-instana-l'] : nil)
|
66
66
|
end
|
67
67
|
|
68
68
|
kvs[:rpc][:flavor] = :grpc
|
@@ -71,18 +71,19 @@ module Instana
|
|
71
71
|
kvs[:rpc][:call_type] = call_type
|
72
72
|
kvs[:rpc][:peer] = { address: active_call.peer }
|
73
73
|
|
74
|
-
::
|
75
|
-
|
76
|
-
|
74
|
+
span = OpenTelemetry::Trace.non_recording_span(incoming_context) if incoming_context
|
75
|
+
parent_context = Trace.context_with_span(span) if incoming_context
|
76
|
+
|
77
|
+
current_span = ::Instana.tracer.start_span(:'rpc-server', attributes: kvs, with_parent: parent_context)
|
77
78
|
|
78
79
|
super(active_call, mth, *others)
|
79
80
|
rescue => e
|
80
81
|
kvs[:rpc][:error] = true
|
81
|
-
|
82
|
-
|
82
|
+
current_span.set_tags(kvs)
|
83
|
+
current_span.record_exception(e)
|
83
84
|
raise
|
84
85
|
ensure
|
85
|
-
|
86
|
+
current_span.finish if ::Instana.tracer.tracing?
|
86
87
|
end
|
87
88
|
end
|
88
89
|
end
|
@@ -20,19 +20,19 @@ module Instana
|
|
20
20
|
json: filter_statement(event.command)
|
21
21
|
}
|
22
22
|
|
23
|
-
@requests[event.request_id] = ::Instana.tracer.
|
23
|
+
@requests[event.request_id] = ::Instana.tracer.start_span(:mongo, attributes: {mongo: tags})
|
24
24
|
end
|
25
25
|
|
26
26
|
def failed(event)
|
27
27
|
span = @requests.delete(event.request_id)
|
28
28
|
span.add_error(Exception.new(event.message))
|
29
29
|
|
30
|
-
|
30
|
+
span.finish
|
31
31
|
end
|
32
32
|
|
33
33
|
def succeeded(event)
|
34
34
|
span = @requests.delete(event.request_id)
|
35
|
-
|
35
|
+
span.finish
|
36
36
|
end
|
37
37
|
|
38
38
|
private
|
@@ -12,7 +12,7 @@ module Instana
|
|
12
12
|
return super(*args, &block)
|
13
13
|
end
|
14
14
|
|
15
|
-
::Instana.tracer.
|
15
|
+
current_span = ::Instana.tracer.start_span(:'net-http')
|
16
16
|
|
17
17
|
# Send out the tracing context with the request
|
18
18
|
request = args[0]
|
@@ -54,15 +54,16 @@ module Instana
|
|
54
54
|
if response.code.to_i >= 500
|
55
55
|
# Because of the 5xx response, we flag this span as errored but
|
56
56
|
# without a backtrace (no exception)
|
57
|
-
|
57
|
+
current_span.record_exception(nil)
|
58
58
|
end
|
59
59
|
|
60
60
|
response
|
61
61
|
rescue => e
|
62
|
-
|
62
|
+
current_span&.record_exception(e)
|
63
63
|
raise
|
64
64
|
ensure
|
65
|
-
|
65
|
+
current_span&.set_tags(kv_payload)
|
66
|
+
current_span&.finish unless do_skip
|
66
67
|
end
|
67
68
|
|
68
69
|
def skip_instrumentation?
|
@@ -10,14 +10,20 @@ module Instana
|
|
10
10
|
@app = app
|
11
11
|
end
|
12
12
|
|
13
|
-
def call(env)
|
13
|
+
def call(env) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength
|
14
14
|
req = InstrumentedRequest.new(env)
|
15
15
|
kvs = {
|
16
16
|
http: req.request_tags
|
17
17
|
}.reject { |_, v| v.nil? }
|
18
18
|
|
19
|
-
|
19
|
+
parent_context = extract_trace_context(req.incoming_context)
|
20
20
|
|
21
|
+
span = OpenTelemetry::Trace.non_recording_span(parent_context) if parent_context
|
22
|
+
parent_context = Trace.context_with_span(span) if parent_context
|
23
|
+
|
24
|
+
current_span = ::Instana.tracer.start_span(:rack, attributes: {}, with_parent: parent_context)
|
25
|
+
trace_ctx = OpenTelemetry::Trace.context_with_span(current_span)
|
26
|
+
@trace_token = OpenTelemetry::Context.attach(trace_ctx)
|
21
27
|
status, headers, response = @app.call(env)
|
22
28
|
|
23
29
|
if ::Instana.tracer.tracing?
|
@@ -66,7 +72,7 @@ module Instana
|
|
66
72
|
|
67
73
|
[status, headers, response]
|
68
74
|
rescue Exception => e
|
69
|
-
|
75
|
+
current_span.record_exception(e) if ::Instana.tracer.tracing?
|
70
76
|
raise
|
71
77
|
ensure
|
72
78
|
if ::Instana.tracer.tracing?
|
@@ -85,9 +91,35 @@ module Instana
|
|
85
91
|
headers['Traceparent'] = trace_context.trace_parent_header
|
86
92
|
headers['Server-Timing'] = "intid;desc=#{trace_context.trace_id_header}"
|
87
93
|
end
|
94
|
+
current_span.set_tags(kvs)
|
95
|
+
OpenTelemetry::Context.detach(@trace_token) if @trace_token
|
96
|
+
current_span.finish
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
88
101
|
|
89
|
-
|
102
|
+
def extract_trace_context(incoming_context)
|
103
|
+
return nil unless incoming_context
|
104
|
+
|
105
|
+
parent_context = nil
|
106
|
+
|
107
|
+
if incoming_context.is_a?(Hash)
|
108
|
+
unless incoming_context.empty?
|
109
|
+
parent_context = SpanContext.new(
|
110
|
+
trace_id: incoming_context[:trace_id],
|
111
|
+
span_id: incoming_context[:span_id],
|
112
|
+
level: incoming_context[:level],
|
113
|
+
baggage: {
|
114
|
+
external_trace_id: incoming_context[:external_trace_id],
|
115
|
+
external_state: incoming_context[:external_state]
|
116
|
+
}
|
117
|
+
)
|
118
|
+
end
|
119
|
+
elsif incoming_context.is_a?(SpanContext)
|
120
|
+
parent_context = incoming_context
|
90
121
|
end
|
122
|
+
parent_context
|
91
123
|
end
|
92
124
|
end
|
93
125
|
end
|
@@ -27,7 +27,7 @@ module Instana
|
|
27
27
|
if Instana.tracer.tracing?
|
28
28
|
kvs = collect_kvs(:enqueue, klass, args)
|
29
29
|
|
30
|
-
Instana.tracer.
|
30
|
+
Instana.tracer.in_span(:'resque-client', attributes: kvs) do
|
31
31
|
args.push(::Instana.tracer.context.to_hash) if ::Instana.config[:'resque-client'][:propagate]
|
32
32
|
super(klass, *args)
|
33
33
|
end
|
@@ -41,7 +41,7 @@ module Instana
|
|
41
41
|
kvs = collect_kvs(:enqueue_to, klass, args)
|
42
42
|
kvs[:Queue] = queue.to_s if queue
|
43
43
|
|
44
|
-
Instana.tracer.
|
44
|
+
Instana.tracer.in_span(:'resque-client', attributes: kvs) do
|
45
45
|
args.push(::Instana.tracer.context.to_hash) if ::Instana.config[:'resque-client'][:propagate]
|
46
46
|
super(queue, klass, *args)
|
47
47
|
end
|
@@ -54,7 +54,7 @@ module Instana
|
|
54
54
|
if Instana.tracer.tracing?
|
55
55
|
kvs = collect_kvs(:dequeue, klass, args)
|
56
56
|
|
57
|
-
Instana.tracer.
|
57
|
+
Instana.tracer.in_span(:'resque-client', attributes: kvs) do
|
58
58
|
super(klass, *args)
|
59
59
|
end
|
60
60
|
else
|
@@ -78,13 +78,15 @@ module Instana
|
|
78
78
|
trace_context = if ::Instana.config[:'resque-client'][:propagate] && job.payload['args'][-1].is_a?(Hash) && job.payload['args'][-1].keys.include?('trace_id')
|
79
79
|
context_from_wire = job.payload['args'].pop
|
80
80
|
::Instana::SpanContext.new(
|
81
|
-
context_from_wire['trace_id'],
|
82
|
-
context_from_wire['span_id']
|
81
|
+
trace_id: context_from_wire['trace_id'],
|
82
|
+
span_id: context_from_wire['span_id']
|
83
83
|
)
|
84
84
|
end
|
85
|
-
|
86
|
-
|
87
|
-
|
85
|
+
span = OpenTelemetry::Trace.non_recording_span(trace_context) if trace_context
|
86
|
+
Trace.with_span(span) do
|
87
|
+
Instana.tracer.in_span(:'resque-worker', attributes: kvs) do |span|
|
88
|
+
super(job)
|
89
|
+
end
|
88
90
|
end
|
89
91
|
end
|
90
92
|
end
|
@@ -8,14 +8,14 @@ module Instana
|
|
8
8
|
# Since RestClient uses net/http under the covers, we just
|
9
9
|
# provide span visibility here. HTTP related KVs are reported
|
10
10
|
# in the Net::HTTP instrumentation
|
11
|
-
::Instana.tracer.
|
11
|
+
span = ::Instana.tracer.start_span(:'rest-client', with_parent: OpenTelemetry::Context.current)
|
12
12
|
|
13
|
-
super(&block)
|
13
|
+
Trace.with_span(span) { super(&block) }
|
14
14
|
rescue => e
|
15
|
-
|
15
|
+
span.record_exception(e)
|
16
16
|
raise
|
17
17
|
ensure
|
18
|
-
|
18
|
+
span.finish
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Instana
|
4
4
|
module Instrumentation
|
5
5
|
module Sequel
|
6
|
-
IGNORED_SQL = %w[BEGIN COMMIT SET].freeze
|
6
|
+
IGNORED_SQL = %w[BEGIN COMMIT SET PRAGMA].freeze
|
7
7
|
VERSION_SELECT_STATEMENT = "SELECT VERSION()".freeze
|
8
8
|
SANITIZE_REGEXP = /('[\s\S][^']*'|\d*\.\d+|\d+|NULL)/i
|
9
9
|
|
@@ -26,9 +26,9 @@ module Instana
|
|
26
26
|
::Instana.config[:sanitize_sql] ? sql.gsub(SANITIZE_REGEXP, '?') : sql
|
27
27
|
end
|
28
28
|
|
29
|
-
def maybe_trace(call_payload, &
|
29
|
+
def maybe_trace(call_payload, &block)
|
30
30
|
if ::Instana.tracer.tracing? && !ignored?(call_payload)
|
31
|
-
::Instana.tracer.
|
31
|
+
::Instana.tracer.in_span(:sequel, attributes: call_payload, &block)
|
32
32
|
else
|
33
33
|
yield
|
34
34
|
end
|
@@ -15,7 +15,10 @@ module Instana
|
|
15
15
|
}
|
16
16
|
|
17
17
|
context = incomming_context_from(sqs_message.message_attributes)
|
18
|
-
::
|
18
|
+
instana_context = Instana::SpanContext.new(trace_id: context[:trace_id], span_id: context[:span_id], level: context[:level])
|
19
|
+
Trace.with_span(OpenTelemetry::Trace.non_recording_span(instana_context)) do
|
20
|
+
::Instana.tracer.in_span(:sqs, attributes: {sqs: sqs_tags}, &block)
|
21
|
+
end
|
19
22
|
end
|
20
23
|
|
21
24
|
private
|
@@ -5,11 +5,10 @@ module Instana
|
|
5
5
|
module Instrumentation
|
6
6
|
class SidekiqClient
|
7
7
|
def call(worker_class, msg, queue, _redis_pool)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
::Instana.tracer.log_entry(:'sidekiq-client', kv_payload)
|
8
|
+
kvs = { :'sidekiq-client' => {} }
|
9
|
+
kvs[:'sidekiq-client'][:queue] = queue
|
10
|
+
kvs[:'sidekiq-client'][:job] = worker_class.to_s
|
11
|
+
kvs[:'sidekiq-client'][:retry] = msg['retry'].to_s
|
13
12
|
|
14
13
|
# Temporary until we move connection collection to redis
|
15
14
|
# instrumentation
|
@@ -24,24 +23,27 @@ module Instana
|
|
24
23
|
else # Unexpected version, continue without recording any redis-url
|
25
24
|
break
|
26
25
|
end
|
27
|
-
|
26
|
+
kvs[:'sidekiq-client'][:'redis-url'] = "#{host}:#{port}"
|
28
27
|
end
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
Instana.tracer.in_span(:'sidekiq-client', attributes: kvs) do |span|
|
30
|
+
context = ::Instana.tracer.context
|
31
|
+
if context
|
32
|
+
msg['X-Instana-T'] = context.trace_id_header
|
33
|
+
msg['X-Instana-S'] = context.span_id_header
|
34
|
+
end
|
35
|
+
|
36
|
+
result = yield
|
35
37
|
|
36
|
-
|
38
|
+
if result && result['jid']
|
39
|
+
span.set_tag(:'sidekiq-client', { job_id: result['jid'] })
|
40
|
+
end
|
37
41
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
ensure
|
44
|
-
::Instana.tracer.log_exit(:'sidekiq-client', kv_payload)
|
42
|
+
result
|
43
|
+
rescue => e
|
44
|
+
span.record_exception(e)
|
45
|
+
raise
|
46
|
+
end
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
@@ -5,11 +5,11 @@ module Instana
|
|
5
5
|
module Instrumentation
|
6
6
|
class SidekiqWorker
|
7
7
|
def call(_worker, msg, _queue)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
kvs = { :'sidekiq-worker' => {} }
|
9
|
+
kvs[:'sidekiq-worker'][:job_id] = msg['jid']
|
10
|
+
kvs[:'sidekiq-worker'][:queue] = msg['queue']
|
11
|
+
kvs[:'sidekiq-worker'][:job] = msg['class'].to_s
|
12
|
+
kvs[:'sidekiq-worker'][:retry] = msg['retry'].to_s
|
13
13
|
|
14
14
|
# Temporary until we move connection collection to redis
|
15
15
|
# instrumentation
|
@@ -24,29 +24,30 @@ module Instana
|
|
24
24
|
else # Unexpected version, continue without recording any redis-url
|
25
25
|
break
|
26
26
|
end
|
27
|
-
|
27
|
+
kvs[:'sidekiq-worker'][:'redis-url'] = "#{host}:#{port}"
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
trace_context = nil
|
31
31
|
if msg.key?('X-Instana-T')
|
32
32
|
trace_id = msg.delete('X-Instana-T')
|
33
33
|
span_id = msg.delete('X-Instana-S')
|
34
|
-
|
35
|
-
|
34
|
+
trace_context = ::Instana::SpanContext.new(
|
35
|
+
trace_id: ::Instana::Util.header_to_id(trace_id),
|
36
|
+
span_id: span_id ? ::Instana::Util.header_to_id(span_id) : nil
|
37
|
+
)
|
36
38
|
end
|
37
39
|
|
38
|
-
::
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
::Instana.tracer.log_end(:'sidekiq-worker', {}) if ::Instana.tracer.tracing?
|
40
|
+
parent_non_recording_span = OpenTelemetry::Trace.non_recording_span(trace_context) if trace_context
|
41
|
+
Trace.with_span(parent_non_recording_span) do
|
42
|
+
Instana.tracer.in_span(:'sidekiq-worker', attributes: kvs) do |span|
|
43
|
+
yield
|
44
|
+
rescue => e
|
45
|
+
kvs[:'sidekiq-worker'][:error] = true
|
46
|
+
span.set_tags(kvs)
|
47
|
+
span.record_exception(e)
|
48
|
+
raise
|
49
|
+
end
|
50
|
+
end
|
50
51
|
end
|
51
52
|
end
|
52
53
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2025
|
2
|
+
|
3
|
+
module Instana
|
4
|
+
module Trace
|
5
|
+
module Samplers
|
6
|
+
class Result
|
7
|
+
EMPTY_HASH = {}.freeze
|
8
|
+
attr_reader :tracestate, :attributes
|
9
|
+
|
10
|
+
def initialize(decision:, tracestate:, attributes: nil)
|
11
|
+
@decision = decision
|
12
|
+
@attributes = attributes.freeze || EMPTY_HASH
|
13
|
+
@tracestate = tracestate
|
14
|
+
end
|
15
|
+
|
16
|
+
# Returns true if this span should be sampled.
|
17
|
+
#
|
18
|
+
# @return FALSE always
|
19
|
+
def sampled?
|
20
|
+
false
|
21
|
+
end
|
22
|
+
|
23
|
+
# Returns true if this span should record events, attributes, status, etc.
|
24
|
+
#
|
25
|
+
# returns TRUE always
|
26
|
+
def recording?
|
27
|
+
true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|