instana 1.209.6 → 1.209.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -0
- data/gemfiles/graphql_20.gemfile +18 -0
- data/lib/instana/activators/sidekiq_client.rb +2 -1
- data/lib/instana/activators/sidekiq_worker.rb +2 -1
- data/lib/instana/config.rb +2 -2
- data/lib/instana/instrumentation/graphql.rb +14 -1
- data/lib/instana/instrumentation/instrumented_request.rb +11 -11
- data/lib/instana/version.rb +1 -1
- data/test/instrumentation/graphql_test.rb +155 -26
- data/test/instrumentation/rack_instrumented_request_test.rb +76 -16
- data/test/instrumentation/rack_test.rb +5 -5
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1461b6f3821df0472c4d486c1256069909ed6c833e8016e70e06d14130124704
|
4
|
+
data.tar.gz: 4f6d244e93cd9bdf2b1e3aa895d8824df136123f46a829a02059d4f82c3d0a75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7533b3a686d6f432cfad515c4625b687c4d14d593acc15bde81bae500d1c170582ebaea43a4527807d68f1e70397ede59e0659c3898f1ecaba5c8311095b0110
|
7
|
+
data.tar.gz: 55e6433ff8f6eb247ef63d1b9d8321e4c82aefd94c8838347bdae07fbac6d3d01903a60db6df32b36430bc351b375f5a8e1630a1d34adf15053dcb28152d71de
|
data/.circleci/config.yml
CHANGED
@@ -191,6 +191,7 @@ workflows:
|
|
191
191
|
- "./gemfiles/excon_02.gemfile"
|
192
192
|
- "./gemfiles/excon_079.gemfile"
|
193
193
|
- "./gemfiles/graphql_10.gemfile"
|
194
|
+
- "./gemfiles/graphql_20.gemfile"
|
194
195
|
- "./gemfiles/grpc_10.gemfile"
|
195
196
|
- "./gemfiles/net_http_01.gemfile"
|
196
197
|
- "./gemfiles/rack_16.gemfile"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
# (c) Copyright IBM Corp. 2021
|
4
|
+
# (c) Copyright Instana Inc. 2021
|
5
|
+
|
6
|
+
source "https://rubygems.org"
|
7
|
+
|
8
|
+
gem "rake"
|
9
|
+
gem "minitest", "5.9.1"
|
10
|
+
gem "minitest-reporters"
|
11
|
+
gem "webmock"
|
12
|
+
gem "puma"
|
13
|
+
gem "rubocop", "~> 1.9"
|
14
|
+
gem "rack-test"
|
15
|
+
gem "simplecov", "~> 0.21.2"
|
16
|
+
gem "graphql", ">= 2.0.21", "< 3.0"
|
17
|
+
|
18
|
+
gemspec path: "../"
|
@@ -5,7 +5,8 @@ module Instana
|
|
5
5
|
module Activators
|
6
6
|
class SidekiqClient < Activator
|
7
7
|
def can_instrument?
|
8
|
-
defined?(::Sidekiq) && ::Sidekiq.respond_to?(:configure_client) && ::Instana.config[:'sidekiq-client'][:enabled]
|
8
|
+
defined?(::Sidekiq) && ::Sidekiq.respond_to?(:configure_client) && ::Instana.config[:'sidekiq-client'][:enabled] &&
|
9
|
+
Gem::Specification.find_by_name('sidekiq').version < Gem::Version.new('5.3')
|
9
10
|
end
|
10
11
|
|
11
12
|
def instrument
|
@@ -5,7 +5,8 @@ module Instana
|
|
5
5
|
module Activators
|
6
6
|
class SidekiqWorker < Activator
|
7
7
|
def can_instrument?
|
8
|
-
defined?(::Sidekiq) && ::Sidekiq.respond_to?(:configure_server) && ::Instana.config[:'sidekiq-worker'][:enabled]
|
8
|
+
defined?(::Sidekiq) && ::Sidekiq.respond_to?(:configure_server) && ::Instana.config[:'sidekiq-worker'][:enabled] &&
|
9
|
+
Gem::Specification.find_by_name('sidekiq').version < Gem::Version.new('5.3')
|
9
10
|
end
|
10
11
|
|
11
12
|
def instrument
|
data/lib/instana/config.rb
CHANGED
@@ -53,8 +53,8 @@ module Instana
|
|
53
53
|
# ::Instana.config[:sanitize_sql] = false
|
54
54
|
@config[:sanitize_sql] = true
|
55
55
|
|
56
|
-
#
|
57
|
-
@config[:
|
56
|
+
# W3C Trace Context Support
|
57
|
+
@config[:w3c_trace_correlation] = ENV['INSTANA_DISABLE_W3C_TRACE_CORRELATION'].nil?
|
58
58
|
|
59
59
|
@config[:post_fork_proc] = proc { ::Instana.agent.spawn_background_thread }
|
60
60
|
|
@@ -63,7 +63,20 @@ module Instana
|
|
63
63
|
return [] unless parent.respond_to?(method)
|
64
64
|
|
65
65
|
parent.send(method).map do |field|
|
66
|
-
|
66
|
+
# Certain types like GraphQL::Language::Nodes::InlineFragment
|
67
|
+
# have no "name" instance variable defined,
|
68
|
+
# in such case we use the class's name
|
69
|
+
parent_name = if parent.instance_variable_defined?(:@name)
|
70
|
+
parent.name
|
71
|
+
else
|
72
|
+
parent.class.name.split('::').last
|
73
|
+
end
|
74
|
+
field_name = if field.instance_variable_defined?(:@name)
|
75
|
+
field.name
|
76
|
+
else
|
77
|
+
field.class.name.split('::').last
|
78
|
+
end
|
79
|
+
[{object: parent_name, field: field_name}] + walk_fields(field, method)
|
67
80
|
end.flatten
|
68
81
|
end
|
69
82
|
|
@@ -9,7 +9,7 @@ require 'rack/request'
|
|
9
9
|
|
10
10
|
module Instana
|
11
11
|
class InstrumentedRequest < Rack::Request
|
12
|
-
|
12
|
+
W3C_TRACE_PARENT_FORMAT = /[0-9a-f][0-9a-e]-(?<trace>[0-9a-f]{32})-(?<parent>[0-9a-f]{16})-(?<flags>[0-9a-f]{2})/.freeze
|
13
13
|
INSTANA_TRACE_STATE = /in=(?<trace>[0-9a-f]+);(?<span>[0-9a-f]+)/.freeze
|
14
14
|
|
15
15
|
def skip_trace?
|
@@ -32,16 +32,16 @@ module Instana
|
|
32
32
|
|
33
33
|
context[:level] = @env['HTTP_X_INSTANA_L'][0] if @env['HTTP_X_INSTANA_L']
|
34
34
|
|
35
|
-
unless ::Instana.config[:
|
35
|
+
unless ::Instana.config[:w3c_trace_correlation]
|
36
36
|
trace_state = parse_trace_state
|
37
37
|
|
38
|
-
if context[:
|
38
|
+
if context[:from_w3c] && trace_state.empty?
|
39
39
|
context.delete(:span_id)
|
40
|
-
context[:
|
41
|
-
elsif context[:
|
40
|
+
context[:from_w3c] = false
|
41
|
+
elsif context[:from_w3c] && !trace_state.empty?
|
42
42
|
context[:trace_id] = trace_state[:t]
|
43
43
|
context[:span_id] = trace_state[:p]
|
44
|
-
context[:
|
44
|
+
context[:from_w3c] = false
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -86,7 +86,7 @@ module Instana
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def continuing_from_trace_parent?
|
89
|
-
incoming_context[:
|
89
|
+
incoming_context[:from_w3c]
|
90
90
|
end
|
91
91
|
|
92
92
|
def synthetic?
|
@@ -122,13 +122,13 @@ 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
|
-
|
125
|
+
from_w3c: false
|
126
126
|
}.reject { |_, v| v.nil? }
|
127
127
|
end
|
128
128
|
|
129
129
|
def context_from_trace_parent
|
130
130
|
return {} unless @env.has_key?('HTTP_TRACEPARENT')
|
131
|
-
matches = @env['HTTP_TRACEPARENT'].match(
|
131
|
+
matches = @env['HTTP_TRACEPARENT'].match(W3C_TRACE_PARENT_FORMAT)
|
132
132
|
return {} unless matches
|
133
133
|
return {} if matches_is_invalid(matches)
|
134
134
|
|
@@ -140,7 +140,7 @@ module Instana
|
|
140
140
|
external_state: @env['HTTP_TRACESTATE'],
|
141
141
|
trace_id: trace_id,
|
142
142
|
span_id: span_id,
|
143
|
-
|
143
|
+
from_w3c: true
|
144
144
|
}
|
145
145
|
end
|
146
146
|
|
@@ -154,7 +154,7 @@ module Instana
|
|
154
154
|
{
|
155
155
|
trace_id: state[:t],
|
156
156
|
span_id: state[:p],
|
157
|
-
|
157
|
+
from_w3c: false
|
158
158
|
}.reject { |_, v| v.nil? }
|
159
159
|
end
|
160
160
|
|
data/lib/instana/version.rb
CHANGED
@@ -8,84 +8,213 @@ class GraphqlTest < Minitest::Test
|
|
8
8
|
field :id, ID, null: false
|
9
9
|
field :action, String, null: false
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
|
+
class JobType < GraphQL::Schema::Object
|
13
|
+
field :id, ID, null: false
|
14
|
+
field :name, String, null: false
|
15
|
+
field :description, String, null: false
|
16
|
+
end
|
17
|
+
|
18
|
+
class TaskJobUnion < GraphQL::Schema::Union
|
19
|
+
description "A union type for Task and Job"
|
20
|
+
possible_types TaskType, JobType
|
21
|
+
|
22
|
+
def self.resolve_type(object, _context)
|
23
|
+
if !object.action.nil?
|
24
|
+
TaskType
|
25
|
+
elsif !object.description?
|
26
|
+
JobType
|
27
|
+
else
|
28
|
+
raise("Unexpected object: #{object}")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
12
33
|
class NewTaskType < GraphQL::Schema::Mutation
|
13
34
|
argument :action, String, required: true
|
14
35
|
field :task, TaskType, null: true
|
15
|
-
|
36
|
+
|
16
37
|
def resolve(action:)
|
17
38
|
{
|
18
39
|
task: OpenStruct.new(id: '0', action: action)
|
19
40
|
}
|
20
41
|
end
|
21
42
|
end
|
22
|
-
|
43
|
+
|
23
44
|
class QueryType < GraphQL::Schema::Object
|
24
45
|
field :tasks, TaskType.connection_type, null: false
|
25
|
-
|
46
|
+
field :jobs, JobType.connection_type, null: false
|
47
|
+
field :tasksorjobs, TaskJobUnion.connection_type, null: false
|
48
|
+
|
26
49
|
def tasks()
|
27
50
|
[
|
28
|
-
OpenStruct.new(id: '0', action: 'Sample')
|
51
|
+
OpenStruct.new(id: '0', action: 'Sample 00'),
|
52
|
+
OpenStruct.new(id: '1', action: 'Sample 01'),
|
53
|
+
OpenStruct.new(id: '2', action: 'Sample 02'),
|
54
|
+
OpenStruct.new(id: '3', action: 'Sample 03'),
|
55
|
+
OpenStruct.new(id: '4', action: 'Sample 04')
|
56
|
+
]
|
57
|
+
end
|
58
|
+
|
59
|
+
def jobs()
|
60
|
+
[
|
61
|
+
OpenStruct.new(id: '0', name: 'Name 00', description: 'Desc 00'),
|
62
|
+
OpenStruct.new(id: '1', name: 'Name 01', description: 'Desc 01'),
|
63
|
+
OpenStruct.new(id: '2', name: 'Name 02', description: 'Desc 02'),
|
64
|
+
OpenStruct.new(id: '3', name: 'Name 03', description: 'Desc 03'),
|
65
|
+
OpenStruct.new(id: '4', name: 'Name 04', description: 'Desc 04')
|
66
|
+
]
|
67
|
+
end
|
68
|
+
|
69
|
+
def tasksorjobs()
|
70
|
+
[
|
71
|
+
OpenStruct.new(id: '0', action: 'Task 00'),
|
72
|
+
OpenStruct.new(id: '0', name: 'Job 00', description: 'Job Desc 00')
|
29
73
|
]
|
30
74
|
end
|
31
75
|
end
|
32
|
-
|
76
|
+
|
33
77
|
class MutationType < GraphQL::Schema::Object
|
34
78
|
field :create_task, mutation: NewTaskType
|
35
79
|
end
|
36
|
-
|
80
|
+
|
37
81
|
class Schema < GraphQL::Schema
|
38
82
|
query QueryType
|
39
83
|
mutation MutationType
|
40
84
|
end
|
41
|
-
|
85
|
+
|
42
86
|
def test_it_works
|
43
87
|
assert defined?(GraphQL)
|
44
88
|
end
|
45
|
-
|
46
|
-
def test_config_defaults
|
89
|
+
|
90
|
+
def test_config_defaults
|
47
91
|
assert ::Instana.config[:graphql].is_a?(Hash)
|
48
92
|
assert ::Instana.config[:graphql].key?(:enabled)
|
49
93
|
assert_equal true, ::Instana.config[:graphql][:enabled]
|
50
94
|
end
|
51
|
-
|
95
|
+
|
52
96
|
def test_query
|
53
97
|
clear_all!
|
54
|
-
|
55
|
-
query = "query
|
56
|
-
tasks(after: \"\", first:
|
98
|
+
|
99
|
+
query = "query FirstTwoTaskSamples {
|
100
|
+
tasks(after: \"\", first: 2) {
|
57
101
|
nodes {
|
58
102
|
action
|
59
103
|
}
|
60
104
|
}
|
61
105
|
}"
|
62
|
-
|
106
|
+
|
63
107
|
expected_data = {
|
64
|
-
:operationName => "
|
108
|
+
:operationName => "FirstTwoTaskSamples",
|
65
109
|
:operationType => "query",
|
66
110
|
:arguments => { "tasks" => ["after", "first"] },
|
67
111
|
:fields => { "tasks" => ["nodes"], "nodes" => ["action"] }
|
68
112
|
}
|
69
113
|
expected_results = {
|
70
114
|
"data" => {
|
71
|
-
"tasks" => {
|
72
|
-
"nodes" => [{ "action" => "Sample"
|
115
|
+
"tasks" => {
|
116
|
+
"nodes" => [{"action" => "Sample 00"}, {"action" => "Sample 01"}]
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
results = Instana.tracer.start_or_continue_trace('graphql-test') { Schema.execute(query) }
|
122
|
+
query_span, root_span = *Instana.processor.queued_spans
|
123
|
+
|
124
|
+
assert_equal expected_results, results.to_h
|
125
|
+
assert_equal :sdk, root_span[:n]
|
126
|
+
assert_equal :'graphql.server', query_span[:n]
|
127
|
+
assert_equal expected_data, query_span[:data][:graphql]
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_query_with_fragment
|
131
|
+
clear_all!
|
132
|
+
|
133
|
+
query = "
|
134
|
+
fragment actionDetails on Task {
|
135
|
+
action
|
136
|
+
}
|
137
|
+
|
138
|
+
query SampleWithFragment {
|
139
|
+
tasks {
|
140
|
+
nodes {
|
141
|
+
... actionDetails
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}"
|
145
|
+
|
146
|
+
expected_data = {
|
147
|
+
:operationName => "SampleWithFragment",
|
148
|
+
:operationType => "query",
|
149
|
+
:arguments => {},
|
150
|
+
:fields => { "tasks" => ["nodes"], "nodes" => ["actionDetails"] }
|
151
|
+
}
|
152
|
+
expected_results = {
|
153
|
+
"data" => {
|
154
|
+
"tasks" => {
|
155
|
+
"nodes" => [{"action" => "Sample 00"}, {"action" => "Sample 01"},
|
156
|
+
{"action" => "Sample 02"}, {"action" => "Sample 03"},
|
157
|
+
{"action" => "Sample 04"}]
|
73
158
|
}
|
74
159
|
}
|
75
160
|
}
|
76
|
-
|
161
|
+
|
77
162
|
results = Instana.tracer.start_or_continue_trace('graphql-test') { Schema.execute(query) }
|
78
163
|
query_span, root_span = *Instana.processor.queued_spans
|
79
|
-
|
164
|
+
|
80
165
|
assert_equal expected_results, results.to_h
|
81
166
|
assert_equal :sdk, root_span[:n]
|
82
167
|
assert_equal :'graphql.server', query_span[:n]
|
83
168
|
assert_equal expected_data, query_span[:data][:graphql]
|
84
169
|
end
|
85
|
-
|
170
|
+
|
171
|
+
def test_query_union_with_fragment
|
172
|
+
clear_all!
|
173
|
+
|
174
|
+
query = "
|
175
|
+
query QueryUnionWithFragment {
|
176
|
+
tasksorjobs {
|
177
|
+
nodes {
|
178
|
+
... on Task {
|
179
|
+
action
|
180
|
+
}
|
181
|
+
... on Job {
|
182
|
+
name
|
183
|
+
description
|
184
|
+
}
|
185
|
+
}
|
186
|
+
}
|
187
|
+
}"
|
188
|
+
|
189
|
+
expected_data = {
|
190
|
+
:operationName => "QueryUnionWithFragment",
|
191
|
+
:operationType => "query",
|
192
|
+
:arguments => {},
|
193
|
+
:fields => { "tasksorjobs" => ["nodes"],
|
194
|
+
"nodes" => ["InlineFragment", "InlineFragment"],
|
195
|
+
"InlineFragment" => %w[action name description]}
|
196
|
+
}
|
197
|
+
expected_results = {
|
198
|
+
"data" => {
|
199
|
+
"tasksorjobs" => {
|
200
|
+
"nodes" => [{"action" => "Task 00"},
|
201
|
+
{"name" => "Job 00", "description" => "Job Desc 00"}]
|
202
|
+
}
|
203
|
+
}
|
204
|
+
}
|
205
|
+
|
206
|
+
results = Instana.tracer.start_or_continue_trace('graphql-test') { Schema.execute(query) }
|
207
|
+
query_span, root_span = *Instana.processor.queued_spans
|
208
|
+
|
209
|
+
assert_equal expected_results, results.to_h
|
210
|
+
assert_equal :sdk, root_span[:n]
|
211
|
+
assert_equal :'graphql.server', query_span[:n]
|
212
|
+
assert_equal expected_data, query_span[:data][:graphql]
|
213
|
+
end
|
214
|
+
|
86
215
|
def test_mutation
|
87
216
|
clear_all!
|
88
|
-
|
217
|
+
|
89
218
|
query = "mutation Sample {
|
90
219
|
createTask(action: \"Sample\") {
|
91
220
|
task {
|
@@ -93,7 +222,7 @@ class GraphqlTest < Minitest::Test
|
|
93
222
|
}
|
94
223
|
}
|
95
224
|
}"
|
96
|
-
|
225
|
+
|
97
226
|
expected_data = {
|
98
227
|
:operationName => "Sample",
|
99
228
|
:operationType => "mutation",
|
@@ -102,15 +231,15 @@ class GraphqlTest < Minitest::Test
|
|
102
231
|
}
|
103
232
|
expected_results = {
|
104
233
|
"data" => {
|
105
|
-
"createTask" => {
|
234
|
+
"createTask" => {
|
106
235
|
"task" => { "action" => "Sample" }
|
107
236
|
}
|
108
237
|
}
|
109
238
|
}
|
110
|
-
|
239
|
+
|
111
240
|
results = Instana.tracer.start_or_continue_trace('graphql-test') { Schema.execute(query) }
|
112
241
|
query_span, root_span = *Instana.processor.queued_spans
|
113
|
-
|
242
|
+
|
114
243
|
assert_equal expected_results, results.to_h
|
115
244
|
assert_equal :sdk, root_span[:n]
|
116
245
|
assert_equal :'graphql.server', query_span[:n]
|
@@ -4,7 +4,15 @@
|
|
4
4
|
require 'test_helper'
|
5
5
|
|
6
6
|
class RackInstrumentedRequestTest < Minitest::Test
|
7
|
-
def
|
7
|
+
def test_suppression_via_x_instana_l
|
8
|
+
req = Instana::InstrumentedRequest.new(
|
9
|
+
'HTTP_X_INSTANA_L' => '0'
|
10
|
+
)
|
11
|
+
|
12
|
+
assert req.skip_trace?
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_suppression_via_x_instana_l_with_trailing_content
|
8
16
|
req = Instana::InstrumentedRequest.new(
|
9
17
|
'HTTP_X_INSTANA_L' => '0;sample-data'
|
10
18
|
)
|
@@ -12,6 +20,20 @@ class RackInstrumentedRequestTest < Minitest::Test
|
|
12
20
|
assert req.skip_trace?
|
13
21
|
end
|
14
22
|
|
23
|
+
def test_no_suppression_assume_level_1_as_default
|
24
|
+
req = Instana::InstrumentedRequest.new({})
|
25
|
+
|
26
|
+
assert !req.skip_trace?
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_no_suppression_when_x_instana_l_is_provided_explicitly
|
30
|
+
req = Instana::InstrumentedRequest.new(
|
31
|
+
'HTTP_X_INSTANA_L' => '1'
|
32
|
+
)
|
33
|
+
|
34
|
+
assert !req.skip_trace?
|
35
|
+
end
|
36
|
+
|
15
37
|
def test_skip_trace_without_header
|
16
38
|
req = Instana::InstrumentedRequest.new({})
|
17
39
|
|
@@ -29,7 +51,7 @@ class RackInstrumentedRequestTest < Minitest::Test
|
|
29
51
|
expected = {
|
30
52
|
trace_id: id,
|
31
53
|
span_id: id,
|
32
|
-
|
54
|
+
from_w3c: false,
|
33
55
|
level: '1'
|
34
56
|
}
|
35
57
|
|
@@ -37,9 +59,8 @@ class RackInstrumentedRequestTest < Minitest::Test
|
|
37
59
|
refute req.continuing_from_trace_parent?
|
38
60
|
end
|
39
61
|
|
40
|
-
def
|
62
|
+
def test_incoming_w3c_context
|
41
63
|
req = Instana::InstrumentedRequest.new(
|
42
|
-
'HTTP_X_INSTANA_L' => '1',
|
43
64
|
'HTTP_TRACEPARENT' => '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01'
|
44
65
|
)
|
45
66
|
|
@@ -48,42 +69,81 @@ class RackInstrumentedRequestTest < Minitest::Test
|
|
48
69
|
external_state: nil,
|
49
70
|
trace_id: 'a3ce929d0e0e4736',
|
50
71
|
span_id: '00f067aa0ba902b7',
|
51
|
-
|
52
|
-
level: '1'
|
72
|
+
from_w3c: true
|
53
73
|
}
|
54
74
|
|
55
75
|
assert_equal expected, req.incoming_context
|
56
76
|
assert req.continuing_from_trace_parent?
|
57
77
|
end
|
58
78
|
|
59
|
-
def
|
79
|
+
def test_incoming_w3c_context_newer_version_additional_fields
|
60
80
|
req = Instana::InstrumentedRequest.new(
|
61
|
-
'
|
62
|
-
'HTTP_TRACEPARENT' => '00-00000000000000000000000000000000-0000000000000000-01'
|
81
|
+
'HTTP_TRACEPARENT' => 'fe-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01-abcdefg'
|
63
82
|
)
|
64
83
|
|
65
84
|
expected = {
|
66
|
-
|
85
|
+
external_trace_id: '4bf92f3577b34da6a3ce929d0e0e4736',
|
86
|
+
external_state: nil,
|
87
|
+
trace_id: 'a3ce929d0e0e4736',
|
88
|
+
span_id: '00f067aa0ba902b7',
|
89
|
+
from_w3c: true
|
67
90
|
}
|
68
91
|
|
69
92
|
assert_equal expected, req.incoming_context
|
70
|
-
|
93
|
+
assert req.continuing_from_trace_parent?
|
71
94
|
end
|
72
95
|
|
73
|
-
def
|
96
|
+
def test_incoming_w3c_context_unknown_flags
|
74
97
|
req = Instana::InstrumentedRequest.new(
|
75
|
-
'
|
76
|
-
'HTTP_TRACEPARENT' => '00-XXa3ce929d0e0e4736-00f67aa0ba902b7-01'
|
98
|
+
'HTTP_TRACEPARENT' => '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-ff'
|
77
99
|
)
|
78
100
|
|
79
101
|
expected = {
|
80
|
-
|
102
|
+
external_trace_id: '4bf92f3577b34da6a3ce929d0e0e4736',
|
103
|
+
external_state: nil,
|
104
|
+
trace_id: 'a3ce929d0e0e4736',
|
105
|
+
span_id: '00f067aa0ba902b7',
|
106
|
+
from_w3c: true
|
81
107
|
}
|
82
108
|
|
83
109
|
assert_equal expected, req.incoming_context
|
110
|
+
assert req.continuing_from_trace_parent?
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_incoming_w3c_context_invalid_version
|
114
|
+
req = Instana::InstrumentedRequest.new(
|
115
|
+
'HTTP_TRACEPARENT' => 'ff-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01'
|
116
|
+
)
|
117
|
+
|
118
|
+
expected = {}
|
119
|
+
|
120
|
+
assert_equal expected, req.incoming_context
|
121
|
+
refute req.continuing_from_trace_parent?
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_incoming_w3c_context_invalid_id
|
125
|
+
req = Instana::InstrumentedRequest.new(
|
126
|
+
'HTTP_TRACEPARENT' => '00-00000000000000000000000000000000-0000000000000000-01'
|
127
|
+
)
|
128
|
+
|
129
|
+
expected = {}
|
130
|
+
|
131
|
+
assert_equal expected, req.incoming_context
|
132
|
+
refute req.continuing_from_trace_parent?
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_incoming_invalid_w3c_context
|
136
|
+
req = Instana::InstrumentedRequest.new(
|
137
|
+
'HTTP_TRACEPARENT' => '00-XXa3ce929d0e0e4736-00f67aa0ba902b7-01'
|
138
|
+
)
|
139
|
+
|
140
|
+
expected = {}
|
141
|
+
|
142
|
+
assert_equal expected, req.incoming_context
|
143
|
+
refute req.continuing_from_trace_parent?
|
84
144
|
end
|
85
145
|
|
86
|
-
def
|
146
|
+
def test_incoming_w3c_state
|
87
147
|
req = Instana::InstrumentedRequest.new(
|
88
148
|
'HTTP_TRACESTATE' => 'a=12345,in=123;abe,c=[+]'
|
89
149
|
)
|
@@ -69,7 +69,7 @@ class RackTest < Minitest::Test
|
|
69
69
|
assert last_response.headers.key?("Server-Timing")
|
70
70
|
assert last_response.headers["Server-Timing"] == "intid;desc=#{::Instana::Util.id_to_header(rack_span[:t])}"
|
71
71
|
|
72
|
-
#
|
72
|
+
# W3C Trace Context
|
73
73
|
assert_equal "00-#{rack_span[:t].rjust(32, '0')}-#{rack_span[:s]}-01", last_response.headers["Traceparent"]
|
74
74
|
assert_equal "in=#{rack_span[:t]};#{rack_span[:s]}", last_response.headers["Tracestate"]
|
75
75
|
|
@@ -301,7 +301,7 @@ class RackTest < Minitest::Test
|
|
301
301
|
assert_equal true, first_span[:sy]
|
302
302
|
end
|
303
303
|
|
304
|
-
def
|
304
|
+
def test_basic_get_with_w3c_trace
|
305
305
|
clear_all!
|
306
306
|
|
307
307
|
header 'TRACEPARENT', '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01'
|
@@ -321,9 +321,9 @@ class RackTest < Minitest::Test
|
|
321
321
|
assert first_span[:tp]
|
322
322
|
end
|
323
323
|
|
324
|
-
def
|
324
|
+
def test_basic_get_with_w3c_disabled
|
325
325
|
clear_all!
|
326
|
-
::Instana.config[:
|
326
|
+
::Instana.config[:w3c_trace_correlation] = false
|
327
327
|
|
328
328
|
header 'TRACEPARENT', '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01'
|
329
329
|
|
@@ -336,7 +336,7 @@ class RackTest < Minitest::Test
|
|
336
336
|
first_span = spans.first
|
337
337
|
assert_equal :rack, first_span[:n]
|
338
338
|
refute first_span[:tp]
|
339
|
-
::Instana.config[:
|
339
|
+
::Instana.config[:w3c_trace_correlation] = true
|
340
340
|
end
|
341
341
|
|
342
342
|
def test_skip_trace
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: instana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.209.
|
4
|
+
version: 1.209.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Giacomo Lombardo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- gemfiles/excon_021.gemfile
|
164
164
|
- gemfiles/excon_079.gemfile
|
165
165
|
- gemfiles/graphql_10.gemfile
|
166
|
+
- gemfiles/graphql_20.gemfile
|
166
167
|
- gemfiles/grpc_10.gemfile
|
167
168
|
- gemfiles/mongo_216.gemfile
|
168
169
|
- gemfiles/net_http_01.gemfile
|