instana 1.193.2 → 1.193.6
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 +204 -133
- data/.gitignore +3 -0
- data/.rubocop.yml +10 -1145
- data/.rubocop_todo.yml +1140 -0
- data/Appraisals +107 -0
- data/Gemfile +14 -32
- data/LICENSE +2 -1
- data/Rakefile +19 -39
- data/benchmarks/10k-rack-traces.rb +3 -0
- data/benchmarks/Gemfile +4 -0
- data/benchmarks/id_generation.rb +4 -0
- data/benchmarks/opentracing.rb +4 -0
- data/benchmarks/rack_vanilla_vs_traced.rb +3 -0
- data/benchmarks/stackprof_rack_tracing.rb +3 -0
- data/benchmarks/time_processing.rb +4 -0
- data/bin/console +8 -4
- data/examples/opentracing.rb +4 -0
- data/examples/tracing.rb +4 -0
- data/extras/license_header.rb +44 -0
- data/gemfiles/.bundle/config +1 -2
- data/gemfiles/aws_30.gemfile +18 -0
- data/gemfiles/cuba_30.gemfile +18 -0
- data/gemfiles/dalli_20.gemfile +18 -0
- data/gemfiles/excon_02.gemfile +18 -0
- data/gemfiles/graphql_10.gemfile +18 -0
- data/gemfiles/grpc_10.gemfile +18 -0
- data/gemfiles/net_http_01.gemfile +17 -0
- data/gemfiles/rack_16.gemfile +18 -0
- data/gemfiles/rack_20.gemfile +18 -0
- data/gemfiles/rails_42.gemfile +21 -0
- data/gemfiles/rails_50.gemfile +21 -0
- data/gemfiles/rails_52.gemfile +21 -0
- data/gemfiles/rails_60.gemfile +21 -0
- data/gemfiles/redis_40.gemfile +18 -0
- data/gemfiles/resque_122.gemfile +19 -0
- data/gemfiles/resque_20.gemfile +18 -0
- data/gemfiles/rest_client_16.gemfile +18 -0
- data/gemfiles/rest_client_20.gemfile +18 -0
- data/gemfiles/roda_20.gemfile +18 -0
- data/gemfiles/roda_30.gemfile +18 -0
- data/gemfiles/sidekiq_42.gemfile +18 -0
- data/gemfiles/sidekiq_50.gemfile +18 -0
- data/gemfiles/sinatra_14.gemfile +18 -0
- data/instana.gemspec +5 -7
- data/lib/instana.rb +3 -0
- data/lib/instana/activator.rb +44 -0
- data/lib/instana/activators/action_cable.rb +24 -0
- data/lib/instana/activators/action_controller_api.rb +21 -0
- data/lib/instana/activators/action_controller_base.rb +21 -0
- data/lib/instana/activators/action_view.rb +21 -0
- data/lib/instana/activators/active_record.rb +21 -0
- data/lib/instana/activators/aws_sdk_dynamodb.rb +20 -0
- data/lib/instana/activators/cuba.rb +21 -0
- data/lib/instana/activators/dalli.rb +23 -0
- data/lib/instana/activators/excon.rb +20 -0
- data/lib/instana/activators/graphql.rb +22 -0
- data/lib/instana/activators/grpc_client.rb +20 -0
- data/lib/instana/activators/grpc_server.rb +20 -0
- data/lib/instana/activators/net_http.rb +20 -0
- data/lib/instana/activators/rack.rb +16 -0
- data/lib/instana/activators/rails.rb +18 -0
- data/lib/instana/activators/redis.rb +20 -0
- data/lib/instana/activators/resque_client.rb +21 -0
- data/lib/instana/activators/resque_worker.rb +33 -0
- data/lib/instana/activators/rest_client.rb +20 -0
- data/lib/instana/activators/roda.rb +21 -0
- data/lib/instana/activators/sidekiq_client.rb +24 -0
- data/lib/instana/activators/sidekiq_worker.rb +24 -0
- data/lib/instana/activators/sinatra.rb +21 -0
- data/lib/instana/agent.rb +3 -0
- data/lib/instana/agent/helpers.rb +3 -0
- data/lib/instana/agent/hooks.rb +3 -0
- data/lib/instana/agent/tasks.rb +3 -0
- data/lib/instana/base.rb +3 -0
- data/lib/instana/collector.rb +3 -0
- data/lib/instana/collectors/gc.rb +3 -0
- data/lib/instana/collectors/memory.rb +3 -0
- data/lib/instana/collectors/thread.rb +3 -0
- data/lib/instana/config.rb +3 -0
- data/lib/instana/frameworks/cuba.rb +9 -13
- data/lib/instana/frameworks/rails.rb +22 -32
- data/lib/instana/frameworks/roda.rb +10 -13
- data/lib/instana/frameworks/sinatra.rb +4 -8
- data/lib/instana/helpers.rb +3 -0
- data/lib/instana/instrumentation/action_cable.rb +53 -0
- data/lib/instana/instrumentation/action_controller.rb +84 -0
- data/lib/instana/instrumentation/action_view.rb +30 -0
- data/lib/instana/instrumentation/active_record.rb +50 -0
- data/lib/instana/instrumentation/aws_sdk_dynamodb.rb +29 -0
- data/lib/instana/instrumentation/dalli.rb +3 -6
- data/lib/instana/instrumentation/excon.rb +54 -57
- data/lib/instana/instrumentation/graphql.rb +19 -18
- data/lib/instana/instrumentation/grpc.rb +7 -10
- data/lib/instana/instrumentation/instrumented_request.rb +6 -1
- data/lib/instana/instrumentation/net-http.rb +6 -6
- data/lib/instana/instrumentation/rack.rb +4 -0
- data/lib/instana/instrumentation/redis.rb +3 -5
- data/lib/instana/instrumentation/resque.rb +3 -25
- data/lib/instana/instrumentation/rest-client.rb +3 -5
- data/lib/instana/instrumentation/sidekiq-client.rb +4 -10
- data/lib/instana/instrumentation/sidekiq-worker.rb +4 -10
- data/lib/instana/opentracing/carrier.rb +3 -0
- data/lib/instana/opentracing/tracer.rb +3 -0
- data/lib/instana/rack.rb +4 -0
- data/lib/instana/secrets.rb +3 -0
- data/lib/instana/setup.rb +6 -1
- data/lib/instana/thread_local.rb +3 -0
- data/lib/instana/tracer.rb +3 -0
- data/lib/instana/tracing/processor.rb +3 -0
- data/lib/instana/tracing/span.rb +11 -2
- data/lib/instana/tracing/span_context.rb +3 -0
- data/lib/instana/util.rb +3 -0
- data/lib/instana/version.rb +4 -1
- data/lib/oj_check.rb +3 -0
- data/lib/opentracing.rb +3 -0
- data/test/activator_test.rb +30 -0
- data/test/agent/agent_test.rb +3 -0
- data/test/benchmarks/bench_id_generation.rb +3 -0
- data/test/benchmarks/bench_opentracing.rb +3 -0
- data/test/config_test.rb +3 -0
- data/test/frameworks/cuba_test.rb +41 -40
- data/test/frameworks/roda_test.rb +43 -41
- data/test/frameworks/sinatra_test.rb +64 -64
- data/test/instana_test.rb +3 -0
- data/test/instrumentation/aws_test.rb +33 -0
- data/test/instrumentation/dalli_test.rb +3 -0
- data/test/instrumentation/excon_test.rb +4 -0
- data/test/instrumentation/graphql_test.rb +3 -0
- data/test/instrumentation/grpc_test.rb +5 -1
- data/test/instrumentation/{net-http_test.rb → net_http_test.rb} +4 -0
- data/test/instrumentation/{instrumented_request_test.rb → rack_instrumented_request_test.rb} +4 -1
- data/test/{frameworks → instrumentation}/rack_test.rb +3 -1
- data/test/instrumentation/rails_action_cable_test.rb +131 -0
- data/test/{frameworks/rails/actioncontroller_test.rb → instrumentation/rails_action_controller_test.rb} +40 -21
- data/test/instrumentation/rails_action_view_test.rb +151 -0
- data/test/instrumentation/rails_active_record_test.rb +122 -0
- data/test/instrumentation/redis_test.rb +3 -0
- data/test/instrumentation/resque_test.rb +6 -11
- data/test/instrumentation/{rest-client_test.rb → rest_client_test.rb} +9 -0
- data/test/instrumentation/sidekiq-client_test.rb +4 -0
- data/test/instrumentation/sidekiq-worker_test.rb +4 -0
- data/test/secrets_test.rb +3 -0
- data/test/support/apps/active_record/active_record.rb +24 -0
- data/test/{servers/grpc_50051.rb → support/apps/grpc/boot.rb} +4 -1
- data/test/{apps → support/apps/grpc}/grpc_server.rb +3 -0
- data/test/{servers/rackapp_6511.rb → support/apps/http_endpoint/boot.rb} +3 -0
- data/test/{servers/rails_3205.rb → support/apps/rails/boot.rb} +10 -13
- data/test/{models → support/apps/rails/models}/block.rb +4 -1
- data/test/{models → support/apps/rails/models}/block6.rb +3 -0
- data/test/support/apps/resque/boot.rb +5 -0
- data/test/{jobs → support/apps/resque/jobs}/resque_error_job.rb +3 -0
- data/test/{jobs → support/apps/resque/jobs}/resque_fast_job.rb +3 -0
- data/test/support/apps/sidekiq/boot.rb +25 -0
- data/test/{jobs → support/apps/sidekiq/jobs}/sidekiq_job_1.rb +3 -0
- data/test/{jobs → support/apps/sidekiq/jobs}/sidekiq_job_2.rb +3 -0
- data/test/{servers → support/apps}/sidekiq/worker.rb +5 -2
- data/test/support/helpers.rb +97 -0
- data/test/test_helper.rb +27 -138
- data/test/tracing/custom_test.rb +3 -0
- data/test/tracing/id_management_test.rb +4 -0
- data/test/tracing/opentracing_test.rb +3 -0
- data/test/tracing/tracer_async_test.rb +3 -0
- data/test/tracing/tracer_test.rb +3 -0
- metadata +110 -96
- data/gemfiles/libraries.gemfile +0 -73
- data/gemfiles/rails32.gemfile +0 -51
- data/gemfiles/rails42.gemfile +0 -50
- data/gemfiles/rails50.gemfile +0 -52
- data/gemfiles/rails52.gemfile +0 -52
- data/gemfiles/rails60.gemfile +0 -72
- data/lib/instana/frameworks/instrumentation/abstract_mysql_adapter.rb +0 -56
- data/lib/instana/frameworks/instrumentation/action_controller.rb +0 -194
- data/lib/instana/frameworks/instrumentation/action_view.rb +0 -39
- data/lib/instana/frameworks/instrumentation/active_record.rb +0 -27
- data/lib/instana/frameworks/instrumentation/mysql2_adapter.rb +0 -83
- data/lib/instana/frameworks/instrumentation/mysql_adapter.rb +0 -60
- data/lib/instana/frameworks/instrumentation/postgresql_adapter.rb +0 -99
- data/lib/instana/instrumentation.rb +0 -25
- data/lib/instana/test.rb +0 -43
- data/test/apps/cuba.rb +0 -19
- data/test/apps/roda.rb +0 -13
- data/test/apps/sinatra.rb +0 -9
- data/test/frameworks/rails/actionview3_test.rb +0 -210
- data/test/frameworks/rails/actionview4_test.rb +0 -208
- data/test/frameworks/rails/actionview5_test.rb +0 -221
- data/test/frameworks/rails/activerecord_test.rb +0 -279
- data/test/servers/helpers/sidekiq_worker_initializer.rb +0 -27
@@ -0,0 +1,84 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
module Instana
|
5
|
+
module Instrumentation
|
6
|
+
module ActionController
|
7
|
+
def process_action(*args)
|
8
|
+
call_payload = {
|
9
|
+
actioncontroller: {
|
10
|
+
controller: self.class.name,
|
11
|
+
action: action_name
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
request.env['INSTANA_HTTP_PATH_TEMPLATE'] = matched_path_template
|
16
|
+
::Instana::Tracer.trace(:actioncontroller, call_payload) { super(*args) }
|
17
|
+
end
|
18
|
+
|
19
|
+
def render(*args, &block)
|
20
|
+
call_payload = {
|
21
|
+
actionview: {
|
22
|
+
name: describe_render_options(args.first) || 'Default'
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
::Instana::Tracer.trace(:actionview, call_payload) { super(*args, &block) }
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def matched_path_template
|
32
|
+
Rails.application.routes.router.recognize(request) do |route, _, _|
|
33
|
+
path = route.path
|
34
|
+
return path.spec.to_s
|
35
|
+
end
|
36
|
+
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def describe_render_options(options)
|
41
|
+
return unless options.is_a?(Hash)
|
42
|
+
|
43
|
+
describe_layout(options[:layout]) ||
|
44
|
+
describe_direct(options)
|
45
|
+
end
|
46
|
+
|
47
|
+
def describe_layout(layout)
|
48
|
+
return unless layout
|
49
|
+
|
50
|
+
case layout
|
51
|
+
when FalseClass
|
52
|
+
'Without layout'
|
53
|
+
when String
|
54
|
+
layout
|
55
|
+
when Proc
|
56
|
+
'Proc'
|
57
|
+
else
|
58
|
+
'Default'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def describe_direct(options)
|
63
|
+
case options
|
64
|
+
when ->(o) { o.key?(:nothing) }
|
65
|
+
'Nothing'
|
66
|
+
when ->(o) { o.key?(:plain) }
|
67
|
+
'Plaintext'
|
68
|
+
when ->(o) { o.key?(:json) }
|
69
|
+
'JSON'
|
70
|
+
when ->(o) { o.key?(:xml) }
|
71
|
+
'XML'
|
72
|
+
when ->(o) { o.key?(:body) }
|
73
|
+
'Raw'
|
74
|
+
when ->(o) { o.key?(:js) }
|
75
|
+
'Javascript'
|
76
|
+
when ->(o) { o.key?(:template) }
|
77
|
+
options[:template]
|
78
|
+
when ->(o) { o.key?(:file) }
|
79
|
+
options[:file]
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
module Instana
|
5
|
+
module Instrumentation
|
6
|
+
module ActionView
|
7
|
+
def render_partial(*args)
|
8
|
+
call_payload = {
|
9
|
+
render: {
|
10
|
+
type: :partial,
|
11
|
+
name: @options.is_a?(Hash) ? @options[:partial].to_s : 'Unknown'
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
::Instana::Tracer.trace(:render, call_payload) { super(*args) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def render_collection(*args)
|
19
|
+
call_payload = {
|
20
|
+
render: {
|
21
|
+
type: :collection,
|
22
|
+
name: @path.to_s
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
::Instana::Tracer.trace(:render, call_payload) { super(*args) }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
module Instana
|
5
|
+
module Instrumentation
|
6
|
+
module ActiveRecord
|
7
|
+
IGNORED_NAMES = %w[SCHEMA EXPLAIN CACHE].freeze
|
8
|
+
IGNORED_SQL = %w[BEGIN COMMIT SET].freeze
|
9
|
+
SANITIZE_REGEXP = /('[\s\S][^']*'|\d*\.\d+|\d+|NULL)/i.freeze
|
10
|
+
|
11
|
+
def log(sql, name = 'SQL', binds = [], *args)
|
12
|
+
call_payload = {
|
13
|
+
activerecord: {
|
14
|
+
adapter: @config[:adapter],
|
15
|
+
host: @config[:host],
|
16
|
+
username: @config[:username],
|
17
|
+
db: @config[:database],
|
18
|
+
sql: maybe_sanitize(sql)
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
if binds.all? { |b| b.respond_to?(:value_before_type_cast) }
|
23
|
+
mapped = binds.map(&:value_before_type_cast)
|
24
|
+
call_payload[:activerecord][:binds] = mapped
|
25
|
+
end
|
26
|
+
|
27
|
+
maybe_trace(call_payload, name) { super(sql, name, binds, *args) }
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def maybe_sanitize(sql)
|
33
|
+
::Instana.config[:sanitize_sql] ? sql.gsub(SANITIZE_REGEXP, '?') : sql
|
34
|
+
end
|
35
|
+
|
36
|
+
def maybe_trace(call_payload, name, &blk)
|
37
|
+
if ::Instana.tracer.tracing? && !ignored?(call_payload, name)
|
38
|
+
::Instana.tracer.trace(:activerecord, call_payload, &blk)
|
39
|
+
else
|
40
|
+
yield
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def ignored?(call_payload, name)
|
45
|
+
IGNORED_NAMES.include?(name) ||
|
46
|
+
IGNORED_SQL.any? { |s| call_payload[:activerecord][:sql].upcase.start_with?(s) }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
module Instana
|
5
|
+
module Instrumentation
|
6
|
+
class DynamoDB < Seahorse::Client::Plugin
|
7
|
+
class Handler < Seahorse::Client::Handler
|
8
|
+
def call(context)
|
9
|
+
dynamo_tags = {
|
10
|
+
op: context.operation_name,
|
11
|
+
table: table_name_from(context)
|
12
|
+
}
|
13
|
+
|
14
|
+
::Instana.tracer.trace(:dynamodb, dynamo_tags) { @handler.call(context) }
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def table_name_from(context)
|
20
|
+
context.params[:table_name] || context.params[:global_table_name] || 'Unknown'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_handlers(handlers, _config)
|
25
|
+
handlers.add(Handler, step: :initialize)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2017
|
3
|
+
|
1
4
|
module Instana
|
2
5
|
module Instrumentation
|
3
6
|
module Dalli
|
@@ -69,9 +72,3 @@ module Instana
|
|
69
72
|
end
|
70
73
|
end
|
71
74
|
end
|
72
|
-
|
73
|
-
if defined?(::Dalli) && ::Instana.config[:dalli][:enabled]
|
74
|
-
::Instana.logger.debug "Instrumenting Dalli"
|
75
|
-
::Dalli::Client.send(:prepend, ::Instana::Instrumentation::Dalli)
|
76
|
-
::Dalli::Server.send(:prepend, ::Instana::Instrumentation::DalliServer)
|
77
|
-
end
|
@@ -1,74 +1,71 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module Instrumentation
|
4
|
-
class Excon < ::Excon::Middleware::Base
|
5
|
-
def request_call(datum)
|
6
|
-
return @stack.request_call(datum) unless ::Instana.tracer.tracing?
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2016
|
7
3
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
module Instana
|
5
|
+
module Instrumentation
|
6
|
+
class Excon < ::Excon::Middleware::Base
|
7
|
+
def request_call(datum)
|
8
|
+
return @stack.request_call(datum) unless ::Instana.tracer.tracing? || !Instana.tracer.current_span.exit_span?
|
12
9
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
t_context = datum[:instana_span].context
|
18
|
-
else
|
19
|
-
::Instana.tracer.log_entry(:excon, payload)
|
20
|
-
t_context = ::Instana.tracer.context
|
21
|
-
end
|
10
|
+
payload = { :http => {} }
|
11
|
+
path = datum[:path].split('?').first
|
12
|
+
payload[:http][:url] = ::Instana.secrets.remove_from_query("#{datum[:connection].instance_variable_get(:@socket_key)}#{path}")
|
13
|
+
payload[:http][:method] = datum[:method] if datum.key?(:method)
|
22
14
|
|
23
|
-
|
24
|
-
datum
|
25
|
-
|
26
|
-
|
27
|
-
|
15
|
+
if datum[:pipeline] == true
|
16
|
+
# Pass the context along in the datum so we get back on response
|
17
|
+
# and can close out the async span
|
18
|
+
datum[:instana_span] = ::Instana.tracer.log_async_entry(:excon, payload)
|
19
|
+
t_context = datum[:instana_span].context
|
20
|
+
else
|
21
|
+
::Instana.tracer.log_entry(:excon, payload)
|
22
|
+
t_context = ::Instana.tracer.context
|
28
23
|
end
|
29
24
|
|
30
|
-
|
31
|
-
|
25
|
+
# Set request headers; encode IDs as hexadecimal strings
|
26
|
+
datum[:headers]['X-Instana-T'] = t_context.trace_id_header
|
27
|
+
datum[:headers]['X-Instana-S'] = t_context.span_id_header
|
28
|
+
|
29
|
+
@stack.request_call(datum)
|
30
|
+
end
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
def error_call(datum)
|
33
|
+
return @stack.error_call(datum) unless ::Instana.tracer.tracing? || !Instana.tracer.current_span.exit_span?
|
34
|
+
|
35
|
+
if datum[:pipeline] == true
|
36
|
+
::Instana.tracer.log_async_error(datum[:error], datum[:instana_span])
|
37
|
+
else
|
38
|
+
::Instana.tracer.log_error(datum[:error])
|
39
39
|
end
|
40
|
+
@stack.error_call(datum)
|
41
|
+
end
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
def response_call(datum)
|
44
|
+
# FIXME: Will connect exceptions call a response?
|
45
|
+
#
|
46
|
+
return @stack.response_call(datum) unless ::Instana.tracer.tracing? || !Instana.tracer.current_span.exit_span?
|
45
47
|
|
46
|
-
|
48
|
+
result = @stack.response_call(datum)
|
47
49
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
status = datum[:status]
|
51
|
+
if !status && datum.key?(:response) && datum[:response].is_a?(Hash)
|
52
|
+
status = datum[:response][:status]
|
53
|
+
end
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
if status.between?(500, 511)
|
56
|
+
# Because of the 5xx response, we flag this span as errored but
|
57
|
+
# without a backtrace (no exception)
|
58
|
+
::Instana.tracer.log_error(nil)
|
59
|
+
end
|
58
60
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
end
|
65
|
-
result
|
61
|
+
if datum[:pipeline] == true
|
62
|
+
# Pickup context of this async span from datum[:instana_span]
|
63
|
+
::Instana.tracer.log_async_exit(:excon, { :http => {:status => status } }, datum[:instana_span])
|
64
|
+
else
|
65
|
+
::Instana.tracer.log_exit(:excon, { :http => {:status => status } })
|
66
66
|
end
|
67
|
+
result
|
67
68
|
end
|
68
69
|
end
|
69
70
|
end
|
70
|
-
|
71
|
-
::Instana.logger.debug "Instrumenting Excon"
|
72
|
-
::Excon.defaults[:middlewares].unshift(::Instana::Instrumentation::Excon)
|
73
71
|
end
|
74
|
-
|
@@ -1,5 +1,8 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
module Instana
|
5
|
+
module Instrumentation
|
3
6
|
class GraphqlTracing < GraphQL::Tracing::PlatformTracing
|
4
7
|
self.platform_keys = {
|
5
8
|
'lex' => 'lex.graphql',
|
@@ -11,26 +14,26 @@ if defined?(GraphQL::Schema) && defined?(GraphQL::Tracing::PlatformTracing) && :
|
|
11
14
|
'execute_query' => 'execute.graphql',
|
12
15
|
'execute_query_lazy' => 'execute.graphql',
|
13
16
|
}
|
14
|
-
|
15
|
-
def platform_trace(platform_key, key, data)
|
16
|
-
return yield unless key == 'execute_query'
|
17
|
+
|
18
|
+
def platform_trace(platform_key, key, data)
|
19
|
+
return yield unless key == 'execute_query'
|
17
20
|
operation = data[:query].selected_operation
|
18
|
-
|
21
|
+
|
19
22
|
arguments = []
|
20
23
|
fields = []
|
21
|
-
|
24
|
+
|
22
25
|
operation.selections.each do |field|
|
23
26
|
arguments.concat(walk_fields(field, :arguments))
|
24
|
-
fields.concat(walk_fields(field, :selections))
|
27
|
+
fields.concat(walk_fields(field, :selections))
|
25
28
|
end
|
26
|
-
|
29
|
+
|
27
30
|
payload = {
|
28
31
|
operationName: data[:query].operation_name || 'anonymous',
|
29
32
|
operationType: operation.operation_type,
|
30
33
|
arguments: grouped_fields(arguments),
|
31
34
|
fields: grouped_fields(fields),
|
32
35
|
}
|
33
|
-
|
36
|
+
|
34
37
|
begin
|
35
38
|
::Instana.tracer.log_entry(:'graphql.server')
|
36
39
|
yield
|
@@ -41,11 +44,11 @@ if defined?(GraphQL::Schema) && defined?(GraphQL::Tracing::PlatformTracing) && :
|
|
41
44
|
::Instana.tracer.log_exit(:'graphql.server', {graphql: payload})
|
42
45
|
end
|
43
46
|
end
|
44
|
-
|
47
|
+
|
45
48
|
def platform_field_key(type, field)
|
46
49
|
"#{type.graphql_name}.#{field.graphql_name}"
|
47
50
|
end
|
48
|
-
|
51
|
+
|
49
52
|
def platform_authorized_key(type)
|
50
53
|
"#{type.graphql_name}.authorized.graphql"
|
51
54
|
end
|
@@ -53,17 +56,17 @@ if defined?(GraphQL::Schema) && defined?(GraphQL::Tracing::PlatformTracing) && :
|
|
53
56
|
def platform_resolve_type_key(type)
|
54
57
|
"#{type.graphql_name}.resolve_type.graphql"
|
55
58
|
end
|
56
|
-
|
59
|
+
|
57
60
|
private
|
58
|
-
|
61
|
+
|
59
62
|
def walk_fields(parent, method)
|
60
63
|
return [] unless parent.respond_to?(method)
|
61
|
-
|
64
|
+
|
62
65
|
parent.send(method).map do |field|
|
63
66
|
[{object: parent.name, field: field.name}] + walk_fields(field, method)
|
64
67
|
end.flatten
|
65
68
|
end
|
66
|
-
|
69
|
+
|
67
70
|
def grouped_fields(fields)
|
68
71
|
fields
|
69
72
|
.group_by { |p| p[:object] }
|
@@ -72,6 +75,4 @@ if defined?(GraphQL::Schema) && defined?(GraphQL::Tracing::PlatformTracing) && :
|
|
72
75
|
end
|
73
76
|
end
|
74
77
|
end
|
75
|
-
|
76
|
-
::GraphQL::Schema.use(::Instana::GraphqlTracing)
|
77
78
|
end
|
@@ -1,7 +1,10 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2017
|
3
|
+
|
1
4
|
call_types = [:request_response, :client_streamer, :server_streamer, :bidi_streamer]
|
2
5
|
|
3
|
-
|
4
|
-
module
|
6
|
+
module Instana
|
7
|
+
module Instrumentation
|
5
8
|
module GRPCCientInstrumentation
|
6
9
|
CALL_TYPES = [:request_response, :client_streamer, :server_streamer, :bidi_streamer]
|
7
10
|
|
@@ -42,13 +45,10 @@ if defined?(GRPC::ActiveCall) && ::Instana.config[:grpc][:enabled]
|
|
42
45
|
end
|
43
46
|
end
|
44
47
|
end
|
45
|
-
|
46
|
-
::Instana.logger.debug 'Instrumenting GRPC client'
|
47
|
-
::GRPC::ClientStub.prepend(::Instana::GRPCCientInstrumentation)
|
48
48
|
end
|
49
49
|
|
50
|
-
|
51
|
-
module
|
50
|
+
module Instana
|
51
|
+
module Instrumentation
|
52
52
|
module GRPCServerInstrumentation
|
53
53
|
CALL_TYPES = [:request_response, :client_streamer, :server_streamer, :bidi_streamer]
|
54
54
|
|
@@ -88,7 +88,4 @@ if defined?(GRPC::RpcDesc) && ::Instana.config[:grpc][:enabled]
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
91
|
-
|
92
|
-
::Instana.logger.debug 'Instrumenting GRPC server'
|
93
|
-
::GRPC::RpcDesc.prepend(::Instana::GRPCServerInstrumentation)
|
94
91
|
end
|