instana 1.11.5 → 1.13.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 +168 -0
- data/Rakefile +26 -37
- data/lib/instana/agent.rb +6 -0
- data/lib/instana/base.rb +2 -0
- data/lib/instana/frameworks/cuba.rb +33 -0
- data/lib/instana/frameworks/instrumentation/action_controller.rb +11 -0
- data/lib/instana/frameworks/roda.rb +41 -0
- data/lib/instana/frameworks/sinatra.rb +17 -0
- data/lib/instana/instrumentation/excon.rb +1 -1
- data/lib/instana/instrumentation/net-http.rb +2 -0
- data/lib/instana/instrumentation/rack.rb +23 -3
- data/lib/instana/instrumentation/redis.rb +39 -33
- data/lib/instana/secrets.rb +42 -0
- data/lib/instana/setup.rb +1 -0
- data/lib/instana/test.rb +4 -3
- data/lib/instana/tracing/span.rb +9 -0
- data/lib/instana/version.rb +1 -1
- data/test/apps/cuba.rb +4 -0
- data/test/apps/roda.rb +3 -0
- data/test/apps/sinatra.rb +4 -0
- data/test/config_test.rb +1 -17
- data/test/frameworks/cuba_test.rb +14 -1
- data/test/frameworks/rack_test.rb +125 -65
- data/test/frameworks/rails/actioncontroller_test.rb +12 -0
- data/test/frameworks/roda_test.rb +14 -0
- data/test/frameworks/sinatra_test.rb +37 -15
- data/test/instrumentation/grpc_test.rb +1 -1
- data/test/instrumentation/resque_test.rb +9 -16
- data/test/jobs/resque_error_job.rb +2 -2
- data/test/jobs/resque_fast_job.rb +2 -2
- data/test/secrets_test.rb +73 -0
- data/test/test_helper.rb +3 -3
- data/test/tracing/tracer_test.rb +31 -1
- metadata +7 -6
- data/.travis.yml +0 -43
- data/test/tracing/trace_test.rb +0 -67
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09630573df5e1941fc17023b97864fd430f6135b9e0a72cd2f19225265b66d16'
|
4
|
+
data.tar.gz: b8dc0dda20938dc03f4ebe0887c3ccd68d03995d07e0c7233a19ff3a0780f1a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9bf1d5bfd714b8d1e3e187d0dfe47f0917384fb41b45d8f01b10890c7259c985b20d5adb550d955ac51b8bca9102246e9926ce114d448b391b82e0acdcd46c4
|
7
|
+
data.tar.gz: 139872ad95ceeca46b97be78773d999228ff30563ff90f29e65032bd6b55f7e619fb00a9e130ad6bd06b83dd0bca3e4321428e5172795242c8a045de570bd77a
|
@@ -0,0 +1,168 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
# More about orbs: https://circleci.com/docs/2.0/using-orbs/
|
4
|
+
orbs:
|
5
|
+
ruby: circleci/ruby@1.1.2
|
6
|
+
|
7
|
+
commands:
|
8
|
+
prelim-deps:
|
9
|
+
steps:
|
10
|
+
- run:
|
11
|
+
name: Preliminary Dependencies
|
12
|
+
command: |
|
13
|
+
gem update --system
|
14
|
+
gem --version
|
15
|
+
gem install bundler
|
16
|
+
bundler --version
|
17
|
+
bundle config set path './vendor/bundle'
|
18
|
+
|
19
|
+
run-tests:
|
20
|
+
steps:
|
21
|
+
- run:
|
22
|
+
name: Run the Tests
|
23
|
+
command: |
|
24
|
+
bundle exec rake test
|
25
|
+
|
26
|
+
save-stan-cache:
|
27
|
+
parameters:
|
28
|
+
gemfile:
|
29
|
+
default: "Gemfile"
|
30
|
+
type: string
|
31
|
+
steps:
|
32
|
+
- save_cache:
|
33
|
+
key: gem-cache-v1-{{ arch }}-{{ .Branch }}-{{ checksum "<<parameters.gemfile>>" }}
|
34
|
+
paths:
|
35
|
+
- vendor/bundle
|
36
|
+
|
37
|
+
restore-stan-cache:
|
38
|
+
parameters:
|
39
|
+
gemfile:
|
40
|
+
default: "Gemfile"
|
41
|
+
type: string
|
42
|
+
steps:
|
43
|
+
- restore_cache:
|
44
|
+
keys:
|
45
|
+
- gem-cache-v1-{{ arch }}-{{ .Branch }}-{{ checksum "<<parameters.gemfile>>" }}
|
46
|
+
- gem-cache-v1-{{ arch }}-{{ .Branch }}
|
47
|
+
- gem-cache-v1
|
48
|
+
|
49
|
+
bundle-install:
|
50
|
+
parameters:
|
51
|
+
gemfile:
|
52
|
+
default: "Gemfile"
|
53
|
+
type: string
|
54
|
+
steps:
|
55
|
+
- restore-stan-cache:
|
56
|
+
gemfile: <<parameters.gemfile>>
|
57
|
+
- run:
|
58
|
+
name: Bundle Installation
|
59
|
+
command: |
|
60
|
+
bundle install
|
61
|
+
- save-stan-cache:
|
62
|
+
gemfile: <<parameters.gemfile>>
|
63
|
+
|
64
|
+
jobs:
|
65
|
+
ruby26:
|
66
|
+
parallelism: 3
|
67
|
+
docker:
|
68
|
+
- image: circleci/ruby:2.6.3-stretch-node
|
69
|
+
executor: ruby/default
|
70
|
+
environment:
|
71
|
+
BUNDLE_JOBS: "3"
|
72
|
+
BUNDLE_RETRY: "3"
|
73
|
+
|
74
|
+
steps:
|
75
|
+
- checkout
|
76
|
+
- prelim-deps
|
77
|
+
- bundle-install
|
78
|
+
- run-tests
|
79
|
+
|
80
|
+
rails50:
|
81
|
+
parallelism: 3
|
82
|
+
docker:
|
83
|
+
- image: circleci/ruby:2.6.3-stretch-node
|
84
|
+
- image: mariadb
|
85
|
+
environment:
|
86
|
+
MYSQL_DATABASE: 'travis_ci_test'
|
87
|
+
MYSQL_USER: 'root'
|
88
|
+
MYSQL_PASSWORD: ''
|
89
|
+
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
|
90
|
+
MYSQL_ROOT_PASSWORD: ''
|
91
|
+
MYSQL_ROOT_HOST: '%'
|
92
|
+
executor: ruby/default
|
93
|
+
environment:
|
94
|
+
BUNDLE_JOBS: "3"
|
95
|
+
BUNDLE_RETRY: "3"
|
96
|
+
BUNDLE_GEMFILE: "./gemfiles/rails50.gemfile"
|
97
|
+
|
98
|
+
steps:
|
99
|
+
- checkout
|
100
|
+
- prelim-deps
|
101
|
+
- bundle-install:
|
102
|
+
gemfile: "./gemfiles/rails50.gemfile"
|
103
|
+
- run-tests
|
104
|
+
|
105
|
+
rails60:
|
106
|
+
parallelism: 3
|
107
|
+
docker:
|
108
|
+
- image: circleci/ruby:2.6.3-stretch-node
|
109
|
+
- image: mariadb
|
110
|
+
environment:
|
111
|
+
MYSQL_DATABASE: 'travis_ci_test'
|
112
|
+
MYSQL_USER: 'root'
|
113
|
+
MYSQL_PASSWORD: ''
|
114
|
+
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
|
115
|
+
MYSQL_ROOT_PASSWORD: ''
|
116
|
+
MYSQL_ROOT_HOST: '%'
|
117
|
+
executor: ruby/default
|
118
|
+
environment:
|
119
|
+
BUNDLE_JOBS: "3"
|
120
|
+
BUNDLE_RETRY: "3"
|
121
|
+
BUNDLE_GEMFILE: "./gemfiles/rails60.gemfile"
|
122
|
+
|
123
|
+
steps:
|
124
|
+
- checkout
|
125
|
+
- prelim-deps
|
126
|
+
- bundle-install:
|
127
|
+
gemfile: "./gemfiles/rails60.gemfile"
|
128
|
+
- run-tests
|
129
|
+
|
130
|
+
libraries:
|
131
|
+
parallelism: 3
|
132
|
+
docker:
|
133
|
+
- image: circleci/ruby:2.6.3-stretch-node
|
134
|
+
- image: mariadb
|
135
|
+
environment:
|
136
|
+
MYSQL_DATABASE: 'travis_ci_test'
|
137
|
+
MYSQL_USER: 'root'
|
138
|
+
MYSQL_PASSWORD: ''
|
139
|
+
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
|
140
|
+
MYSQL_ROOT_PASSWORD: ''
|
141
|
+
MYSQL_ROOT_HOST: '%'
|
142
|
+
- image: memcached
|
143
|
+
- image: postgres
|
144
|
+
environment:
|
145
|
+
POSTGRES_USER: 'stan'
|
146
|
+
POSTGRES_PASSWORD: 'stanlikesdata'
|
147
|
+
- image: redis
|
148
|
+
executor: ruby/default
|
149
|
+
environment:
|
150
|
+
BUNDLE_JOBS: "3"
|
151
|
+
BUNDLE_RETRY: "3"
|
152
|
+
BUNDLE_GEMFILE: "./gemfiles/libraries.gemfile"
|
153
|
+
|
154
|
+
steps:
|
155
|
+
- checkout
|
156
|
+
- prelim-deps
|
157
|
+
- bundle-install:
|
158
|
+
gemfile: "./gemfiles/libraries.gemfile"
|
159
|
+
- run-tests
|
160
|
+
|
161
|
+
workflows:
|
162
|
+
version: 2
|
163
|
+
whole-enchilada-MRI26:
|
164
|
+
jobs:
|
165
|
+
- ruby26
|
166
|
+
- rails50
|
167
|
+
- rails60
|
168
|
+
- libraries
|
data/Rakefile
CHANGED
@@ -8,44 +8,33 @@ Rake::TestTask.new(:test) do |t|
|
|
8
8
|
|
9
9
|
t.libs << "test"
|
10
10
|
t.libs << "lib"
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
'test/frameworks/sinatra_test.rb']
|
37
|
-
else
|
38
|
-
t.test_files = FileList['test/agent/*_test.rb'] +
|
39
|
-
FileList['test/tracing/*_test.rb'] +
|
40
|
-
FileList['test/profiling/*_test.rb'] +
|
41
|
-
FileList['test/benchmarks/bench_*.rb']
|
42
|
-
end
|
43
|
-
else
|
44
|
-
t.test_files = FileList['test/agent/*_test.rb'] +
|
45
|
-
FileList['test/tracing/*_test.rb'] +
|
46
|
-
FileList['test/profiling/*_test.rb'] +
|
47
|
-
FileList['test/benchmarks/bench_*.rb']
|
11
|
+
|
12
|
+
t.test_files = Dir[
|
13
|
+
'test/*_test.rb',
|
14
|
+
'test/{agent,tracing,profiling,benchmarks}/*_test.rb'
|
15
|
+
]
|
16
|
+
|
17
|
+
case File.basename(ENV.fetch('BUNDLE_GEMFILE', '')).split('.').first
|
18
|
+
when /rails6/
|
19
|
+
t.test_files = %w(test/frameworks/rails/activerecord_test.rb
|
20
|
+
test/frameworks/rails/actioncontroller_test.rb
|
21
|
+
test/frameworks/rails/actionview5_test.rb)
|
22
|
+
when /rails5/
|
23
|
+
t.test_files = %w(test/frameworks/rails/activerecord_test.rb
|
24
|
+
test/frameworks/rails/actioncontroller_test.rb
|
25
|
+
test/frameworks/rails/actionview5_test.rb)
|
26
|
+
when /rails42/
|
27
|
+
t.test_files = %w(test/frameworks/rails/activerecord_test.rb
|
28
|
+
test/frameworks/rails/actioncontroller_test.rb
|
29
|
+
test/frameworks/rails/actionview4_test.rb)
|
30
|
+
when /rails32/
|
31
|
+
t.test_files = %w(test/frameworks/rails/activerecord_test.rb
|
32
|
+
test/frameworks/rails/actioncontroller_test.rb
|
33
|
+
test/frameworks/rails/actionview3_test.rb)
|
34
|
+
when /libraries/
|
35
|
+
t.test_files = Dir['test/{instrumentation,frameworks}/*_test.rb']
|
48
36
|
end
|
37
|
+
|
49
38
|
end
|
50
39
|
|
51
40
|
task :environment do
|
data/lib/instana/agent.rb
CHANGED
@@ -25,6 +25,7 @@ module Instana
|
|
25
25
|
attr_accessor :collect_thread
|
26
26
|
attr_accessor :thread_spawn_lock
|
27
27
|
attr_accessor :extra_headers
|
28
|
+
attr_reader :secret_values
|
28
29
|
|
29
30
|
attr_accessor :testmode
|
30
31
|
|
@@ -83,6 +84,10 @@ module Instana
|
|
83
84
|
|
84
85
|
# The agent may pass down custom headers for this sensor to capture
|
85
86
|
@extra_headers = nil
|
87
|
+
|
88
|
+
# The values considered sensitive and removed from http query parameters
|
89
|
+
# and database connection strings
|
90
|
+
@secret_values = nil
|
86
91
|
end
|
87
92
|
|
88
93
|
# Spawns the background thread and calls start. This method is separated
|
@@ -278,6 +283,7 @@ module Instana
|
|
278
283
|
data = Oj.load(response.body, OJ_OPTIONS)
|
279
284
|
@process[:report_pid] = data['pid']
|
280
285
|
@agent_uuid = data['agentUuid']
|
286
|
+
@secret_values = data['secrets']
|
281
287
|
|
282
288
|
if data.key?('extraHeaders')
|
283
289
|
@extra_headers = data['extraHeaders']
|
data/lib/instana/base.rb
CHANGED
@@ -12,6 +12,7 @@ module Instana
|
|
12
12
|
attr_accessor :config
|
13
13
|
attr_accessor :logger
|
14
14
|
attr_accessor :pid
|
15
|
+
attr_reader :secrets
|
15
16
|
|
16
17
|
##
|
17
18
|
# setup
|
@@ -24,6 +25,7 @@ module Instana
|
|
24
25
|
@tracer = ::Instana::Tracer.new
|
25
26
|
@processor = ::Instana::Processor.new
|
26
27
|
@collector = ::Instana::Collector.new
|
28
|
+
@secrets = ::Instana::Secrets.new
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
@@ -1,6 +1,39 @@
|
|
1
1
|
require "instana/rack"
|
2
2
|
|
3
|
+
module Instana
|
4
|
+
module CubaPathTemplateExtractor
|
5
|
+
REPLACE_TARGET = /:(?<term>[^\/]+)/i
|
6
|
+
|
7
|
+
def self.prepended(base)
|
8
|
+
::Instana.logger.debug "#{base} prepended #{self}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def on(*args, &blk)
|
12
|
+
wrapper = lambda do |*caputres|
|
13
|
+
env['INSTANA_PATH_TEMPLATE_FRAGMENTS'] << args
|
14
|
+
.select { |a| a.is_a?(String) }
|
15
|
+
.join('/')
|
16
|
+
|
17
|
+
blk.call(*captures)
|
18
|
+
end
|
19
|
+
|
20
|
+
super(*args, &wrapper)
|
21
|
+
end
|
22
|
+
|
23
|
+
def call!(env)
|
24
|
+
env['INSTANA_PATH_TEMPLATE_FRAGMENTS'] = []
|
25
|
+
response = super(env)
|
26
|
+
env['INSTANA_HTTP_PATH_TEMPLATE'] = env['INSTANA_PATH_TEMPLATE_FRAGMENTS']
|
27
|
+
.join('/')
|
28
|
+
.gsub(REPLACE_TARGET, '{\k<term>}')
|
29
|
+
response
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
3
35
|
if defined?(::Cuba)
|
4
36
|
::Instana.logger.debug "Instrumenting Cuba"
|
5
37
|
Cuba.use ::Instana::Rack
|
38
|
+
Cuba.prepend ::Instana::CubaPathTemplateExtractor
|
6
39
|
end
|
@@ -64,6 +64,15 @@ module Instana
|
|
64
64
|
end
|
65
65
|
name
|
66
66
|
end
|
67
|
+
|
68
|
+
def matched_path_template
|
69
|
+
Rails.application.routes.router.recognize(request) do |route, _, _|
|
70
|
+
path = route.path
|
71
|
+
return path.spec.to_s
|
72
|
+
end
|
73
|
+
|
74
|
+
nil
|
75
|
+
end
|
67
76
|
end
|
68
77
|
|
69
78
|
# Used in ActionPack versions 5 and beyond, this module provides
|
@@ -83,6 +92,7 @@ module Instana
|
|
83
92
|
::Instana.tracer.log_entry(:actioncontroller, kv_payload)
|
84
93
|
|
85
94
|
super(*args)
|
95
|
+
request.env['INSTANA_HTTP_PATH_TEMPLATE'] = matched_path_template
|
86
96
|
rescue Exception => e
|
87
97
|
::Instana.tracer.log_error(e) unless has_rails_handler?(e)
|
88
98
|
raise
|
@@ -135,6 +145,7 @@ module Instana
|
|
135
145
|
::Instana.tracer.log_entry(:actioncontroller, kv_payload)
|
136
146
|
|
137
147
|
process_action_without_instana(*args)
|
148
|
+
request.env['INSTANA_HTTP_PATH_TEMPLATE'] = matched_path_template
|
138
149
|
rescue Exception => e
|
139
150
|
::Instana.tracer.log_error(e) unless has_rails_handler?(e)
|
140
151
|
raise
|
@@ -1,6 +1,47 @@
|
|
1
1
|
require "instana/rack"
|
2
2
|
|
3
|
+
module Instana
|
4
|
+
module RodaPathTemplateExtractor
|
5
|
+
module RequestMethods
|
6
|
+
TERM = defined?(::Roda) ? ::Roda::RodaPlugins::Base::RequestMethods::TERM : Object
|
7
|
+
|
8
|
+
def if_match(args, &blk)
|
9
|
+
path = @remaining_path
|
10
|
+
captures = @captures.clear
|
11
|
+
|
12
|
+
if match_all(args)
|
13
|
+
(env['INSTANA_PATH_TEMPLATE_FRAGMENTS'] ||= []).concat(named_args(args, blk))
|
14
|
+
block_result(blk.(*captures))
|
15
|
+
env['INSTANA_HTTP_PATH_TEMPLATE'] = env['INSTANA_PATH_TEMPLATE_FRAGMENTS']
|
16
|
+
.join('/')
|
17
|
+
.prepend('/')
|
18
|
+
throw :halt, response.finish
|
19
|
+
else
|
20
|
+
@remaining_path = path
|
21
|
+
false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def named_args(args, blk)
|
26
|
+
parameters = blk.parameters
|
27
|
+
args.map do |a|
|
28
|
+
case a
|
29
|
+
when String
|
30
|
+
a
|
31
|
+
when TERM
|
32
|
+
nil
|
33
|
+
else
|
34
|
+
_, name = parameters.pop
|
35
|
+
"{#{name}}"
|
36
|
+
end
|
37
|
+
end.compact
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
3
43
|
if defined?(::Roda)
|
4
44
|
::Instana.logger.debug "Instrumenting Roda"
|
5
45
|
Roda.use ::Instana::Rack
|
46
|
+
Roda.plugin ::Instana::RodaPathTemplateExtractor
|
6
47
|
end
|
@@ -3,7 +3,24 @@ require "instana/rack"
|
|
3
3
|
# This instrumentation will insert Rack into Sinatra _and_ Padrino since
|
4
4
|
# the latter is based on Sinatra
|
5
5
|
|
6
|
+
module Instana
|
7
|
+
module SinatraPathTemplateExtractor
|
8
|
+
def self.extended(base)
|
9
|
+
::Instana.logger.debug "#{base} extended #{self}"
|
10
|
+
base.store_path_template
|
11
|
+
end
|
12
|
+
|
13
|
+
def store_path_template
|
14
|
+
after do
|
15
|
+
@env["INSTANA_HTTP_PATH_TEMPLATE"] = @env["sinatra.route"]
|
16
|
+
.sub("#{@request.request_method} ", '')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
6
22
|
if defined?(::Sinatra)
|
7
23
|
::Instana.logger.debug "Instrumenting Sinatra"
|
8
24
|
::Sinatra::Base.use ::Instana::Rack
|
25
|
+
::Sinatra::Base.register ::Instana::SinatraPathTemplateExtractor
|
9
26
|
end
|
@@ -7,7 +7,7 @@ if defined?(::Excon) && ::Instana.config[:excon][:enabled]
|
|
7
7
|
|
8
8
|
payload = { :http => {} }
|
9
9
|
path = datum[:path].split('?').first
|
10
|
-
payload[:http][:url] = "#{datum[:connection].instance_variable_get(:@socket_key)}#{path}"
|
10
|
+
payload[:http][:url] = ::Instana.secrets.remove_from_query("#{datum[:connection].instance_variable_get(:@socket_key)}#{path}")
|
11
11
|
payload[:http][:method] = datum[:method] if datum.key?(:method)
|
12
12
|
|
13
13
|
if datum[:pipeline] == true
|