instana 1.204.0.pre3 → 1.207.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6c2235234526a14bbb8818b104e9417f4683179b2166cb222fe136af32794d4
4
- data.tar.gz: 16a190359fa7208ceeaf7170db5cfc732bcb464837f6acde9eb1c5be08b09eba
3
+ metadata.gz: 01f078ad2a63d8cd71303a9bf7b413209eda0b2f464ce72f88c84ae05bf797da
4
+ data.tar.gz: d547946bdbb52ea3c3c3a7fc317f7bcd2dd8ccf37d52507788bff1b85fc4434c
5
5
  SHA512:
6
- metadata.gz: d1465d42aeee46d0db43c2563b6bea541efddb553bb30fec875cc1cc2b5de30303476258ad889ccc9c6b10c4e1164f12001c743c16de0dafebce8e0020fd850b
7
- data.tar.gz: b87b819750e3901f524609b89c2c8a96ac54965d8c6db2f4100a9cc2586cfafd55be20b30516364fdbec1199da7db8c987b6fb8f4edfc82761624caf5ea5d94b
6
+ metadata.gz: df3a3926477ab6842628f7fe1062655e63760c0fc1e5100912c8191f5894b8b4dabb1e030441b0b924d379bd6be56a9b69e877c22220153acba3393af59e4b51
7
+ data.tar.gz: 05fd9a76497614afca946d9538577bdfda21bd3a901759b285d7033425610206fd5a88405f86e86d52928da8f9324798cbf579bb516d845a8749f7c000d98fdf
data/.circleci/config.yml CHANGED
@@ -113,6 +113,10 @@ executors:
113
113
  commands:
114
114
  setup:
115
115
  steps:
116
+ - run:
117
+ name: Install iproute2
118
+ command: |
119
+ sudo apt-get install iproute2
116
120
  - run:
117
121
  name: Install Java
118
122
  command: |
@@ -141,13 +145,20 @@ commands:
141
145
  - run:
142
146
  name: Run SonarQube to capture coverage
143
147
  command: |
144
- wget -O /tmp/sonar-scanner-cli.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.5.0.2216.zip
148
+ wget -O /tmp/sonar-scanner-cli.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472.zip
145
149
  unzip -d /tmp /tmp/sonar-scanner-cli.zip
146
- /tmp/sonar-scanner-4.5.0.2216/bin/sonar-scanner \
147
- -Dsonar.projectKey=ruby-sensor \
148
- -Dsonar.sources=. \
149
- -Dsonar.host.url="${SONARQUBE_URL}" \
150
- -Dsonar.login="${SONARQUBE_LOGIN}"
150
+ if [[ -n "${CIRCLE_PR_NUMBER}" ]]; then
151
+ /tmp/sonar-scanner-4.6.2.2472/bin/sonar-scanner \
152
+ -Dsonar.host.url="${SONARQUBE_URL}" \
153
+ -Dsonar.login="${SONARQUBE_LOGIN}" \
154
+ -Dsonar.pullrequest.key="${CIRCLE_PR_NUMBER}" \
155
+ -Dsonar.pullrequest.branch="${CIRCLE_BRANCH}"
156
+ else
157
+ /tmp/sonar-scanner-4.6.2.2472/bin/sonar-scanner \
158
+ -Dsonar.host.url="${SONARQUBE_URL}" \
159
+ -Dsonar.login="${SONARQUBE_LOGIN}" \
160
+ -Dsonar.branch.name="${CIRCLE_BRANCH}"
161
+ fi
151
162
  run_tests:
152
163
  steps:
153
164
  - run:
@@ -156,7 +167,7 @@ commands:
156
167
  mkdir _junit
157
168
  bundle exec rake
158
169
  - store_test_results:
159
- path: ~/_junit
170
+ path: ~/project/_junit
160
171
  run_rubocop:
161
172
  steps:
162
173
  - run:
@@ -171,11 +182,11 @@ commands:
171
182
  mkdir -p ~/.gem
172
183
  echo -e "---\r\n:rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials
173
184
  chmod 0600 /home/circleci/.gem/credentials
174
- - run:
185
+ - run:
175
186
  name: Publish Gem
176
187
  command: |
177
188
  bundle exec rake release[origin]
178
-
189
+
179
190
  jobs:
180
191
  test_core:
181
192
  parameters:
@@ -9,6 +9,7 @@ module Instana
9
9
  ENTITY_DATA_URL = '/com.instana.plugin.ruby.%i'.freeze
10
10
  RESPONSE_DATA_URL = '/com.instana.plugin.ruby/response.%i?messageId=%s'.freeze
11
11
  TRACES_DATA_URL = "/com.instana.plugin.ruby/traces.%i".freeze
12
+ TRACE_METRICS_URL = "/tracermetrics".freeze
12
13
 
13
14
  attr_reader :report_timer
14
15
 
@@ -35,10 +36,24 @@ module Instana
35
36
  def report_to_backend
36
37
  report_metrics if ::Instana.config[:metrics][:enabled]
37
38
  report_traces if ::Instana.config[:tracing][:enabled]
39
+ report_trace_stats if ::Instana.config[:tracing][:enabled]
38
40
  rescue StandardError => e
39
41
  @logger.error(%(#{e}\n#{e.backtrace.join("\n")}))
40
42
  end
41
43
 
44
+ def report_trace_stats
45
+ discovery = @discovery.value
46
+ return unless discovery
47
+
48
+ payload = {
49
+ tracer: 'ruby',
50
+ pid: discovery['pid'],
51
+ metrics: @processor.span_metrics
52
+ }
53
+
54
+ @client.send_request('POST', TRACE_METRICS_URL, payload)
55
+ end
56
+
42
57
  def report_traces
43
58
  discovery = @discovery.value
44
59
  return unless discovery
@@ -87,17 +102,27 @@ module Instana
87
102
  end
88
103
 
89
104
  def metrics_payload(discovery)
90
- proc_table = Sys::ProcTable.ps(pid: Process.pid)
91
- process = ProcessInfo.new(proc_table)
92
-
93
- {
105
+ payload = {
94
106
  pid: discovery['pid'],
95
- name: Util.get_app_name,
96
- exec_args: process.arguments,
97
- gc: GCSnapshot.instance.report,
98
- thread: {count: ::Thread.list.count},
99
- memory: {rss_size: proc_table.rss / 1024} # Bytes to Kilobytes
107
+ name: Util.get_app_name
100
108
  }
109
+
110
+ if ::Instana.config[:metrics][:memory][:enabled]
111
+ proc_table = Sys::ProcTable.ps(pid: Process.pid)
112
+ process = ProcessInfo.new(proc_table)
113
+ payload[:exec_args] = process.arguments
114
+ payload[:memory] = {rss_size: process.memory_used}
115
+ end
116
+
117
+ if ::Instana.config[:metrics][:gc][:enabled]
118
+ payload[:gc] = GCSnapshot.instance.report
119
+ end
120
+
121
+ if ::Instana.config[:metrics][:thread][:enabled]
122
+ payload[:thread] = {count: ::Thread.list.count}
123
+ end
124
+
125
+ payload
101
126
  end
102
127
  end
103
128
  end
@@ -47,6 +47,14 @@ module Instana
47
47
  File.read(path).match(/\d+/).to_s.to_i
48
48
  end
49
49
 
50
+ def memory_used
51
+ if RbConfig::CONFIG['host_os'].include?('darwin')
52
+ rss / 1024
53
+ else
54
+ rss * 4096
55
+ end
56
+ end
57
+
50
58
  private
51
59
 
52
60
  def clean_arguments(arguments)
@@ -19,7 +19,7 @@ module Instana
19
19
  }
20
20
  }
21
21
 
22
- if binds.all? { |b| b.respond_to?(:value_before_type_cast) }
22
+ if binds.all? { |b| b.respond_to?(:value_before_type_cast) } && !::Instana.config[:sanitize_sql]
23
23
  mapped = binds.map(&:value_before_type_cast)
24
24
  call_payload[:activerecord][:binds] = mapped
25
25
  end
@@ -20,6 +20,9 @@ module Instana
20
20
  @batch_size = 3000
21
21
  @logger = logger
22
22
  @pid = Process.pid
23
+
24
+ @spans_opened = Concurrent::AtomicFixnum.new(0)
25
+ @spans_closed = Concurrent::AtomicFixnum.new(0)
23
26
  end
24
27
 
25
28
  # Adds a span to the span queue
@@ -34,9 +37,31 @@ module Instana
34
37
  end
35
38
  # :nocov:
36
39
 
40
+ @spans_closed.increment
37
41
  @queue.push(span)
38
42
  end
39
43
 
44
+ # Note that we've started a new span. Used to
45
+ # generate monitoring metrics.
46
+ def start_span(_)
47
+ @spans_opened.increment
48
+ end
49
+
50
+ # Clears and retrieves metrics associated with span creation and submission
51
+ def span_metrics
52
+ response = {
53
+ opened: @spans_opened.value,
54
+ closed: @spans_closed.value,
55
+ filtered: 0,
56
+ dropped: 0
57
+ }
58
+
59
+ @spans_opened.value = 0
60
+ @spans_closed.value = 0
61
+
62
+ response
63
+ end
64
+
40
65
  ##
41
66
  # send
42
67
  #
@@ -82,6 +107,9 @@ module Instana
82
107
  # test suite to reset state.
83
108
  #
84
109
  def clear!
110
+ @spans_opened.value = 0
111
+ @spans_closed.value = 0
112
+
85
113
  until @queue.empty? do
86
114
  # Non-blocking pop; ignore exception
87
115
  @queue.pop(true) rescue nil
@@ -71,6 +71,8 @@ module Instana
71
71
  configure_custom(name)
72
72
  end
73
73
 
74
+ ::Instana.processor.start_span(self)
75
+
74
76
  # Attach a backtrace to all exit spans
75
77
  add_stack if ::Instana.config[:collect_backtraces] && exit_span?
76
78
  end
@@ -2,6 +2,6 @@
2
2
  # (c) Copyright Instana Inc. 2016
3
3
 
4
4
  module Instana
5
- VERSION = "1.204.0.pre3"
5
+ VERSION = "1.207.0"
6
6
  VERSION_FULL = "instana-#{VERSION}"
7
7
  end
@@ -0,0 +1,9 @@
1
+ sonar.projectKey=ruby-sensor
2
+ sonar.sources=lib
3
+ sonar.tests=test
4
+ sonar.exclusions=_junit/*
5
+ sonar.ruby.coverage.reportPaths=coverage/coverage.json
6
+ sonar.links.homepage=https://github.com/instana/ruby-sensor/
7
+ sonar.links.ci=https://circleci.com/gh/instana/ruby-sensor
8
+ sonar.links.issue=https://github.com/instana/ruby-sensor/issues
9
+ sonar.links.scm=https://github.com/instana/ruby-sensor/
@@ -23,6 +23,8 @@ class HostAgentReportingObserverTest < Minitest::Test
23
23
  end
24
24
 
25
25
  def test_report
26
+ stub_request(:post, "http://10.10.10.10:9292/tracermetrics")
27
+ .to_return(status: 200)
26
28
  stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby.0")
27
29
  .to_return(status: 200)
28
30
 
@@ -35,6 +37,8 @@ class HostAgentReportingObserverTest < Minitest::Test
35
37
  end
36
38
 
37
39
  def test_report_fail
40
+ stub_request(:post, "http://10.10.10.10:9292/tracermetrics")
41
+ .to_return(status: 200)
38
42
  stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby.0")
39
43
  .to_return(status: 500)
40
44
 
@@ -54,6 +58,9 @@ class HostAgentReportingObserverTest < Minitest::Test
54
58
  args: {file: 'test_helper.rb'}
55
59
  )
56
60
 
61
+ stub_request(:post, "http://10.10.10.10:9292/tracermetrics")
62
+ .to_return(status: 200)
63
+
57
64
  stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby.0")
58
65
  .to_return(status: 200, body: action)
59
66
 
@@ -75,6 +82,9 @@ class HostAgentReportingObserverTest < Minitest::Test
75
82
  args: {file: 'test_helper.rb'}
76
83
  ])
77
84
 
85
+ stub_request(:post, "http://10.10.10.10:9292/tracermetrics")
86
+ .to_return(status: 200)
87
+
78
88
  stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby.0")
79
89
  .to_return(status: 200, body: action)
80
90
 
@@ -90,6 +100,9 @@ class HostAgentReportingObserverTest < Minitest::Test
90
100
  end
91
101
 
92
102
  def test_agent_action_error
103
+ stub_request(:post, "http://10.10.10.10:9292/tracermetrics")
104
+ .to_return(status: 200)
105
+
93
106
  stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby.0")
94
107
  .to_return(status: 200, body: 'INVALID')
95
108
 
@@ -114,6 +127,75 @@ class HostAgentReportingObserverTest < Minitest::Test
114
127
  ::Instana.config[:metrics][:enabled] = true
115
128
  end
116
129
 
130
+ def test_disable_metrics_memory
131
+ ::Instana.config[:metrics][:memory][:enabled] = false
132
+
133
+ stub_request(:post, "http://10.10.10.10:9292/tracermetrics")
134
+ .to_return(status: 200)
135
+
136
+ stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby.0")
137
+ .with(body: ->(data) { (JSON.parse(data).keys & ['exec_args', 'memory']).length.eql?(0) })
138
+ .to_return(status: 200)
139
+
140
+ stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby/traces.0")
141
+ .to_return(status: 200)
142
+
143
+ client = Instana::Backend::RequestClient.new('10.10.10.10', 9292)
144
+ discovery = Concurrent::Atom.new({'pid' => 0})
145
+
146
+ subject = Instana::Backend::HostAgentReportingObserver.new(client, discovery, timer_class: MockTimer)
147
+
148
+ subject.report_timer.block.call
149
+ ensure
150
+ ::Instana.config[:metrics][:memory][:enabled] = true
151
+ end
152
+
153
+ def test_disable_gc
154
+ ::Instana.config[:metrics][:gc][:enabled] = false
155
+
156
+ stub_request(:post, "http://10.10.10.10:9292/tracermetrics")
157
+ .to_return(status: 200)
158
+
159
+ stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby.0")
160
+ .with(body: ->(data) { (JSON.parse(data).keys & ['gc']).length.eql?(0) })
161
+ .to_return(status: 200)
162
+
163
+ stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby/traces.0")
164
+ .to_return(status: 200)
165
+
166
+ client = Instana::Backend::RequestClient.new('10.10.10.10', 9292)
167
+ discovery = Concurrent::Atom.new({'pid' => 0})
168
+
169
+ subject = Instana::Backend::HostAgentReportingObserver.new(client, discovery, timer_class: MockTimer)
170
+
171
+ subject.report_timer.block.call
172
+ ensure
173
+ ::Instana.config[:metrics][:gc][:enabled] = true
174
+ end
175
+
176
+ def test_disable_thread
177
+ ::Instana.config[:metrics][:thread][:enabled] = false
178
+
179
+ stub_request(:post, "http://10.10.10.10:9292/tracermetrics")
180
+ .to_return(status: 200)
181
+
182
+ stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby.0")
183
+ .with(body: ->(data) { (JSON.parse(data).keys & ['thread']).length.eql?(0) })
184
+ .to_return(status: 200)
185
+
186
+ stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby/traces.0")
187
+ .to_return(status: 200)
188
+
189
+ client = Instana::Backend::RequestClient.new('10.10.10.10', 9292)
190
+ discovery = Concurrent::Atom.new({'pid' => 0})
191
+
192
+ subject = Instana::Backend::HostAgentReportingObserver.new(client, discovery, timer_class: MockTimer)
193
+
194
+ subject.report_timer.block.call
195
+ ensure
196
+ ::Instana.config[:metrics][:thread][:enabled] = true
197
+ end
198
+
117
199
  def test_disable_tracing
118
200
  ::Instana.config[:tracing][:enabled] = false
119
201
 
@@ -60,4 +60,24 @@ class ProcessInfoTest < Minitest::Test
60
60
  assert_equal subject.sched_pid, subject.parent_pid
61
61
  end
62
62
  end
63
+
64
+ def test_osx_memory_used
65
+ host_os = RbConfig::CONFIG['host_os']
66
+ RbConfig::CONFIG['host_os'] = 'darwin'
67
+
68
+ subject = Instana::Backend::ProcessInfo.new(OpenStruct.new(rss: 1024))
69
+ assert_equal 1, subject.memory_used
70
+ ensure
71
+ RbConfig::CONFIG['host_os'] = host_os
72
+ end
73
+
74
+ def test_linux_memory_used
75
+ host_os = RbConfig::CONFIG['host_os']
76
+ RbConfig::CONFIG['host_os'] = 'linux'
77
+
78
+ subject = Instana::Backend::ProcessInfo.new(OpenStruct.new(rss: 1))
79
+ assert_equal 4096, subject.memory_used
80
+ ensure
81
+ RbConfig::CONFIG['host_os'] = host_os
82
+ end
63
83
  end
@@ -38,8 +38,6 @@ class RailsActiveRecordTest < Minitest::Test
38
38
  data = span[:data][:activerecord]
39
39
 
40
40
  assert data[:sql].start_with?('INSERT INTO')
41
- assert 'core', data[:binds][0]
42
- assert 'blue', data[:binds][1]
43
41
  end
44
42
 
45
43
  def test_read
@@ -54,8 +52,6 @@ class RailsActiveRecordTest < Minitest::Test
54
52
  data = span[:data][:activerecord]
55
53
 
56
54
  assert data[:sql].start_with?('SELECT')
57
- assert 'core', data[:binds][0]
58
- assert 1, data[:binds][1]
59
55
  end
60
56
 
61
57
  def test_update
@@ -73,8 +69,6 @@ class RailsActiveRecordTest < Minitest::Test
73
69
  data = span[:data][:activerecord]
74
70
 
75
71
  assert data[:sql].start_with?('UPDATE')
76
- assert 'red', data[:binds][0]
77
- assert 1, data[:binds][2]
78
72
  end
79
73
 
80
74
  def test_delete
@@ -90,7 +84,6 @@ class RailsActiveRecordTest < Minitest::Test
90
84
  data = span[:data][:activerecord]
91
85
 
92
86
  assert data[:sql].start_with?('DELETE')
93
- assert 1, data[:binds][0]
94
87
  end
95
88
 
96
89
  def test_raw
@@ -10,8 +10,6 @@ class ErrorJob
10
10
  def self.perform
11
11
  if ENV.key?('REDIS_URL')
12
12
  redis = Redis.new(:url => ENV['REDIS_URL'])
13
- elsif ENV.key?('REDIS_URL')
14
- redis = Redis.new(:url => ENV['REDIS_URL'])
15
13
  else
16
14
  redis = Redis.new(:url => 'localhost:6379')
17
15
  end
@@ -20,6 +18,5 @@ class ErrorJob
20
18
  redis.set('ts', dt)
21
19
 
22
20
  raise Exception.new("Silly Rabbit, Trix are for kids.")
23
- redis.set(:nb_id, 2)
24
21
  end
25
22
  end
@@ -12,8 +12,6 @@ class FastJob
12
12
 
13
13
  if ENV.key?('REDIS_URL')
14
14
  redis = Redis.new(:url => ENV['REDIS_URL'])
15
- elsif ENV.key?('REDIS_URL')
16
- redis = Redis.new(:url => ENV['REDIS_URL'])
17
15
  else
18
16
  redis = Redis.new(:url => 'redis://localhost:6379')
19
17
  end
@@ -111,7 +111,6 @@ class CustomTracingTest < Minitest::Test
111
111
 
112
112
  ::Instana.tracer.log_entry(:custom_span, kvs)
113
113
  raise "custom tracing error. This is only a test"
114
- ::Instana.tracer.log_info({:on_info_kv => 1})
115
114
  rescue => e
116
115
  ::Instana.tracer.log_error(e)
117
116
  ensure
@@ -133,4 +133,21 @@ class SpanTest < Minitest::Test
133
133
  assert_equal({}, span.tags)
134
134
  time.verify
135
135
  end
136
+
137
+ def test_inc_processed_counts
138
+ clear_all!
139
+
140
+ span = Instana::Span.new(:excon)
141
+ span.close
142
+
143
+ metrics = Instana.processor.span_metrics
144
+
145
+ assert_equal 1, metrics[:opened]
146
+ assert_equal 1, metrics[:closed]
147
+
148
+ metrics = Instana.processor.span_metrics
149
+
150
+ assert_equal 0, metrics[:opened]
151
+ assert_equal 0, metrics[:closed]
152
+ end
136
153
  end
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.204.0.pre3
4
+ version: 1.207.0
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: 2021-07-08 00:00:00.000000000 Z
11
+ date: 2021-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -275,6 +275,7 @@ files:
275
275
  - lib/instana/version.rb
276
276
  - lib/opentracing.rb
277
277
  - log/.keep
278
+ - sonar-project.properties
278
279
  - test/activator_test.rb
279
280
  - test/backend/agent_test.rb
280
281
  - test/backend/gc_snapshot_test.rb
@@ -370,9 +371,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
370
371
  version: '2.1'
371
372
  required_rubygems_version: !ruby/object:Gem::Requirement
372
373
  requirements:
373
- - - ">"
374
+ - - ">="
374
375
  - !ruby/object:Gem::Version
375
- version: 1.3.1
376
+ version: '0'
376
377
  requirements: []
377
378
  rubygems_version: 3.1.6
378
379
  signing_key: