instana 1.201.0 → 1.202.0
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 +14 -5
- data/lib/instana/activator.rb +2 -0
- data/lib/instana/config.rb +3 -0
- data/lib/instana/frameworks/rails.rb +5 -5
- data/lib/instana/instrumented_logger.rb +26 -0
- data/lib/instana/setup.rb +2 -0
- data/lib/instana/tracing/span.rb +2 -2
- data/lib/instana/version.rb +1 -1
- data/test/test_helper.rb +10 -1
- data/test/tracing/instrumented_logger_test.rb +39 -0
- metadata +62 -59
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c72533e116e54ad36227ccdf76c02aaaeb3536f40c99ecf1009f0cf284ebf99
|
4
|
+
data.tar.gz: 3f748a84fed00443296d65340fc71e876a69c17d8698637356529d6d5980aa5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '009d83c5f6a7d8a5f4da1903fb482c6fe5a5cb68de6c984c1a58f52b01559bae3bbf43a10f028deae5cabe73c41a07e625f5545037ca295d53108e03564efbe1'
|
7
|
+
data.tar.gz: 241d6f1b46de88f5e7933dc85530cc5f540f71f9d9ad26b0778ffb970645b2c5c2aa4d0b11f05d85033cb4232339e9e27b92bfcd386fe79a1e3d9578485c9bfc
|
data/.circleci/config.yml
CHANGED
@@ -132,12 +132,12 @@ commands:
|
|
132
132
|
name: Install Depdendecies
|
133
133
|
command: |
|
134
134
|
bundle check || bundle install
|
135
|
-
|
135
|
+
run_sonarqube:
|
136
136
|
steps:
|
137
137
|
- run:
|
138
|
-
name:
|
138
|
+
name: Install Java
|
139
139
|
command: |
|
140
|
-
|
140
|
+
sudo apt-get install openjdk-11-jdk
|
141
141
|
- run:
|
142
142
|
name: Run SonarQube to capture coverage
|
143
143
|
command: |
|
@@ -147,8 +147,16 @@ commands:
|
|
147
147
|
-Dsonar.projectKey=ruby-sensor \
|
148
148
|
-Dsonar.sources=. \
|
149
149
|
-Dsonar.host.url="${SONARQUBE_URL}" \
|
150
|
-
-Dsonar.login="${SONARQUBE_LOGIN}"
|
151
|
-
|
150
|
+
-Dsonar.login="${SONARQUBE_LOGIN}"
|
151
|
+
run_tests:
|
152
|
+
steps:
|
153
|
+
- run:
|
154
|
+
name: Run Tests
|
155
|
+
command: |
|
156
|
+
mkdir _junit
|
157
|
+
bundle exec rake
|
158
|
+
- store_test_results:
|
159
|
+
path: ~/_junit
|
152
160
|
run_rubocop:
|
153
161
|
steps:
|
154
162
|
- run:
|
@@ -201,6 +209,7 @@ jobs:
|
|
201
209
|
- checkout
|
202
210
|
- setup
|
203
211
|
- run_rubocop
|
212
|
+
- run_sonarqube
|
204
213
|
publish:
|
205
214
|
executor: ruby_27
|
206
215
|
steps:
|
data/lib/instana/activator.rb
CHANGED
@@ -46,11 +46,13 @@ end
|
|
46
46
|
Dir["#{__dir__}/activators/*.rb"]
|
47
47
|
.sort
|
48
48
|
.select do |f|
|
49
|
+
# :nocov:
|
49
50
|
if ENV['INSTANA_ACTIVATE_SET']
|
50
51
|
base = File.basename(f, '.rb')
|
51
52
|
ENV.fetch('INSTANA_ACTIVATE_SET', '').split(',').include?(base)
|
52
53
|
else
|
53
54
|
true
|
54
55
|
end
|
56
|
+
# :nocov:
|
55
57
|
end
|
56
58
|
.each { |f| require(f) }
|
data/lib/instana/config.rb
CHANGED
@@ -27,6 +27,9 @@ module Instana
|
|
27
27
|
# Enable/disable tracing (default: enabled)
|
28
28
|
@config[:tracing] = { :enabled => true }
|
29
29
|
|
30
|
+
# Enable/Disable logging
|
31
|
+
@config[:logging] = { :enabled => true }
|
32
|
+
|
30
33
|
# Collector interval
|
31
34
|
@config[:collector] = { :enabled => true, :interval => 1 }
|
32
35
|
|
@@ -3,9 +3,6 @@
|
|
3
3
|
|
4
4
|
if ::Rails::VERSION::MAJOR < 3
|
5
5
|
::Rails.configuration.after_initialize do
|
6
|
-
# In Rails, let's use the Rails logger
|
7
|
-
::Instana.logger = ::Rails.logger if ::Rails.logger
|
8
|
-
|
9
6
|
if ::Instana.config[:tracing][:enabled]
|
10
7
|
::Instana.logger.debug "Instrumenting Rack"
|
11
8
|
::Rails.configuration.middleware.insert 0, ::Instana::Rack
|
@@ -17,8 +14,11 @@ else
|
|
17
14
|
module ::Instana
|
18
15
|
class Railtie < ::Rails::Railtie
|
19
16
|
initializer 'instana.rack' do |app|
|
20
|
-
#
|
21
|
-
::Instana.
|
17
|
+
# Configure the Instrumented Logger
|
18
|
+
if ::Instana.config[:logging][:enabled] && !ENV.key?('INSTANA_TEST')
|
19
|
+
logger = ::Instana::InstrumentedLogger.new('/dev/null')
|
20
|
+
Rails.logger.extend(ActiveSupport::Logger.broadcast(logger))
|
21
|
+
end
|
22
22
|
|
23
23
|
if ::Instana.config[:tracing][:enabled]
|
24
24
|
::Instana.logger.debug "Instrumenting Rack"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
module Instana
|
5
|
+
class InstrumentedLogger < Logger
|
6
|
+
LEVEL_LABELS = %w[Debug Info Warn Error Fatal Any].freeze
|
7
|
+
|
8
|
+
def instana_log_level
|
9
|
+
WARN
|
10
|
+
end
|
11
|
+
|
12
|
+
def add(severity, message = nil, progname = nil)
|
13
|
+
severity ||= UNKNOWN
|
14
|
+
|
15
|
+
if severity >= instana_log_level && ::Instana.tracer.tracing?
|
16
|
+
tags = {
|
17
|
+
level: LEVEL_LABELS[severity],
|
18
|
+
message: "#{message} #{progname}".strip
|
19
|
+
}
|
20
|
+
Instana::Tracer.trace(:log, {log: tags}) {}
|
21
|
+
end
|
22
|
+
|
23
|
+
super(severity, message, progname)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/instana/setup.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# (c) Copyright IBM Corp. 2021
|
2
2
|
# (c) Copyright Instana Inc. 2016
|
3
3
|
|
4
|
+
require 'logger'
|
4
5
|
require 'concurrent'
|
5
6
|
require 'sys-proctable'
|
6
7
|
|
7
8
|
require 'instana/logger_delegator'
|
9
|
+
require 'instana/instrumented_logger'
|
8
10
|
|
9
11
|
require "instana/base"
|
10
12
|
require "instana/config"
|
data/lib/instana/tracing/span.rb
CHANGED
@@ -6,10 +6,10 @@ module Instana
|
|
6
6
|
REGISTERED_SPANS = [ :actioncontroller, :actionview, :activerecord, :excon,
|
7
7
|
:memcache, :'net-http', :rack, :render, :'rpc-client',
|
8
8
|
:'rpc-server', :'sidekiq-client', :'sidekiq-worker',
|
9
|
-
:redis, :'resque-client', :'resque-worker', :'graphql.server', :dynamodb, :s3, :sns, :sqs, :'aws.lambda.entry', :activejob ].freeze
|
9
|
+
:redis, :'resque-client', :'resque-worker', :'graphql.server', :dynamodb, :s3, :sns, :sqs, :'aws.lambda.entry', :activejob, :log ].freeze
|
10
10
|
ENTRY_SPANS = [ :rack, :'resque-worker', :'rpc-server', :'sidekiq-worker', :'graphql.server', :sqs, :'aws.lambda.entry' ].freeze
|
11
11
|
EXIT_SPANS = [ :activerecord, :excon, :'net-http', :'resque-client',
|
12
|
-
:'rpc-client', :'sidekiq-client', :redis, :dynamodb, :s3, :sns, :sqs ].freeze
|
12
|
+
:'rpc-client', :'sidekiq-client', :redis, :dynamodb, :s3, :sns, :sqs, :log ].freeze
|
13
13
|
HTTP_SPANS = [ :rack, :excon, :'net-http' ].freeze
|
14
14
|
|
15
15
|
attr_accessor :parent
|
data/lib/instana/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -50,5 +50,14 @@ WebMock.disable_net_connect!(
|
|
50
50
|
|
51
51
|
Dir['test/support/*.rb'].each { |f| load(f) }
|
52
52
|
|
53
|
-
|
53
|
+
if ENV['CI']
|
54
|
+
Minitest::Reporters.use!([
|
55
|
+
Minitest::Reporters::JUnitReporter.new('_junit', false),
|
56
|
+
Minitest::Reporters::SpecReporter.new
|
57
|
+
])
|
58
|
+
else
|
59
|
+
Minitest::Reporters.use!([
|
60
|
+
MiniTest::Reporters::SpecReporter.new
|
61
|
+
])
|
62
|
+
end
|
54
63
|
Minitest::Test.include(Instana::TestHelpers)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
|
6
|
+
class InstrumentedLoggerTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
clear_all!
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_log_warn_error
|
12
|
+
subject = Instana::InstrumentedLogger.new('/dev/null')
|
13
|
+
|
14
|
+
Instana::Tracer.start_or_continue_trace(:test_logging) do
|
15
|
+
subject.warn('warn')
|
16
|
+
subject.debug('test')
|
17
|
+
subject.error('error')
|
18
|
+
end
|
19
|
+
|
20
|
+
spans = ::Instana.processor.queued_spans
|
21
|
+
|
22
|
+
warn_span, error_span, = *spans
|
23
|
+
|
24
|
+
assert_equal :log, warn_span[:n]
|
25
|
+
assert_equal 'warn', warn_span[:data][:log][:message]
|
26
|
+
assert_equal 'Warn', warn_span[:data][:log][:level]
|
27
|
+
|
28
|
+
assert_equal :log, error_span[:n]
|
29
|
+
assert_equal 'error', error_span[:data][:log][:message]
|
30
|
+
assert_equal 'Error', error_span[:data][:log][:level]
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_no_trace
|
34
|
+
subject = Instana::InstrumentedLogger.new('/dev/null')
|
35
|
+
subject.warn('warn')
|
36
|
+
|
37
|
+
assert_equal [], ::Instana.processor.queued_spans
|
38
|
+
end
|
39
|
+
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.
|
4
|
+
version: 1.202.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-06-
|
11
|
+
date: 2021-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -244,6 +244,7 @@ files:
|
|
244
244
|
- lib/instana/instrumentation/shoryuken.rb
|
245
245
|
- lib/instana/instrumentation/sidekiq-client.rb
|
246
246
|
- lib/instana/instrumentation/sidekiq-worker.rb
|
247
|
+
- lib/instana/instrumented_logger.rb
|
247
248
|
- lib/instana/logger_delegator.rb
|
248
249
|
- lib/instana/open_tracing/carrier.rb
|
249
250
|
- lib/instana/open_tracing/instana_tracer.rb
|
@@ -334,6 +335,7 @@ files:
|
|
334
335
|
- test/test_helper.rb
|
335
336
|
- test/tracing/custom_test.rb
|
336
337
|
- test/tracing/id_management_test.rb
|
338
|
+
- test/tracing/instrumented_logger_test.rb
|
337
339
|
- test/tracing/opentracing_test.rb
|
338
340
|
- test/tracing/processor_test.rb
|
339
341
|
- test/tracing/span_context_test.rb
|
@@ -364,81 +366,82 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
364
366
|
- !ruby/object:Gem::Version
|
365
367
|
version: '0'
|
366
368
|
requirements: []
|
367
|
-
rubygems_version: 3.
|
369
|
+
rubygems_version: 3.2.6
|
368
370
|
signing_key:
|
369
371
|
specification_version: 4
|
370
372
|
summary: Ruby Distributed Tracing & Metrics Sensor for Instana
|
371
373
|
test_files:
|
374
|
+
- test/config_test.rb
|
375
|
+
- test/serverless_test.rb
|
372
376
|
- test/activator_test.rb
|
373
|
-
- test/
|
374
|
-
- test/
|
377
|
+
- test/tracing/span_context_test.rb
|
378
|
+
- test/tracing/span_test.rb
|
379
|
+
- test/tracing/id_management_test.rb
|
380
|
+
- test/tracing/tracer_test.rb
|
381
|
+
- test/tracing/custom_test.rb
|
382
|
+
- test/tracing/opentracing_test.rb
|
383
|
+
- test/tracing/instrumented_logger_test.rb
|
384
|
+
- test/tracing/tracer_async_test.rb
|
385
|
+
- test/tracing/processor_test.rb
|
386
|
+
- test/snapshot/docker_container_test.rb
|
387
|
+
- test/snapshot/fargate_process_test.rb
|
388
|
+
- test/snapshot/deltable_test.rb
|
389
|
+
- test/snapshot/fargate_task_test.rb
|
390
|
+
- test/snapshot/ruby_process_test.rb
|
391
|
+
- test/snapshot/google_cloud_run_process_test.rb
|
392
|
+
- test/snapshot/lambda_function_test.rb
|
393
|
+
- test/snapshot/fargate_container_test.rb
|
394
|
+
- test/snapshot/google_cloud_run_instance_test.rb
|
375
395
|
- test/backend/host_agent_activation_observer_test.rb
|
376
|
-
- test/backend/host_agent_lookup_test.rb
|
377
396
|
- test/backend/host_agent_reporting_observer_test.rb
|
378
|
-
- test/backend/
|
397
|
+
- test/backend/gc_snapshot_test.rb
|
398
|
+
- test/backend/host_agent_lookup_test.rb
|
399
|
+
- test/backend/serverless_agent_test.rb
|
379
400
|
- test/backend/process_info_test.rb
|
401
|
+
- test/backend/agent_test.rb
|
402
|
+
- test/backend/host_agent_test.rb
|
380
403
|
- test/backend/request_client_test.rb
|
381
|
-
- test/
|
382
|
-
- test/benchmarks/bench_id_generation.rb
|
383
|
-
- test/benchmarks/bench_opentracing.rb
|
384
|
-
- test/config_test.rb
|
385
|
-
- test/frameworks/cuba_test.rb
|
386
|
-
- test/frameworks/roda_test.rb
|
387
|
-
- test/frameworks/sinatra_test.rb
|
388
|
-
- test/instana_test.rb
|
389
|
-
- test/instrumentation/aws_test.rb
|
390
|
-
- test/instrumentation/dalli_test.rb
|
391
|
-
- test/instrumentation/excon_test.rb
|
404
|
+
- test/secrets_test.rb
|
392
405
|
- test/instrumentation/graphql_test.rb
|
393
|
-
- test/instrumentation/
|
394
|
-
- test/instrumentation/net_http_test.rb
|
395
|
-
- test/instrumentation/rack_instrumented_request_test.rb
|
396
|
-
- test/instrumentation/rack_test.rb
|
397
|
-
- test/instrumentation/rails_action_cable_test.rb
|
406
|
+
- test/instrumentation/sidekiq-client_test.rb
|
398
407
|
- test/instrumentation/rails_action_controller_test.rb
|
408
|
+
- test/instrumentation/rest_client_test.rb
|
409
|
+
- test/instrumentation/net_http_test.rb
|
410
|
+
- test/instrumentation/resque_test.rb
|
411
|
+
- test/instrumentation/sidekiq-worker_test.rb
|
399
412
|
- test/instrumentation/rails_action_view_test.rb
|
400
413
|
- test/instrumentation/rails_active_job_test.rb
|
414
|
+
- test/instrumentation/rack_test.rb
|
415
|
+
- test/instrumentation/rack_instrumented_request_test.rb
|
416
|
+
- test/instrumentation/shoryuken_test.rb
|
401
417
|
- test/instrumentation/rails_active_record_test.rb
|
402
418
|
- test/instrumentation/redis_test.rb
|
403
|
-
- test/instrumentation/
|
404
|
-
- test/instrumentation/
|
405
|
-
- test/instrumentation/
|
406
|
-
- test/instrumentation/
|
407
|
-
- test/instrumentation/
|
408
|
-
- test/
|
409
|
-
- test/
|
410
|
-
- test/
|
411
|
-
- test/
|
412
|
-
- test/
|
413
|
-
- test/
|
414
|
-
- test/
|
415
|
-
- test/snapshot/google_cloud_run_instance_test.rb
|
416
|
-
- test/snapshot/google_cloud_run_process_test.rb
|
417
|
-
- test/snapshot/lambda_function_test.rb
|
418
|
-
- test/snapshot/ruby_process_test.rb
|
419
|
-
- test/support/apps/active_record/active_record.rb
|
419
|
+
- test/instrumentation/dalli_test.rb
|
420
|
+
- test/instrumentation/rails_action_cable_test.rb
|
421
|
+
- test/instrumentation/excon_test.rb
|
422
|
+
- test/instrumentation/grpc_test.rb
|
423
|
+
- test/instrumentation/aws_test.rb
|
424
|
+
- test/util_test.rb
|
425
|
+
- test/support/helpers.rb
|
426
|
+
- test/support/mock_timer.rb
|
427
|
+
- test/support/apps/sidekiq/boot.rb
|
428
|
+
- test/support/apps/sidekiq/jobs/sidekiq_job_2.rb
|
429
|
+
- test/support/apps/sidekiq/jobs/sidekiq_job_1.rb
|
430
|
+
- test/support/apps/sidekiq/worker.rb
|
420
431
|
- test/support/apps/grpc/boot.rb
|
421
432
|
- test/support/apps/grpc/grpc_server.rb
|
422
|
-
- test/support/apps/
|
423
|
-
- test/support/apps/rails/boot.rb
|
424
|
-
- test/support/apps/rails/models/block.rb
|
425
|
-
- test/support/apps/rails/models/block6.rb
|
433
|
+
- test/support/apps/active_record/active_record.rb
|
426
434
|
- test/support/apps/resque/boot.rb
|
427
435
|
- test/support/apps/resque/jobs/resque_error_job.rb
|
428
436
|
- test/support/apps/resque/jobs/resque_fast_job.rb
|
429
|
-
- test/support/apps/
|
430
|
-
- test/support/apps/
|
431
|
-
- test/support/apps/
|
432
|
-
- test/support/apps/
|
433
|
-
- test/
|
434
|
-
- test/
|
437
|
+
- test/support/apps/http_endpoint/boot.rb
|
438
|
+
- test/support/apps/rails/models/block.rb
|
439
|
+
- test/support/apps/rails/models/block6.rb
|
440
|
+
- test/support/apps/rails/boot.rb
|
441
|
+
- test/benchmarks/bench_opentracing.rb
|
442
|
+
- test/benchmarks/bench_id_generation.rb
|
435
443
|
- test/test_helper.rb
|
436
|
-
- test/
|
437
|
-
- test/
|
438
|
-
- test/
|
439
|
-
- test/
|
440
|
-
- test/tracing/span_context_test.rb
|
441
|
-
- test/tracing/span_test.rb
|
442
|
-
- test/tracing/tracer_async_test.rb
|
443
|
-
- test/tracing/tracer_test.rb
|
444
|
-
- test/util_test.rb
|
444
|
+
- test/frameworks/cuba_test.rb
|
445
|
+
- test/frameworks/roda_test.rb
|
446
|
+
- test/frameworks/sinatra_test.rb
|
447
|
+
- test/instana_test.rb
|