solarwinds_apm 6.0.0.prev6 → 6.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/ext/oboe_metal/extconf.rb +43 -42
  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-lambda-aarch64.so.sha256 +1 -0
  7. data/ext/oboe_metal/lib/liboboe-1.0-lambda-x86_64.so.sha256 +1 -0
  8. data/ext/oboe_metal/lib/liboboe-1.0-x86_64.so.sha256 +1 -1
  9. data/ext/oboe_metal/src/VERSION +1 -1
  10. data/ext/oboe_metal/src/oboe.h +3 -0
  11. data/ext/oboe_metal/src/oboe_api.cpp +1 -1
  12. data/lib/oboe_metal.rb +46 -84
  13. data/lib/rails/generators/solarwinds_apm/install_generator.rb +21 -19
  14. data/lib/solarwinds_apm/api/current_trace_info.rb +16 -9
  15. data/lib/solarwinds_apm/api/custom_metrics.rb +6 -4
  16. data/lib/solarwinds_apm/api/opentelemetry.rb +10 -6
  17. data/lib/solarwinds_apm/api/tracing.rb +7 -5
  18. data/lib/solarwinds_apm/api/transaction_name.rb +21 -11
  19. data/lib/solarwinds_apm/api.rb +8 -6
  20. data/lib/solarwinds_apm/config.rb +72 -47
  21. data/lib/solarwinds_apm/constants.rb +26 -26
  22. data/lib/solarwinds_apm/logger.rb +2 -0
  23. data/lib/solarwinds_apm/noop/README.md +1 -1
  24. data/lib/solarwinds_apm/noop/api.rb +85 -0
  25. data/lib/solarwinds_apm/noop/context.rb +15 -2
  26. data/lib/solarwinds_apm/noop/metadata.rb +7 -2
  27. data/lib/solarwinds_apm/{base.rb → noop/span.rb} +16 -15
  28. data/lib/solarwinds_apm/noop.rb +33 -0
  29. data/lib/solarwinds_apm/oboe_init_options.rb +50 -111
  30. data/lib/solarwinds_apm/opentelemetry/otlp_processor.rb +135 -0
  31. data/lib/solarwinds_apm/opentelemetry/solarwinds_exporter.rb +66 -41
  32. data/lib/solarwinds_apm/opentelemetry/solarwinds_processor.rb +50 -52
  33. data/lib/solarwinds_apm/opentelemetry/solarwinds_propagator.rb +30 -22
  34. data/lib/solarwinds_apm/opentelemetry/solarwinds_response_propagator.rb +29 -16
  35. data/lib/solarwinds_apm/opentelemetry/solarwinds_sampler.rb +136 -99
  36. data/lib/solarwinds_apm/opentelemetry.rb +8 -5
  37. data/lib/solarwinds_apm/otel_config.rb +38 -43
  38. data/lib/solarwinds_apm/otel_lambda_config.rb +53 -0
  39. data/lib/solarwinds_apm/patch/dummy_patch.rb +12 -0
  40. data/lib/solarwinds_apm/{thread_local.rb → patch.rb} +6 -22
  41. data/lib/solarwinds_apm/support/logger_formatter.rb +4 -2
  42. data/lib/solarwinds_apm/support/logging_log_event.rb +2 -0
  43. data/lib/solarwinds_apm/support/lumberjack_formatter.rb +2 -0
  44. data/lib/solarwinds_apm/support/oboe_tracing_mode.rb +22 -22
  45. data/lib/solarwinds_apm/support/service_key_checker.rb +106 -0
  46. data/lib/solarwinds_apm/{support_report.rb → support/support_report.rb} +15 -10
  47. data/lib/solarwinds_apm/support/swomarginalia/comment.rb +18 -17
  48. data/lib/solarwinds_apm/support/swomarginalia/load_swomarginalia.rb +13 -12
  49. data/lib/solarwinds_apm/support/swomarginalia/railtie.rb +4 -2
  50. data/lib/solarwinds_apm/support/swomarginalia/swomarginalia.rb +3 -1
  51. data/lib/solarwinds_apm/support/transaction_cache.rb +6 -4
  52. data/lib/solarwinds_apm/support/transaction_settings.rb +7 -3
  53. data/lib/solarwinds_apm/support/txn_name_manager.rb +8 -3
  54. data/lib/solarwinds_apm/support/utils.rb +12 -9
  55. data/lib/solarwinds_apm/support/x_trace_options.rb +23 -17
  56. data/lib/solarwinds_apm/support.rb +28 -23
  57. data/lib/solarwinds_apm/version.rb +4 -2
  58. data/lib/solarwinds_apm.rb +82 -52
  59. metadata +23 -28
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # © 2023 SolarWinds Worldwide, LLC. All rights reserved.
2
4
  #
3
5
  # 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
@@ -13,7 +15,7 @@ module SolarWindsAPM
13
15
  # information during the whole time the process is running. It returns boolean if <tt>integer_response</tt> is false,
14
16
  # and it will return integer if setting <tt>integer_response</tt> as true.
15
17
  # Usually SolarWinds doesn't block an application while it is starting up.
16
- #
18
+ #
17
19
  # For status code reference:
18
20
  # 0: unknown error
19
21
  # 1: is ready
@@ -32,18 +34,18 @@ module SolarWindsAPM
32
34
  # unless SolarWindsAPM::API.solarwinds_ready?(10_000)
33
35
  # Logger.info "SolarWindsAPM not ready after 10 seconds, no metrics will be sent"
34
36
  # end
35
- #
37
+ #
36
38
  # # with status code print out
37
39
  # status = SolarWindsAPM::API.solarwinds_ready?(10_000, integer_response: true)
38
40
  # unless status == 1
39
41
  # Logger.info "SolarWindsAPM not ready after 10 seconds, no metrics will be sent. Error code "#{status}"
40
42
  # end
41
- #
43
+ #
42
44
  # === Returns:
43
45
  # * Boolean (if integer_response: false)
44
46
  # * Integer (if integer_response: true)
45
47
  #
46
- def solarwinds_ready?(wait_milliseconds=3000, integer_response: false)
48
+ def solarwinds_ready?(wait_milliseconds = 3000, integer_response: false)
47
49
  return false unless SolarWindsAPM.loaded
48
50
 
49
51
  is_ready = SolarWindsAPM::Context.isReady(wait_milliseconds)
@@ -54,4 +56,4 @@ module SolarWindsAPM
54
56
  end
55
57
  end
56
58
  end
57
- end
59
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # © 2023 SolarWinds Worldwide, LLC. All rights reserved.
2
4
  #
3
5
  # 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
@@ -35,35 +37,43 @@ module SolarWindsAPM
35
37
  # === Returns:
36
38
  # * Boolean
37
39
  #
38
- def set_transaction_name(custom_name=nil)
40
+ def set_transaction_name(custom_name = nil)
39
41
  status = true
40
42
  if ENV.fetch('SW_APM_ENABLED', 'true') == 'false' ||
41
43
  SolarWindsAPM::Context.toString == '99-00000000000000000000000000000000-0000000000000000-00'
42
44
  # library disabled or noop, just log and skip work.
43
45
  # TODO: can we have a single indicator that the API is in noop mode?
44
- SolarWindsAPM.logger.debug {"[#{name}/#{__method__}] SolarWindsAPM is in disabled or noop mode."}
46
+ SolarWindsAPM.logger.debug { "[#{name}/#{__method__}] SolarWindsAPM is in disabled or noop mode." }
45
47
  elsif custom_name.nil? || custom_name.empty?
46
- SolarWindsAPM.logger.warn {"[#{name}/#{__method__}] Set transaction name failed: custom_name is either nil or empty string."}
48
+ SolarWindsAPM.logger.warn do
49
+ "[#{name}/#{__method__}] Set transaction name failed: custom_name is either nil or empty string."
50
+ end
47
51
  status = false
48
- elsif SolarWindsAPM::OTelConfig.class_variable_get(:@@config)[:span_processor].nil?
49
- SolarWindsAPM.logger.warn {"[#{name}/#{__method__}] Set transaction name failed: Solarwinds processor is missing."}
52
+ elsif SolarWindsAPM::OTelConfig[:metrics_processor].nil?
53
+ SolarWindsAPM.logger.warn do
54
+ "[#{name}/#{__method__}] Set transaction name failed: Solarwinds processor is missing."
55
+ end
50
56
  status = false
51
57
  else
52
- solarwinds_processor = SolarWindsAPM::OTelConfig.class_variable_get(:@@config)[:span_processor]
53
- current_span = ::OpenTelemetry::Trace.current_span
58
+ solarwinds_processor = SolarWindsAPM::OTelConfig[:metrics_processor]
59
+ current_span = ::OpenTelemetry::Trace.current_span
54
60
 
55
61
  if current_span.context.valid?
56
62
  current_trace_id = current_span.context.hex_trace_id
57
63
  entry_span_id, trace_flags = solarwinds_processor.txn_manager.get_root_context_h(current_trace_id)&.split('-')
58
64
  if entry_span_id.to_s.empty? || trace_flags.to_s.empty?
59
- SolarWindsAPM.logger.warn {"[#{name}/#{__method__}] Set transaction name failed: record not found in the transaction manager."}
65
+ SolarWindsAPM.logger.warn do
66
+ "[#{name}/#{__method__}] Set transaction name failed: record not found in the transaction manager."
67
+ end
60
68
  status = false
61
69
  else
62
- solarwinds_processor.txn_manager.set("#{current_trace_id}-#{entry_span_id}",custom_name)
63
- SolarWindsAPM.logger.debug {"[#{name}/#{__method__}] Cached custom transaction name for #{current_trace_id}-#{entry_span_id} as #{custom_name}"}
70
+ solarwinds_processor.txn_manager.set("#{current_trace_id}-#{entry_span_id}", custom_name)
71
+ SolarWindsAPM.logger.debug do
72
+ "[#{name}/#{__method__}] Cached custom transaction name for #{current_trace_id}-#{entry_span_id} as #{custom_name}"
73
+ end
64
74
  end
65
75
  else
66
- SolarWindsAPM.logger.warn {"[#{name}/#{__method__}] Set transaction name failed: invalid span context."}
76
+ SolarWindsAPM.logger.warn { "[#{name}/#{__method__}] Set transaction name failed: invalid span context." }
67
77
  status = false
68
78
  end
69
79
  end
@@ -1,14 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # © 2023 SolarWinds Worldwide, LLC. All rights reserved.
2
4
  #
3
5
  # 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
6
  #
5
7
  # 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
8
 
7
- require_relative './api/transaction_name'
8
- require_relative './api/current_trace_info'
9
- require_relative './api/tracing'
10
- require_relative './api/opentelemetry'
11
- require_relative './api/custom_metrics'
9
+ require_relative 'api/transaction_name'
10
+ require_relative 'api/current_trace_info'
11
+ require_relative 'api/tracing'
12
+ require_relative 'api/opentelemetry'
13
+ require_relative 'api/custom_metrics'
12
14
 
13
15
  module SolarWindsAPM
14
16
  module API
@@ -18,4 +20,4 @@ module SolarWindsAPM
18
20
  extend SolarWindsAPM::API::OpenTelemetry
19
21
  extend SolarWindsAPM::API::CustomMetrics
20
22
  end
21
- end
23
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # © 2023 SolarWinds Worldwide, LLC. All rights reserved.
2
4
  #
3
5
  # 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
@@ -12,24 +14,24 @@ module SolarWindsAPM
12
14
  # Use SolarWindsAPM::Config.show to view the entire nested hash.
13
15
  #
14
16
  module Config
15
- LOGGER_LEVEL_MAPPING = {-1 => ::Logger::FATAL,
16
- 0 => ::Logger::FATAL,
17
- 1 => ::Logger::ERROR,
18
- 2 => ::Logger::WARN,
19
- 3 => ::Logger::INFO,
20
- 4 => ::Logger::DEBUG,
21
- 5 => ::Logger::DEBUG,
22
- 6 => ::Logger::DEBUG}.freeze
17
+ SW_LOG_LEVEL_MAPPING = { -1 => { stdlib: ::Logger::FATAL, otel: 'fatal' },
18
+ 0 => { stdlib: ::Logger::FATAL, otel: 'fatal' },
19
+ 1 => { stdlib: ::Logger::ERROR, otel: 'error' },
20
+ 2 => { stdlib: ::Logger::WARN, otel: 'warn' },
21
+ 3 => { stdlib: ::Logger::INFO, otel: 'info' },
22
+ 4 => { stdlib: ::Logger::DEBUG, otel: 'debug' },
23
+ 5 => { stdlib: ::Logger::DEBUG, otel: 'debug' },
24
+ 6 => { stdlib: ::Logger::DEBUG, otel: 'debug' } }.freeze
23
25
 
24
26
  @@config = {}
25
- @@instrumentation = [:action_controller, :action_controller_api, :action_view,
26
- :active_record, :bunnyclient, :bunnyconsumer, :curb,
27
- :dalli, :delayed_jobclient, :delayed_jobworker,
28
- :excon, :faraday, :graphql, :grpc_client, :grpc_server, :grape,
29
- :httpclient, :nethttp, :memcached, :mongo, :moped, :padrino, :rack, :redis,
30
- :resqueclient, :resqueworker, :rest_client,
31
- :sequel, :sidekiqclient, :sidekiqworker, :sinatra, :typhoeus,
32
- :curb, :excon, :faraday, :httpclient, :nethttp, :rest_client, :typhoeus]
27
+ @@instrumentation = %i[action_controller action_controller_api action_view
28
+ active_record bunnyclient bunnyconsumer curb
29
+ dalli delayed_jobclient delayed_jobworker
30
+ excon faraday graphql grpc_client grpc_server grape
31
+ httpclient nethttp memcached mongo moped padrino rack redis
32
+ resqueclient resqueworker rest_client
33
+ sequel sidekiqclient sidekiqworker sinatra typhoeus
34
+ curb excon faraday httpclient nethttp rest_client typhoeus]
33
35
 
34
36
  ##
35
37
  # load_config_file
@@ -53,26 +55,32 @@ module SolarWindsAPM
53
55
  config_files << config_file if File.exist?(config_file)
54
56
 
55
57
  # Check for file set by env variable
56
- config_files << config_file_from_env if ENV.has_key?('SW_APM_CONFIG_RUBY')
58
+ config_files << config_file_from_env if ENV.key?('SW_APM_CONFIG_RUBY')
57
59
 
58
60
  # Check for default config file
59
61
  config_file = File.join(Dir.pwd, 'solarwinds_apm_config.rb')
60
62
  config_files << config_file if File.exist?(config_file)
61
63
 
62
- SolarWindsAPM.logger.debug {"[#{name}/#{__method__}] Available config_files: #{config_files.join(', ')}" }
63
- SolarWindsAPM.logger.warn {"[#{name}/#{__method__}] Multiple configuration files configured, using the first one listed: #{config_files.join(', ')}"} if config_files.size > 1
64
- load(config_files[0]) if config_files.size > 0
64
+ SolarWindsAPM.logger.debug { "[#{name}/#{__method__}] Available config_files: #{config_files.join(', ')}" }
65
+ if config_files.size > 1
66
+ SolarWindsAPM.logger.warn do
67
+ "[#{name}/#{__method__}] Multiple configuration files configured, using the first one listed: #{config_files.join(', ')}"
68
+ end
69
+ end
70
+ load(config_files[0]) if config_files.size.positive?
65
71
 
66
- set_log_level # sets SolarWindsAPM::Config[:debug_level], SolarWindsAPM.logger.level
72
+ set_log_level # sets SolarWindsAPM::Config[:debug_level], SolarWindsAPM.logger.level
67
73
  end
68
74
 
69
75
  def self.config_file_from_env
70
- if File.exist?(ENV['SW_APM_CONFIG_RUBY']) && !File.directory?(ENV['SW_APM_CONFIG_RUBY'])
71
- config_file = ENV['SW_APM_CONFIG_RUBY']
72
- elsif File.exist?(File.join(ENV['SW_APM_CONFIG_RUBY'], 'solarwinds_apm_config.rb'))
73
- config_file = File.join(ENV['SW_APM_CONFIG_RUBY'], 'solarwinds_apm_config.rb')
76
+ if File.exist?(ENV.fetch('SW_APM_CONFIG_RUBY', nil)) && !File.directory?(ENV.fetch('SW_APM_CONFIG_RUBY', nil))
77
+ config_file = ENV.fetch('SW_APM_CONFIG_RUBY', nil)
78
+ elsif File.exist?(File.join(ENV.fetch('SW_APM_CONFIG_RUBY', nil), 'solarwinds_apm_config.rb'))
79
+ config_file = File.join(ENV.fetch('SW_APM_CONFIG_RUBY', nil), 'solarwinds_apm_config.rb')
74
80
  else
75
- SolarWindsAPM.logger.warn {"[#{name}/#{__method__}] Could not find the configuration file set by the SW_APM_CONFIG_RUBY environment variable: #{ENV['SW_APM_CONFIG_RUBY']}"}
81
+ SolarWindsAPM.logger.warn do
82
+ "[#{name}/#{__method__}] Could not find the configuration file set by the SW_APM_CONFIG_RUBY environment variable: #{ENV.fetch('SW_APM_CONFIG_RUBY', nil)}"
83
+ end
76
84
  end
77
85
  config_file
78
86
  end
@@ -82,7 +90,7 @@ module SolarWindsAPM
82
90
 
83
91
  SolarWindsAPM.logger = ::Logger.new(nil) if log_level == -1
84
92
 
85
- SolarWindsAPM.logger.level = LOGGER_LEVEL_MAPPING[log_level] || ::Logger::INFO # default log level info
93
+ SolarWindsAPM.logger.level = SW_LOG_LEVEL_MAPPING.dig(log_level, :stdlib) || ::Logger::INFO # default log level info
86
94
  end
87
95
 
88
96
  def self.enable_disable_config(env_var, key, value, default, bool: false)
@@ -92,7 +100,7 @@ module SolarWindsAPM
92
100
  if env_var && valid_env_values.include?(env_value)
93
101
  value = bool ? true?(env_value) : env_value.to_sym
94
102
  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}.")
103
+ SolarWindsAPM.logger.warn("[#{name}/#{__method__}] #{env_var} must be #{valid_env_values.join('/')} (current setting is #{ENV.fetch(env_var, nil)}). Using default value: #{default}.")
96
104
  return @@config[key.to_sym] = default
97
105
  end
98
106
 
@@ -103,7 +111,7 @@ module SolarWindsAPM
103
111
  end
104
112
 
105
113
  def self.true?(obj)
106
- obj.to_s.casecmp("true").zero?
114
+ obj.to_s.casecmp('true').zero?
107
115
  end
108
116
 
109
117
  def self.boolean?(obj)
@@ -111,7 +119,7 @@ module SolarWindsAPM
111
119
  end
112
120
 
113
121
  def self.symbol?(obj)
114
- [:enabled, :disabled].include?(obj)
122
+ %i[enabled disabled].include?(obj)
115
123
  end
116
124
 
117
125
  ##
@@ -121,10 +129,15 @@ module SolarWindsAPM
121
129
  # to create an output similar to the content of the config file
122
130
  #
123
131
  def self.print_config
124
- SolarWindsAPM.logger.warn {"[#{name}/#{__method__}] General configurations list blow:"}
125
- @@config.each do |k,v|
126
- SolarWindsAPM.logger.warn {"[#{name}/#{__method__}] Config Key/Value: #{k}, #{v.inspect}"}
132
+ SolarWindsAPM.logger.debug { "[#{name}/#{__method__}] General configurations list blow:" }
133
+ @@config.each do |k, v|
134
+ next if @@instrumentation.include?(k)
135
+
136
+ SolarWindsAPM.logger.debug do
137
+ "[#{name}/#{__method__}] Config Key/Value: #{k}, #{v.inspect}"
138
+ end
127
139
  end
140
+ nil
128
141
  end
129
142
 
130
143
  ##
@@ -136,12 +149,18 @@ module SolarWindsAPM
136
149
  #
137
150
  def self.initialize
138
151
  # for config file backward compatibility
139
- @@instrumentation.each {|inst| @@config[inst] = {}}
152
+ @@instrumentation.each { |inst| @@config[inst] = {} }
140
153
  @@config[:transaction_name] = {}
141
154
 
142
155
  # Always load the template, it has all the keys and defaults defined,
143
156
  # no guarantee of completeness in the user's config file
144
- load(File.join(File.dirname(File.dirname(__FILE__)), 'rails/generators/solarwinds_apm/templates/solarwinds_apm_initializer.rb'))
157
+
158
+ load(File.join(File.dirname(File.dirname(__FILE__)),
159
+ 'rails/generators/solarwinds_apm/templates/solarwinds_apm_initializer.rb'))
160
+
161
+ load_config_file
162
+
163
+ print_config if SolarWindsAPM.logger.level.zero?
145
164
  end
146
165
 
147
166
  def self.update!(data)
@@ -163,7 +182,7 @@ module SolarWindsAPM
163
182
  #
164
183
  # Config variable assignment method. Here we validate and store the
165
184
  # assigned value(s) and trigger any secondary action needed.
166
- # ENV always have higher precedence
185
+ # ENV always have higher precedence
167
186
  #
168
187
  def self.[]=(key, value)
169
188
  key = key.to_sym
@@ -171,18 +190,24 @@ module SolarWindsAPM
171
190
 
172
191
  case key
173
192
  when :sampling_rate
174
- SolarWindsAPM.logger.warn {"[#{name}/#{__method__}] sampling_rate is not a supported setting for SolarWindsAPM::Config. Please use :sample_rate."}
193
+ SolarWindsAPM.logger.warn do
194
+ "[#{name}/#{__method__}] sampling_rate is not a supported setting for SolarWindsAPM::Config. Please use :sample_rate."
195
+ end
175
196
 
176
197
  when :sample_rate
177
198
  unless value.is_a?(Integer) || value.is_a?(Float)
178
- SolarWindsAPM.logger.warn {"[#{name}/#{__method__}] :sample_rate must be a number between 0 and 1000000 (1m) (provided: #{value}), corrected to 0"}
199
+ SolarWindsAPM.logger.warn do
200
+ "[#{name}/#{__method__}] :sample_rate must be a number between 0 and 1000000 (1m) (provided: #{value}), corrected to 0"
201
+ end
179
202
  value = 0
180
203
  end
181
204
 
182
205
  # Validate :sample_rate value
183
206
  unless value.between?(0, 1e6)
184
- new_value = value < 0 ? 0 : 1_000_000
185
- SolarWindsAPM.logger.warn {"[#{name}/#{__method__}] :sample_rate must be between 0 and 1000000 (1m) (provided: #{value}), corrected to #{new_value}"}
207
+ new_value = value.negative? ? 0 : 1_000_000
208
+ SolarWindsAPM.logger.warn do
209
+ "[#{name}/#{__method__}] :sample_rate must be between 0 and 1000000 (1m) (provided: #{value}), corrected to #{new_value}"
210
+ end
186
211
  end
187
212
 
188
213
  # Assure value is an integer
@@ -216,7 +241,7 @@ module SolarWindsAPM
216
241
  end
217
242
 
218
243
  # `tracing: disabled` is the default
219
- disabled = settings.select { |v| !v.has_key?(:tracing) || v[:tracing] == :disabled }
244
+ disabled = settings.select { |v| !v.key?(:tracing) || v[:tracing] == :disabled }
220
245
  enabled = settings.select { |v| v[:tracing] == :enabled }
221
246
 
222
247
  SolarWindsAPM::Config[:enabled_regexps] = compile_regexp(enabled)
@@ -233,18 +258,18 @@ module SolarWindsAPM
233
258
 
234
259
  def self.compile_settings_regexp(value)
235
260
  regexps = value.select do |v|
236
- v.has_key?(:regexp) &&
261
+ v.key?(:regexp) &&
237
262
  !(v[:regexp].is_a?(String) && v[:regexp].empty?) &&
238
263
  !(v[:regexp].is_a?(Regexp) && v[:regexp].inspect == '//')
239
264
  end
240
265
 
241
266
  regexps.map! do |v|
242
- begin
243
- v[:regexp].is_a?(String) ? Regexp.new(v[:regexp], v[:opts]) : Regexp.new(v[:regexp])
244
- rescue StandardError => e
245
- SolarWindsAPM.logger.warn {"[#{name}/#{__method__}] Problem compiling transaction_settings item #{v}, will ignore. Error: #{e.message}"}
246
- nil
267
+ v[:regexp].is_a?(String) ? Regexp.new(v[:regexp], v[:opts]) : Regexp.new(v[:regexp])
268
+ rescue StandardError => e
269
+ SolarWindsAPM.logger.warn do
270
+ "[#{name}/#{__method__}] Problem compiling transaction_settings item #{v}, will ignore. Error: #{e.message}"
247
271
  end
272
+ nil
248
273
  end
249
274
  regexps.keep_if { |v| !v.nil? }
250
275
  regexps.empty? ? nil : regexps
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # © 2023 SolarWinds Worldwide, LLC. All rights reserved.
2
4
  #
3
5
  # 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
@@ -7,30 +9,28 @@
7
9
  module SolarWindsAPM
8
10
  # Constants
9
11
  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
-
15
- INTL_SWO_AO_COLLECTOR = "collector.appoptics.com".freeze
16
- INTL_SWO_AO_STG_COLLECTOR = "collector-stg.appoptics.com".freeze
17
- INTL_SWO_COMMA = ",".freeze
18
- INTL_SWO_COMMA_W3C_SANITIZED = "....".freeze
19
- INTL_SWO_EQUALS = "=".freeze
20
- INTL_SWO_EQUALS_W3C_SANITIZED = "####".freeze
21
- INTL_SWO_TRACESTATE_KEY = "sw".freeze
22
- INTL_SWO_X_OPTIONS_KEY = "sw_xtraceoptions".freeze
23
- INTL_SWO_SIGNATURE_KEY = "sw_signature".freeze
24
- INTL_SWO_DEFAULT_TRACES_EXPORTER = "solarwinds_exporter".freeze
25
- INTL_SWO_TRACECONTEXT_PROPAGATOR = "tracecontext".freeze
26
- INTL_SWO_PROPAGATOR = "solarwinds_propagator".freeze
27
- INTL_SWO_DEFAULT_PROPAGATORS = [INTL_SWO_TRACECONTEXT_PROPAGATOR, "baggage",INTL_SWO_PROPAGATOR].freeze
28
- INTL_SWO_SUPPORT_EMAIL = "SWO-support@solarwinds.com".freeze
29
- INTL_SWO_OTEL_SCOPE_NAME = "otel.scope.name".freeze
30
- INTL_SWO_OTEL_SCOPE_VERSION = "otel.scope.version".freeze
31
- INTL_SWO_OTEL_STATUS = "otel.status".freeze
32
- INTL_SWO_OTEL_STATUS_DESCRIPTION = "otel.status_description".freeze
33
-
34
- INTERNAL_TRIGGERED_TRACE = "TriggeredTrace".freeze
12
+ HTTP_METHOD = 'http.method'
13
+ HTTP_ROUTE = 'http.route'
14
+ HTTP_STATUS_CODE = 'http.status_code'
15
+ HTTP_URL = 'http.url'
16
+ INTL_SWO_AO_COLLECTOR = 'collector.appoptics.com'
17
+ INTL_SWO_AO_STG_COLLECTOR = 'collector-stg.appoptics.com'
18
+ INTL_SWO_COMMA = ','
19
+ INTL_SWO_COMMA_W3C_SANITIZED = '....'
20
+ INTL_SWO_EQUALS = '='
21
+ INTL_SWO_EQUALS_W3C_SANITIZED = '####'
22
+ INTL_SWO_TRACESTATE_KEY = 'sw'
23
+ INTL_SWO_X_OPTIONS_KEY = 'sw_xtraceoptions'
24
+ INTL_SWO_SIGNATURE_KEY = 'sw_signature'
25
+ INTL_SWO_DEFAULT_TRACES_EXPORTER = 'solarwinds_exporter'
26
+ INTL_SWO_TRACECONTEXT_PROPAGATOR = 'tracecontext'
27
+ INTL_SWO_PROPAGATOR = 'solarwinds_propagator'
28
+ INTL_SWO_DEFAULT_PROPAGATORS = [INTL_SWO_TRACECONTEXT_PROPAGATOR, 'baggage', INTL_SWO_PROPAGATOR].freeze
29
+ INTL_SWO_SUPPORT_EMAIL = 'SWO-support@solarwinds.com'
30
+ INTL_SWO_OTEL_SCOPE_NAME = 'otel.scope.name'
31
+ INTL_SWO_OTEL_SCOPE_VERSION = 'otel.scope.version'
32
+ INTL_SWO_OTEL_STATUS = 'otel.status'
33
+ INTL_SWO_OTEL_STATUS_DESCRIPTION = 'otel.status_description'
34
+ INTERNAL_TRIGGERED_TRACE = 'TriggeredTrace'
35
35
  end
36
- end
36
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # © 2023 SolarWinds Worldwide, LLC. All rights reserved.
2
4
  #
3
5
  # 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
@@ -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,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ # © 2023 SolarWinds Worldwide, LLC. All rights reserved.
4
+ #
5
+ # 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
6
+ #
7
+ # 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.
8
+
9
+ ####
10
+ # noop version of SolarWindsAPM::API
11
+ #
12
+ module SolarWindsAPM
13
+ # API
14
+ module API
15
+ end
16
+ end
17
+
18
+ module NoopAPI
19
+ # Tracing
20
+ module Tracing
21
+ # (wait_milliseconds=3000, integer_response: false)
22
+ def solarwinds_ready?(*_args, **options)
23
+ options && options[:integer_response] ? 0 : false
24
+ end
25
+ end
26
+
27
+ # CurrentTraceInfo
28
+ module CurrentTraceInfo
29
+ def current_trace_info
30
+ TraceInfo.new
31
+ end
32
+
33
+ class TraceInfo
34
+ attr_reader :tracestring, :trace_id, :span_id, :trace_flags, :do_log
35
+
36
+ def initialize
37
+ @trace_id = '00000000000000000000000000000000'
38
+ @span_id = '0000000000000000'
39
+ @trace_flags = '00'
40
+ @tracestring = '00-00000000000000000000000000000000-0000000000000000-00'
41
+ @service_name = ''
42
+ @do_log = :never
43
+ end
44
+
45
+ def for_log
46
+ ''
47
+ end
48
+
49
+ def hash_for_log
50
+ {}
51
+ end
52
+ end
53
+ end
54
+
55
+ # CustomMetrics
56
+ module CustomMetrics
57
+ def increment_metric(*)
58
+ false
59
+ end
60
+
61
+ def summary_metric(*)
62
+ false
63
+ end
64
+ end
65
+
66
+ # OpenTelemetry
67
+ module OpenTelemetry
68
+ def in_span(*)
69
+ yield if block_given?
70
+ end
71
+ end
72
+
73
+ # TransactionName
74
+ module TransactionName
75
+ def set_transaction_name(*)
76
+ true
77
+ end
78
+ end
79
+ end
80
+
81
+ SolarWindsAPM::API.extend(NoopAPI::Tracing)
82
+ SolarWindsAPM::API.extend(NoopAPI::CurrentTraceInfo)
83
+ SolarWindsAPM::API.extend(NoopAPI::CustomMetrics)
84
+ SolarWindsAPM::API.extend(NoopAPI::OpenTelemetry)
85
+ SolarWindsAPM::API.extend(NoopAPI::TransactionName)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # © 2023 SolarWinds Worldwide, LLC. All rights reserved.
2
4
  #
3
5
  # 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
@@ -7,9 +9,12 @@
7
9
  ####
8
10
  # noop version of SolarWindsAPM::Context
9
11
  #
10
- module SolarWindsAPM
12
+ # module SolarWindsAPM
13
+ # end
14
+
15
+ module Oboe_metal # rubocop:disable Naming/ClassAndModuleCamelCase
11
16
  # Context for noop
12
- module Context
17
+ class Context
13
18
  ##
14
19
  # noop version of :toString
15
20
  # toString would return the current trace context as string
@@ -18,6 +23,14 @@ module SolarWindsAPM
18
23
  '99-00000000000000000000000000000000-0000000000000000-00'
19
24
  end
20
25
 
26
+ def self.isReady(*)
27
+ false
28
+ end
29
+
30
+ def self.getDecisions(*)
31
+ [-1, -1, -1, 0, 0.0, 0.0, -1, -1, '', '', 4]
32
+ end
33
+
21
34
  ##
22
35
  # noop version of :clear
23
36
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # © 2023 SolarWinds Worldwide, LLC. All rights reserved.
2
4
  #
3
5
  # 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
@@ -7,8 +9,7 @@
7
9
  ####
8
10
  # noop version of SolarWindsAPM::Metadata
9
11
  #
10
- #
11
- module SolarWindsAPM
12
+ module Oboe_metal # rubocop:disable Naming/ClassAndModuleCamelCase
12
13
  # Metadata
13
14
  class Metadata
14
15
  ##
@@ -20,6 +21,10 @@ module SolarWindsAPM
20
21
  Metadata.new
21
22
  end
22
23
 
24
+ def self.fromString(*)
25
+ Metadata.new
26
+ end
27
+
23
28
  def isValid
24
29
  false
25
30
  end
@@ -1,24 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # © 2023 SolarWinds Worldwide, LLC. All rights reserved.
2
4
  #
3
5
  # 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
6
  #
5
7
  # 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
8
 
7
- ##
8
- # This module is the base module for SolarWindsAPM reporting.
9
+ ####
10
+ # noop version of SolarWindsAPM::Span
9
11
  #
10
- module SolarWindsAPMBase
11
- extend SolarWindsAPM::ThreadLocal
12
-
13
- attr_accessor :reporter, :loaded
14
- end
12
+ module Oboe_metal # rubocop:disable Naming/ClassAndModuleCamelCase
13
+ # Span
14
+ class Span
15
+ ##
16
+ # noop version of :createHttpSpan
17
+ #
18
+ def self.createHttpSpan(*); end
15
19
 
16
- module SolarWindsAPM
17
- extend SolarWindsAPMBase
20
+ ##
21
+ # noop version of :createSpan
22
+ #
23
+ def self.createSpan(*); end
24
+ end
18
25
  end
19
-
20
- # Setup an alias
21
- SolarWindsApm = SolarWindsAPM
22
- SolarwindsApm = SolarWindsAPM
23
- SolarwindsAPM = SolarWindsAPM
24
- Solarwindsapm = SolarWindsAPM