solarwinds_apm 6.0.0.preV5 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/ext/oboe_metal/extconf.rb +5 -4
  3. data/ext/oboe_metal/lib/liboboe-1.0-aarch64.so.sha256 +1 -1
  4. data/ext/oboe_metal/lib/liboboe-1.0-alpine-aarch64.so.sha256 +1 -1
  5. data/ext/oboe_metal/lib/liboboe-1.0-alpine-x86_64.so.sha256 +1 -1
  6. data/ext/oboe_metal/lib/liboboe-1.0-x86_64.so.sha256 +1 -1
  7. data/ext/oboe_metal/src/VERSION +1 -1
  8. data/ext/oboe_metal/src/oboe.h +56 -13
  9. data/ext/oboe_metal/src/oboe_api.cpp +105 -6
  10. data/ext/oboe_metal/src/oboe_api.h +121 -2
  11. data/ext/oboe_metal/src/oboe_debug.h +4 -315
  12. data/ext/oboe_metal/src/oboe_swig_wrap.cc +2987 -549
  13. data/lib/oboe_metal.rb +23 -64
  14. data/lib/rails/generators/solarwinds_apm/templates/solarwinds_apm_initializer.rb +1 -1
  15. data/lib/solarwinds_apm/api/current_trace_info.rb +2 -3
  16. data/lib/solarwinds_apm/api/opentelemetry.rb +2 -2
  17. data/lib/solarwinds_apm/api/tracing.rb +1 -1
  18. data/lib/solarwinds_apm/api.rb +1 -1
  19. data/lib/solarwinds_apm/config.rb +56 -17
  20. data/lib/solarwinds_apm/constants.rb +5 -7
  21. data/lib/solarwinds_apm/noop/README.md +1 -1
  22. data/lib/solarwinds_apm/noop/api.rb +83 -0
  23. data/lib/solarwinds_apm/noop/context.rb +13 -2
  24. data/lib/solarwinds_apm/noop/metadata.rb +5 -2
  25. data/lib/solarwinds_apm/{thread_local.rb → noop/span.rb} +14 -20
  26. data/lib/solarwinds_apm/{base.rb → noop.rb} +22 -27
  27. data/lib/solarwinds_apm/oboe_init_options.rb +23 -82
  28. data/lib/solarwinds_apm/opentelemetry/solarwinds_exporter.rb +1 -1
  29. data/lib/solarwinds_apm/opentelemetry/solarwinds_processor.rb +2 -2
  30. data/lib/solarwinds_apm/opentelemetry/solarwinds_sampler.rb +4 -3
  31. data/lib/solarwinds_apm/opentelemetry.rb +1 -1
  32. data/lib/solarwinds_apm/otel_config.rb +14 -43
  33. data/lib/solarwinds_apm/patch/dummy_patch.rb +12 -0
  34. data/lib/solarwinds_apm/patch.rb +11 -0
  35. data/lib/solarwinds_apm/support/logger_formatter.rb +1 -1
  36. data/lib/solarwinds_apm/support/oboe_tracing_mode.rb +20 -22
  37. data/lib/solarwinds_apm/support/service_key_checker.rb +94 -0
  38. data/lib/solarwinds_apm/{support_report.rb → support/support_report.rb} +11 -8
  39. data/lib/solarwinds_apm/support/swomarginalia/comment.rb +2 -2
  40. data/lib/solarwinds_apm/support/swomarginalia/swomarginalia.rb +1 -1
  41. data/lib/solarwinds_apm/support/transaction_settings.rb +1 -5
  42. data/lib/solarwinds_apm/support.rb +1 -0
  43. data/lib/solarwinds_apm/version.rb +1 -1
  44. data/lib/solarwinds_apm.rb +70 -55
  45. metadata +12 -7
data/lib/oboe_metal.rb CHANGED
@@ -7,9 +7,22 @@
7
7
  # Disable docs and Camelcase warns since we're implementing
8
8
  # an interface here. See OboeBase for details.
9
9
  module SolarWindsAPM
10
- extend SolarWindsAPMBase
11
10
  include Oboe_metal
12
11
 
12
+ @loaded = false
13
+ @reporter = nil
14
+
15
+ class << self
16
+ attr_accessor :reporter, :loaded
17
+
18
+ def sample_rate(rate)
19
+ return unless SolarWindsAPM.loaded
20
+
21
+ # Update liboboe with the new SampleRate value
22
+ SolarWindsAPM::Context.setDefaultSampleRate(rate.to_i)
23
+ end
24
+ end
25
+
13
26
  # Reporter that send span data to SWO
14
27
  class Reporter
15
28
  class << self
@@ -19,18 +32,14 @@ module SolarWindsAPM
19
32
  # Start the SolarWindsAPM Reporter
20
33
  #
21
34
  def start
22
- SolarWindsAPM.loaded = false unless SolarWindsAPM::OboeInitOptions.instance.service_key_ok?
23
- return unless SolarWindsAPM.loaded
24
-
25
35
  begin
26
36
  options = SolarWindsAPM::OboeInitOptions.instance.array_for_oboe # creates an array with the options in the right order
27
-
28
37
  SolarWindsAPM.reporter = Oboe_metal::Reporter.new(*options)
29
-
30
38
  report_init
39
+ SolarWindsAPM.loaded = true
31
40
  rescue StandardError=> e
32
41
  $stderr.puts e.message
33
- raise
42
+ SolarWindsAPM.loaded = false
34
43
  end
35
44
  end
36
45
  alias :restart :start
@@ -53,52 +62,6 @@ module SolarWindsAPM
53
62
  SolarWindsAPM.reporter.sendStatus(evt, context, with_system_timestamp)
54
63
  end
55
64
 
56
- ##
57
- # clear_all_traces
58
- #
59
- # Truncates the trace output file to zero
60
- #
61
- def clear_all_traces
62
- File.truncate(SolarWindsAPM::OboeInitOptions.instance.host, 0)
63
- end
64
-
65
- ##
66
- # obtain_all_traces
67
- #
68
- # Retrieves all traces written to the trace file
69
- #
70
- def obtain_all_traces
71
- io = File.open(SolarWindsAPM::OboeInitOptions.instance.host, 'r')
72
- contents = io.readlines(nil)
73
- io.close
74
-
75
- return contents if contents.empty?
76
-
77
- traces = []
78
-
79
- # We use Gem.loaded_spec because older versions of the bson
80
- # gem didn't even have a version embedded in the gem. If the
81
- # gem isn't in the bundle, it should rightfully error out
82
- # anyways.
83
- #
84
- if Gem.loaded_specs['bson'] && Gem.loaded_specs['bson'].version.to_s < '4.0'
85
- s = StringIO.new(contents[0])
86
-
87
- until s.eof?
88
- traces << if ::BSON.respond_to? :read_bson_document
89
- BSON.read_bson_document(s)
90
- else
91
- BSON::Document.from_bson(s)
92
- end
93
- end
94
- else
95
- bbb = ::BSON::ByteBuffer.new(contents[0])
96
- traces << Hash.from_bson(bbb) until bbb.length == 0
97
- end
98
-
99
- traces
100
- end
101
-
102
65
  private
103
66
 
104
67
  # Internal: Report that instrumentation for the given layer has been
@@ -205,16 +168,12 @@ module SolarWindsAPM
205
168
  end
206
169
  end
207
170
  end
208
-
209
- class << self
210
- def sample_rate(rate)
211
- return unless SolarWindsAPM.loaded
212
-
213
- # Update liboboe with the new SampleRate value
214
- SolarWindsAPM::Context.setDefaultSampleRate(rate.to_i)
215
- end
216
- end
217
171
  end
218
172
 
219
- SolarWindsAPM.loaded = true
220
- # rubocop:enable Style/Documentation
173
+ # rubocop:enable Style/Documentation
174
+
175
+ # Setup an alias
176
+ SolarWindsApm = SolarWindsAPM
177
+ SolarwindsApm = SolarWindsAPM
178
+ SolarwindsAPM = SolarWindsAPM
179
+ Solarwindsapm = SolarWindsAPM
@@ -147,7 +147,7 @@ if defined?(SolarWindsAPM::Config)
147
147
  # Trace options is a custom HTTP header X-Trace-Options that can be set on a request to carry additional information
148
148
  # to the agents, one such option being trigger-trace which we’ll call a trigger trace request.
149
149
  #
150
- SolarWindsAPM::Config[:trigger_tracing_mode] = 'enabled'
150
+ SolarWindsAPM::Config[:trigger_tracing_mode] = :enabled
151
151
 
152
152
  #
153
153
  # Argument logging
@@ -51,7 +51,7 @@ module SolarWindsAPM
51
51
  class TraceInfo
52
52
  attr_reader :tracestring, :trace_id, :span_id, :trace_flags, :do_log
53
53
 
54
- REGEXP = /^(?<tracestring>(?<version>[a-f0-9]{2})-(?<trace_id>[a-f0-9]{32})-(?<span_id>[a-f0-9]{16})-(?<flags>[a-f0-9]{2}))$/
54
+ REGEXP = /^(?<tracestring>(?<version>[a-f0-9]{2})-(?<trace_id>[a-f0-9]{32})-(?<span_id>[a-f0-9]{16})-(?<flags>[a-f0-9]{2}))$/.freeze # rubocop:disable Style/RedundantFreeze
55
55
  private_constant :REGEXP
56
56
 
57
57
  def initialize
@@ -98,8 +98,7 @@ module SolarWindsAPM
98
98
  # * Hash
99
99
  #
100
100
  def hash_for_log
101
- @hash_for_log = {}
102
- @hash_for_log = {trace_id: @trace_id, span_id: @span_id, trace_flags: @trace_flags, service_name: @service_name} if @do_log
101
+ @hash_for_log = @do_log ? {'trace_id' => @trace_id, 'span_id' => @span_id, 'trace_flags' => @trace_flags, 'resource.service.name' => @service_name} : {}
103
102
  end
104
103
 
105
104
  private
@@ -28,7 +28,7 @@ module SolarWindsAPM
28
28
  # end
29
29
  #
30
30
  # === Returns:
31
- # * Objective
31
+ # * value returned by block
32
32
  #
33
33
  def in_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil, &block)
34
34
  if block.nil?
@@ -42,4 +42,4 @@ module SolarWindsAPM
42
42
  end
43
43
  end
44
44
  end
45
- end
45
+ end
@@ -54,4 +54,4 @@ module SolarWindsAPM
54
54
  end
55
55
  end
56
56
  end
57
- end
57
+ end
@@ -18,4 +18,4 @@ module SolarWindsAPM
18
18
  extend SolarWindsAPM::API::OpenTelemetry
19
19
  extend SolarWindsAPM::API::CustomMetrics
20
20
  end
21
- end
21
+ end
@@ -12,6 +12,15 @@ module SolarWindsAPM
12
12
  # Use SolarWindsAPM::Config.show to view the entire nested hash.
13
13
  #
14
14
  module Config
15
+ SW_LOG_LEVEL_MAPPING = {-1 => {:stdlib => ::Logger::FATAL, :otel => 'fatal'},
16
+ 0 => {:stdlib => ::Logger::FATAL, :otel => 'fatal'},
17
+ 1 => {:stdlib => ::Logger::ERROR, :otel => 'error'},
18
+ 2 => {:stdlib => ::Logger::WARN, :otel => 'warn'},
19
+ 3 => {:stdlib => ::Logger::INFO, :otel => 'info'},
20
+ 4 => {:stdlib => ::Logger::DEBUG, :otel => 'debug'},
21
+ 5 => {:stdlib => ::Logger::DEBUG, :otel => 'debug'},
22
+ 6 => {:stdlib => ::Logger::DEBUG, :otel => 'debug'}}.freeze
23
+
15
24
  @@config = {}
16
25
  @@instrumentation = [:action_controller, :action_controller_api, :action_view,
17
26
  :active_record, :bunnyclient, :bunnyconsumer, :curb,
@@ -44,19 +53,20 @@ module SolarWindsAPM
44
53
  config_files << config_file if File.exist?(config_file)
45
54
 
46
55
  # Check for file set by env variable
47
- config_files << config_from_env if ENV.has_key?('SW_APM_CONFIG_RUBY')
56
+ config_files << config_file_from_env if ENV.has_key?('SW_APM_CONFIG_RUBY')
48
57
 
49
58
  # Check for default config file
50
59
  config_file = File.join(Dir.pwd, 'solarwinds_apm_config.rb')
51
60
  config_files << config_file if File.exist?(config_file)
52
61
 
62
+ SolarWindsAPM.logger.debug {"[#{name}/#{__method__}] Available config_files: #{config_files.join(', ')}" }
53
63
  SolarWindsAPM.logger.warn {"[#{name}/#{__method__}] Multiple configuration files configured, using the first one listed: #{config_files.join(', ')}"} if config_files.size > 1
54
64
  load(config_files[0]) if config_files.size > 0
55
65
 
56
66
  set_log_level # sets SolarWindsAPM::Config[:debug_level], SolarWindsAPM.logger.level
57
67
  end
58
68
 
59
- def self.config_from_env
69
+ def self.config_file_from_env
60
70
  if File.exist?(ENV['SW_APM_CONFIG_RUBY']) && !File.directory?(ENV['SW_APM_CONFIG_RUBY'])
61
71
  config_file = ENV['SW_APM_CONFIG_RUBY']
62
72
  elsif File.exist?(File.join(ENV['SW_APM_CONFIG_RUBY'], 'solarwinds_apm_config.rb'))
@@ -68,11 +78,40 @@ module SolarWindsAPM
68
78
  end
69
79
 
70
80
  def self.set_log_level
71
- SolarWindsAPM::Config[:debug_level] = 3 unless (-1..6).include?(SolarWindsAPM::Config[:debug_level])
81
+ log_level = (ENV['SW_APM_DEBUG_LEVEL'] || SolarWindsAPM::Config[:debug_level] || 3).to_i
82
+
83
+ SolarWindsAPM.logger = ::Logger.new(nil) if log_level == -1
84
+
85
+ SolarWindsAPM.logger.level = SW_LOG_LEVEL_MAPPING.dig(log_level, :stdlib) || ::Logger::INFO # default log level info
86
+ end
87
+
88
+ def self.enable_disable_config(env_var, key, value, default, bool: false)
89
+ env_value = ENV[env_var.to_s]&.downcase
90
+ valid_env_values = bool ? %w[true false] : %w[enabled disabled]
91
+
92
+ if env_var && valid_env_values.include?(env_value)
93
+ value = bool ? true?(env_value) : env_value.to_sym
94
+ elsif env_var && !env_value.to_s.empty?
95
+ SolarWindsAPM.logger.warn("[#{name}/#{__method__}] #{env_var} must be #{valid_env_values.join('/')} (current setting is #{ENV[env_var]}). Using default value: #{default}.")
96
+ return @@config[key.to_sym] = default
97
+ end
98
+
99
+ return @@config[key.to_sym] = value unless (bool && !boolean?(value)) || (!bool && !symbol?(value))
72
100
 
73
- # let's find and use the equivalent debug level for ruby
74
- debug_level = (ENV['SW_APM_DEBUG_LEVEL'] || SolarWindsAPM::Config[:debug_level] || 3).to_i
75
- SolarWindsAPM.logger.level = debug_level < 0 ? 6 : [4 - debug_level, 0].max
101
+ SolarWindsAPM.logger.warn("[#{name}/#{__method__}] :#{key} must be a #{valid_env_values.join('/')}. Using default value: #{default}.")
102
+ @@config[key.to_sym] = default
103
+ end
104
+
105
+ def self.true?(obj)
106
+ obj.to_s.casecmp("true").zero?
107
+ end
108
+
109
+ def self.boolean?(obj)
110
+ [true, false].include?(obj)
111
+ end
112
+
113
+ def self.symbol?(obj)
114
+ [:enabled, :disabled].include?(obj)
76
115
  end
77
116
 
78
117
  ##
@@ -82,10 +121,11 @@ module SolarWindsAPM
82
121
  # to create an output similar to the content of the config file
83
122
  #
84
123
  def self.print_config
85
- SolarWindsAPM.logger.warn {"[#{name}/#{__method__}] General configurations list blow:"}
124
+ SolarWindsAPM.logger.debug {"[#{name}/#{__method__}] General configurations list blow:"}
86
125
  @@config.each do |k,v|
87
- SolarWindsAPM.logger.warn {"[#{name}/#{__method__}] Config Key/Value: #{k}, #{v.inspect}"}
126
+ SolarWindsAPM.logger.debug {"[#{name}/#{__method__}] Config Key/Value: #{k}, #{v.inspect}"} unless @@instrumentation.include?(k)
88
127
  end
128
+ nil
89
129
  end
90
130
 
91
131
  ##
@@ -93,8 +133,9 @@ module SolarWindsAPM
93
133
  #
94
134
  # Initializer method to set everything up with a default configuration.
95
135
  # The defaults are read from the template configuration file.
136
+ # This will be called when require 'solarwinds_apm/config' happen
96
137
  #
97
- def self.initialize(_data={})
138
+ def self.initialize
98
139
  # for config file backward compatibility
99
140
  @@instrumentation.each {|inst| @@config[inst] = {}}
100
141
  @@config[:transaction_name] = {}
@@ -123,6 +164,7 @@ module SolarWindsAPM
123
164
  #
124
165
  # Config variable assignment method. Here we validate and store the
125
166
  # assigned value(s) and trigger any secondary action needed.
167
+ # ENV always have higher precedence
126
168
  #
127
169
  def self.[]=(key, value)
128
170
  key = key.to_sym
@@ -151,17 +193,14 @@ module SolarWindsAPM
151
193
  when :transaction_settings
152
194
  compile_settings(value)
153
195
 
196
+ when :trigger_tracing_mode
197
+ enable_disable_config('SW_APM_TRIGGER_TRACING_MODE', key, value, :enabled)
198
+
154
199
  when :tracing_mode
155
- # ALL TRACING COMMUNICATION TO OBOE IS NOW HANDLED BY TransactionSettings
156
- # Make sure that the mode is stored as a symbol
157
- @@config[key.to_sym] = value.to_sym
200
+ enable_disable_config(nil, key, value, :enabled)
158
201
 
159
202
  when :tag_sql
160
- if ENV.has_key?('SW_APM_TAG_SQL')
161
- @@config[key.to_sym] = (ENV['SW_APM_TAG_SQL'] == 'true')
162
- else
163
- @@config[key.to_sym] = value
164
- end
203
+ enable_disable_config('SW_APM_TAG_SQL', key, value, false, bool: true)
165
204
 
166
205
  else
167
206
  @@config[key.to_sym] = value
@@ -7,11 +7,10 @@
7
7
  module SolarWindsAPM
8
8
  # Constants
9
9
  module Constants
10
- HTTP_METHOD = "http.method".freeze
11
- HTTP_ROUTE = "http.route".freeze
12
- HTTP_STATUS_CODE = "http.status_code".freeze
13
- HTTP_URL = "http.url".freeze
14
-
10
+ HTTP_METHOD = "http.method".freeze
11
+ HTTP_ROUTE = "http.route".freeze
12
+ HTTP_STATUS_CODE = "http.status_code".freeze
13
+ HTTP_URL = "http.url".freeze
15
14
  INTL_SWO_AO_COLLECTOR = "collector.appoptics.com".freeze
16
15
  INTL_SWO_AO_STG_COLLECTOR = "collector-stg.appoptics.com".freeze
17
16
  INTL_SWO_COMMA = ",".freeze
@@ -30,7 +29,6 @@ module SolarWindsAPM
30
29
  INTL_SWO_OTEL_SCOPE_VERSION = "otel.scope.version".freeze
31
30
  INTL_SWO_OTEL_STATUS = "otel.status".freeze
32
31
  INTL_SWO_OTEL_STATUS_DESCRIPTION = "otel.status_description".freeze
33
-
34
32
  INTERNAL_TRIGGERED_TRACE = "TriggeredTrace".freeze
35
33
  end
36
- end
34
+ end
@@ -6,4 +6,4 @@ we load these classes when in noop mode and they expose noop behavior.
6
6
 
7
7
  so far only one class is needed:
8
8
 
9
- - SolarWindsAPM::Context and its toString() method from oboe
9
+ - SolarWindsAPM::Context and its toString() method from oboe
@@ -0,0 +1,83 @@
1
+ # © 2023 SolarWinds Worldwide, LLC. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:http://www.apache.org/licenses/LICENSE-2.0
4
+ #
5
+ # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
6
+
7
+ ####
8
+ # noop version of SolarWindsAPM::API
9
+ #
10
+ module SolarWindsAPM
11
+ # API
12
+ module API
13
+ end
14
+ end
15
+
16
+ module NoopAPI
17
+ # Tracing
18
+ module Tracing
19
+ # (wait_milliseconds=3000, integer_response: false)
20
+ def solarwinds_ready?(*_args, **options)
21
+ options && options[:integer_response] ? 0 : false
22
+ end
23
+ end
24
+
25
+ # CurrentTraceInfo
26
+ module CurrentTraceInfo
27
+ def current_trace_info
28
+ TraceInfo.new
29
+ end
30
+
31
+ class TraceInfo
32
+ attr_reader :tracestring, :trace_id, :span_id, :trace_flags, :do_log
33
+
34
+ def initialize
35
+ @trace_id = '00000000000000000000000000000000'
36
+ @span_id = '0000000000000000'
37
+ @trace_flags = '00'
38
+ @tracestring = '00-00000000000000000000000000000000-0000000000000000-00'
39
+ @service_name = ''
40
+ @do_log = :never
41
+ end
42
+
43
+ def for_log
44
+ ''
45
+ end
46
+
47
+ def hash_for_log
48
+ {}
49
+ end
50
+ end
51
+ end
52
+
53
+ # CustomMetrics
54
+ module CustomMetrics
55
+ def increment_metric(*)
56
+ false
57
+ end
58
+
59
+ def summary_metric(*)
60
+ false
61
+ end
62
+ end
63
+
64
+ # OpenTelemetry
65
+ module OpenTelemetry
66
+ def in_span(*)
67
+ yield if block_given?
68
+ end
69
+ end
70
+
71
+ # TransactionName
72
+ module TransactionName
73
+ def set_transaction_name(*)
74
+ true
75
+ end
76
+ end
77
+ end
78
+
79
+ SolarWindsAPM::API.extend(NoopAPI::Tracing)
80
+ SolarWindsAPM::API.extend(NoopAPI::CurrentTraceInfo)
81
+ SolarWindsAPM::API.extend(NoopAPI::CustomMetrics)
82
+ SolarWindsAPM::API.extend(NoopAPI::OpenTelemetry)
83
+ SolarWindsAPM::API.extend(NoopAPI::TransactionName)
@@ -7,9 +7,12 @@
7
7
  ####
8
8
  # noop version of SolarWindsAPM::Context
9
9
  #
10
- module SolarWindsAPM
10
+ # module SolarWindsAPM
11
+ # end
12
+
13
+ module Oboe_metal # rubocop:disable Naming/ClassAndModuleCamelCase
11
14
  # Context for noop
12
- module Context
15
+ class Context
13
16
  ##
14
17
  # noop version of :toString
15
18
  # toString would return the current trace context as string
@@ -18,6 +21,14 @@ module SolarWindsAPM
18
21
  '99-00000000000000000000000000000000-0000000000000000-00'
19
22
  end
20
23
 
24
+ def self.isReady(*)
25
+ false
26
+ end
27
+
28
+ def self.getDecisions(*)
29
+ [-1, -1, -1, 0, 0.0, 0.0, -1, -1, '', '', 4]
30
+ end
31
+
21
32
  ##
22
33
  # noop version of :clear
23
34
  #
@@ -7,8 +7,7 @@
7
7
  ####
8
8
  # noop version of SolarWindsAPM::Metadata
9
9
  #
10
- #
11
- module SolarWindsAPM
10
+ module Oboe_metal # rubocop:disable Naming/ClassAndModuleCamelCase
12
11
  # Metadata
13
12
  class Metadata
14
13
  ##
@@ -20,6 +19,10 @@ module SolarWindsAPM
20
19
  Metadata.new
21
20
  end
22
21
 
22
+ def self.fromString(*)
23
+ Metadata.new
24
+ end
25
+
23
26
  def isValid
24
27
  false
25
28
  end
@@ -4,26 +4,20 @@
4
4
  #
5
5
  # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
6
6
 
7
- module SolarWindsAPM
8
- ##
9
- # Provides thread local storage for SolarWindsAPM.
10
- #
11
- # Example usage:
12
- # module SolarWindsAPMBase
13
- # extend SolarWindsAPM::ThreadLocal
14
- # thread_local :layer_op
15
- # end
16
- module ThreadLocal
17
- def thread_local(name)
18
- key = "__#{self}_#{name}__".intern
19
-
20
- define_method(name) do
21
- Thread.current[key]
22
- end
7
+ ####
8
+ # noop version of SolarWindsAPM::Span
9
+ #
10
+ module Oboe_metal # rubocop:disable Naming/ClassAndModuleCamelCase
11
+ # Span
12
+ class Span
13
+ ##
14
+ # noop version of :createHttpSpan
15
+ #
16
+ def self.createHttpSpan(*); end
23
17
 
24
- define_method("#{name}=") do |value|
25
- Thread.current[key] = value
26
- end
27
- end
18
+ ##
19
+ # noop version of :createSpan
20
+ #
21
+ def self.createSpan(*); end
28
22
  end
29
23
  end
@@ -4,33 +4,28 @@
4
4
  #
5
5
  # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
6
6
 
7
- ##
8
- # This module is the base module for SolarWindsAPM reporting.
9
- #
10
- module SolarWindsAPMBase
11
- extend SolarWindsAPM::ThreadLocal
12
-
13
- attr_accessor :reporter, :loaded
14
-
15
- ##
16
- # Determines if we are running under a forking webserver
17
- #
18
- def forking_webserver?
19
- if (defined?(::Unicorn) && ($PROGRAM_NAME =~ /unicorn/i)) ||
20
- (defined?(::Puma) && ($PROGRAM_NAME =~ /puma/i))
21
- true
22
- else
23
- false
24
- end
25
- end
26
- end
7
+ require_relative './noop/context'
8
+ require_relative './noop/metadata'
9
+ require_relative './noop/span'
10
+ require_relative './noop/api'
27
11
 
28
12
  module SolarWindsAPM
29
- extend SolarWindsAPMBase
30
- end
13
+ include Oboe_metal
14
+ # Reporter noop
15
+ class Reporter
16
+ ##
17
+ # noop version of :send_report
18
+ #
19
+ def self.send_report(event, with_system_timestamp: false); end
20
+
21
+ ##
22
+ # noop version of :send_status
23
+ #
24
+ def self.send_status(event, context=nil, with_system_timestamp: false); end
31
25
 
32
- # Setup an alias
33
- SolarWindsApm = SolarWindsAPM
34
- SolarwindsApm = SolarWindsAPM
35
- SolarwindsAPM = SolarWindsAPM
36
- Solarwindsapm = SolarWindsAPM
26
+ ##
27
+ # noop version of :start
28
+ #
29
+ def self.start; end
30
+ end
31
+ end