solarwinds_apm 6.1.2 → 7.0.0.prev1

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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -2
  3. data/lib/solarwinds_apm/api/current_trace_info.rb +10 -6
  4. data/lib/solarwinds_apm/api/custom_metrics.rb +8 -25
  5. data/lib/solarwinds_apm/api/tracing.rb +12 -27
  6. data/lib/solarwinds_apm/api/transaction_name.rb +6 -10
  7. data/lib/solarwinds_apm/config.rb +1 -1
  8. data/lib/solarwinds_apm/constants.rb +1 -0
  9. data/lib/solarwinds_apm/noop/api.rb +5 -2
  10. data/lib/solarwinds_apm/noop.rb +0 -24
  11. data/lib/solarwinds_apm/opentelemetry/otlp_processor.rb +90 -69
  12. data/lib/solarwinds_apm/opentelemetry/solarwinds_propagator.rb +0 -2
  13. data/lib/solarwinds_apm/opentelemetry/solarwinds_response_propagator.rb +5 -4
  14. data/lib/solarwinds_apm/opentelemetry.rb +5 -7
  15. data/lib/solarwinds_apm/otel_native_config.rb +177 -0
  16. data/lib/solarwinds_apm/patch/README.md +15 -0
  17. data/lib/solarwinds_apm/{noop/metadata.rb → sampling/dice.rb} +19 -17
  18. data/lib/solarwinds_apm/sampling/http_sampler.rb +87 -0
  19. data/lib/solarwinds_apm/sampling/json_sampler.rb +52 -0
  20. data/lib/solarwinds_apm/sampling/metrics.rb +38 -0
  21. data/lib/solarwinds_apm/sampling/oboe_sampler.rb +348 -0
  22. data/lib/solarwinds_apm/sampling/sampler.rb +197 -0
  23. data/lib/solarwinds_apm/sampling/sampling_constants.rb +127 -0
  24. data/lib/solarwinds_apm/sampling/sampling_patch.rb +49 -0
  25. data/lib/solarwinds_apm/sampling/setting_example.txt +1 -0
  26. data/lib/solarwinds_apm/{noop/context.rb → sampling/settings.rb} +14 -25
  27. data/lib/solarwinds_apm/sampling/token_bucket.rb +126 -0
  28. data/lib/solarwinds_apm/sampling/trace_options.rb +100 -0
  29. data/lib/solarwinds_apm/{patch.rb → sampling.rb} +20 -4
  30. data/lib/solarwinds_apm/{noop/span.rb → support/aws_resource_detector.rb} +5 -18
  31. data/lib/solarwinds_apm/support/logger_formatter.rb +1 -1
  32. data/lib/solarwinds_apm/support/logging_log_event.rb +1 -1
  33. data/lib/solarwinds_apm/support/lumberjack_formatter.rb +1 -1
  34. data/lib/solarwinds_apm/support/otlp_endpoint.rb +99 -0
  35. data/lib/solarwinds_apm/support/resource_detector/aws/beanstalk.rb +51 -0
  36. data/lib/solarwinds_apm/support/resource_detector/aws/ec2.rb +145 -0
  37. data/lib/solarwinds_apm/support/resource_detector/aws/ecs.rb +173 -0
  38. data/lib/solarwinds_apm/support/resource_detector/aws/eks.rb +174 -0
  39. data/lib/solarwinds_apm/support/resource_detector/aws/lambda.rb +66 -0
  40. data/lib/solarwinds_apm/support/resource_detector.rb +192 -0
  41. data/lib/solarwinds_apm/support/service_key_checker.rb +12 -6
  42. data/lib/solarwinds_apm/support/transaction_settings.rb +6 -0
  43. data/lib/solarwinds_apm/support/txn_name_manager.rb +54 -9
  44. data/lib/solarwinds_apm/support/utils.rb +9 -0
  45. data/lib/solarwinds_apm/support.rb +3 -4
  46. data/lib/solarwinds_apm/version.rb +4 -4
  47. data/lib/solarwinds_apm.rb +27 -73
  48. metadata +99 -40
  49. data/ext/oboe_metal/extconf.rb +0 -168
  50. data/ext/oboe_metal/lib/liboboe-1.0-aarch64.so.sha256 +0 -1
  51. data/ext/oboe_metal/lib/liboboe-1.0-alpine-aarch64.so.sha256 +0 -1
  52. data/ext/oboe_metal/lib/liboboe-1.0-alpine-x86_64.so.sha256 +0 -1
  53. data/ext/oboe_metal/lib/liboboe-1.0-lambda-aarch64.so.sha256 +0 -1
  54. data/ext/oboe_metal/lib/liboboe-1.0-lambda-x86_64.so.sha256 +0 -1
  55. data/ext/oboe_metal/lib/liboboe-1.0-x86_64.so.sha256 +0 -1
  56. data/ext/oboe_metal/src/VERSION +0 -1
  57. data/ext/oboe_metal/src/bson/bson.h +0 -220
  58. data/ext/oboe_metal/src/bson/platform_hacks.h +0 -91
  59. data/ext/oboe_metal/src/init_solarwinds_apm.cc +0 -18
  60. data/ext/oboe_metal/src/oboe.h +0 -930
  61. data/ext/oboe_metal/src/oboe_api.cpp +0 -793
  62. data/ext/oboe_metal/src/oboe_api.h +0 -621
  63. data/ext/oboe_metal/src/oboe_debug.h +0 -17
  64. data/ext/oboe_metal/src/oboe_swig_wrap.cc +0 -11045
  65. data/lib/oboe_metal.rb +0 -187
  66. data/lib/solarwinds_apm/cert/star.appoptics.com.issuer.crt +0 -24
  67. data/lib/solarwinds_apm/oboe_init_options.rb +0 -222
  68. data/lib/solarwinds_apm/opentelemetry/solarwinds_exporter.rb +0 -239
  69. data/lib/solarwinds_apm/opentelemetry/solarwinds_processor.rb +0 -174
  70. data/lib/solarwinds_apm/opentelemetry/solarwinds_sampler.rb +0 -333
  71. data/lib/solarwinds_apm/otel_config.rb +0 -174
  72. data/lib/solarwinds_apm/otel_lambda_config.rb +0 -56
  73. data/lib/solarwinds_apm/patch/dummy_patch.rb +0 -12
  74. data/lib/solarwinds_apm/support/oboe_tracing_mode.rb +0 -33
  75. data/lib/solarwinds_apm/support/support_report.rb +0 -99
  76. data/lib/solarwinds_apm/support/transaction_cache.rb +0 -57
  77. data/lib/solarwinds_apm/support/x_trace_options.rb +0 -138
@@ -0,0 +1,192 @@
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
+ require 'net/http'
10
+ require 'uri'
11
+ require 'json'
12
+ require 'socket'
13
+ require 'securerandom'
14
+ require 'opentelemetry/resource/detector/azure'
15
+ require 'opentelemetry/resource/detector/container'
16
+ require_relative 'resource_detector/aws/ec2'
17
+
18
+ module SolarWindsAPM
19
+ # ResourceDetector
20
+ # Usage:
21
+ # require 'opentelemetry/sdk'
22
+ # require 'opentelemetry/resource/detector'
23
+ # OpenTelemetry::SDK.configure do |c|
24
+ # c.resource = SolarWindsAPM::ResourceDetector.detect
25
+ # end
26
+ module ResourceDetector
27
+ K8S_PODNAME_PATH = '/etc/hostname'
28
+ K8S_NAMESPACE_PATH = '/var/run/secrets/kubernetes.io/serviceaccount/namespace'
29
+ K8S_NAMESPACE_PATH_WIN = 'C:\\var\\run\\secrets\\kubernetes.io\\serviceaccount\\namespace'
30
+ K8S_MOUNTINFO_FILE = '/proc/self/mountinfo'
31
+ UID_REGEX = /[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}/i
32
+
33
+ SW_K8S_NAMESPACE_ENV = 'SW_K8S_POD_NAMESPACE'
34
+ SW_K8S_UID_ENV = 'SW_K8S_POD_UID'
35
+ SW_K8S_NAME_ENV = 'SW_K8S_POD_NAME'
36
+
37
+ UAMS_CLIENT_PATH = '/opt/solarwinds/uamsclient/var/uamsclientid'
38
+ UAMS_CLIENT_PATH_WIN = 'C:\\ProgramData\\SolarWinds\\UAMSClient\\uamsclientid'
39
+ UAMS_CLIENT_URL = 'http://127.0.0.1:2113/info/uamsclient'
40
+ UAMS_CLIENT_ID_FIELD = 'uamsclient_id'
41
+
42
+ def self.detect
43
+ uuid_attr = { ::OpenTelemetry::SemanticConventions::Resource::SERVICE_INSTANCE_ID => random_uuid }
44
+ attributes = ::OpenTelemetry::SDK::Resources::Resource.create(uuid_attr)
45
+ attributes = attributes.merge(detect_uams_client_id)
46
+ attributes = attributes.merge(detect_k8s_attributes)
47
+ attributes = attributes.merge(detect_ec2)
48
+ attributes = attributes.merge(detect_azure)
49
+ attributes.merge(detect_container)
50
+ end
51
+
52
+ def self.detect_uams_client_id
53
+ uams_client_final_path = windows? ? UAMS_CLIENT_PATH_WIN : UAMS_CLIENT_PATH
54
+ uams_client_id = nil
55
+ begin
56
+ uams_client_id = File.read(uams_client_final_path).strip
57
+ rescue StandardError => e
58
+ SolarWindsAPM.logger.debug "#{self.class}/#{__method__}] uams file retrieve error #{e.message}."
59
+ end
60
+
61
+ if uams_client_id.nil?
62
+ begin
63
+ url = URI(UAMS_CLIENT_URL)
64
+
65
+ response = nil
66
+ ::OpenTelemetry::Common::Utilities.untraced do
67
+ http = Net::HTTP.new(url.host, url.port)
68
+ request = Net::HTTP::Get.new(url)
69
+ response = http.request(request)
70
+ end
71
+
72
+ raise 'Response returned non-200 status code' unless response&.code.to_i == 200
73
+
74
+ uams_metadata = JSON.parse(response.body)
75
+ uams_client_id = uams_metadata&.fetch(UAMS_CLIENT_ID_FIELD)
76
+ rescue StandardError => e
77
+ SolarWindsAPM.logger.debug "#{self.class}/#{__method__}] uams api retrieve error #{e.message}."
78
+ end
79
+ end
80
+
81
+ resource_attributes = {
82
+ 'sw.uams.client.id' => uams_client_id,
83
+ 'host.id' => uams_client_id
84
+ }
85
+
86
+ SolarWindsAPM.logger.debug "#{self.class}/#{__method__}] retrieved resource_attributes: #{resource_attributes.inspect}."
87
+ ::OpenTelemetry::SDK::Resources::Resource.create(resource_attributes)
88
+ rescue StandardError => e
89
+ SolarWindsAPM.logger.debug "#{self.class}/#{__method__}] detect_uams_client_id failed. Error: #{e.message}."
90
+ ::OpenTelemetry::SDK::Resources::Resource.create({})
91
+ end
92
+
93
+ def self.detect_k8s_attributes
94
+ unless ENV['KUBERNETES_SERVICE_HOST'] && ENV['KUBERNETES_SERVICE_PORT']
95
+ SolarWindsAPM.logger.debug { "Can't read environment variable (KUBERNETES_SERVICE_HOST/KUBERNETES_SERVICE_PORT). It's likely not in kubernetes pod environment. No K8S resource detection." }
96
+ return ::OpenTelemetry::SDK::Resources::Resource.create({})
97
+ end
98
+
99
+ pod_name = ENV.fetch(SW_K8S_NAME_ENV, nil)
100
+ if pod_name.nil?
101
+ pod_name = Socket.gethostname
102
+ else
103
+ SolarWindsAPM.logger.debug { "read pod name from env #{pod_name}" }
104
+ end
105
+
106
+ pod_namespace = ENV.fetch(SW_K8S_NAMESPACE_ENV, nil)
107
+ if pod_namespace.nil?
108
+ begin
109
+ k8s_namspace_final_path = windows? ? K8S_NAMESPACE_PATH_WIN : K8S_NAMESPACE_PATH
110
+ pod_namespace = File.read(k8s_namspace_final_path).strip
111
+ SolarWindsAPM.logger.debug { 'read pod namespace from file' }
112
+ rescue StandardError => e
113
+ SolarWindsAPM.logger.debug { "can't read pod namespace #{e.message}" }
114
+ end
115
+ else
116
+ SolarWindsAPM.logger.debug { "read pod namespace from env #{pod_namespace}" }
117
+ end
118
+
119
+ pod_uid = ENV.fetch(SW_K8S_UID_ENV, nil)
120
+ if pod_uid.nil?
121
+ begin
122
+ File.open(K8S_MOUNTINFO_FILE) do |file|
123
+ file.each_line do |line|
124
+ fields = line.split
125
+ next if fields.size < 10
126
+
127
+ id, parent_id, _, root = fields
128
+ next unless safe_integer?(id) && safe_integer?(parent_id)
129
+ next unless root.include?('kube')
130
+
131
+ matches = UID_REGEX.match(root)
132
+ pod_uid = matches[0] if matches
133
+ break if pod_uid
134
+ end
135
+ end
136
+ rescue StandardError => e
137
+ SolarWindsAPM.logger.debug { "can't read pod uid #{e.message}" }
138
+ end
139
+ else
140
+ SolarWindsAPM.logger.debug { "read pod uid from env #{pod_uid}" }
141
+ end
142
+
143
+ resource_attributes = {
144
+ ::OpenTelemetry::SemanticConventions::Resource::K8S_NAMESPACE_NAME => pod_namespace,
145
+ ::OpenTelemetry::SemanticConventions::Resource::K8S_POD_NAME => pod_name,
146
+ ::OpenTelemetry::SemanticConventions::Resource::K8S_POD_UID => pod_uid
147
+ }
148
+
149
+ resource_attributes.compact!
150
+ SolarWindsAPM.logger.debug { "#{self.class}/#{__method__}] retrieved resource_attributes: #{resource_attributes.inspect}." }
151
+ ::OpenTelemetry::SDK::Resources::Resource.create(resource_attributes)
152
+ end
153
+
154
+ def self.detect_ec2
155
+ attribute = ::OpenTelemetry::Resource::Detector::AWS::EC2.detect
156
+ SolarWindsAPM.logger.debug { "#{self.class}/#{__method__}] retrieved resource_attributes: #{attribute.instance_variable_get(:@attributes)}" }
157
+ attribute
158
+ rescue StandardError
159
+ ::OpenTelemetry::SDK::Resources::Resource.create({})
160
+ end
161
+
162
+ def self.detect_azure
163
+ attribute = ::OpenTelemetry::Resource::Detector::Azure.detect
164
+ SolarWindsAPM.logger.debug { "#{self.class}/#{__method__}] retrieved resource_attributes: #{attribute.instance_variable_get(:@attributes)}" }
165
+ attribute
166
+ rescue StandardError
167
+ ::OpenTelemetry::SDK::Resources::Resource.create({})
168
+ end
169
+
170
+ def self.detect_container
171
+ attribute = ::OpenTelemetry::Resource::Detector::Container.detect
172
+ SolarWindsAPM.logger.debug { "#{self.class}/#{__method__}] retrieved resource_attributes: #{attribute.instance_variable_get(:@attributes)}" }
173
+ attribute
174
+ rescue StandardError
175
+ ::OpenTelemetry::SDK::Resources::Resource.create({})
176
+ end
177
+
178
+ def self.safe_integer?(number)
179
+ min_safe_integer = -((2**53) - 1)
180
+ max_safe_integer = (2**53) - 1
181
+ number.is_a?(Integer) && number >= min_safe_integer && number <= max_safe_integer
182
+ end
183
+
184
+ def self.windows?
185
+ %w[mingw32 cygwin].any? { |platform| RUBY_PLATFORM.include?(platform) }
186
+ end
187
+
188
+ def self.random_uuid
189
+ SecureRandom.uuid
190
+ end
191
+ end
192
+ end
@@ -10,19 +10,24 @@ module SolarWindsAPM
10
10
  # ServiceKeyChecker
11
11
  # It is a service that validate the service_key
12
12
  class ServiceKeyChecker
13
+ attr_reader :token, :service_name
14
+
13
15
  def initialize(reporter, is_lambda)
14
16
  @reporter = reporter
15
17
  @is_lambda = is_lambda
18
+ @token = nil
19
+ @service_name = nil
20
+ read_and_validate_service_key
16
21
  end
17
22
 
18
23
  def read_and_validate_service_key
19
- return '' unless @reporter == 'ssl'
20
- return '' if @is_lambda
24
+ return unless @reporter == 'ssl'
25
+ return if @is_lambda
21
26
 
22
27
  service_key = fetch_service_key
23
28
  if service_key.empty?
24
29
  SolarWindsAPM.logger.error { "[#{self.class}/#{__method__}] SW_APM_SERVICE_KEY not configured." }
25
- return ''
30
+ return
26
31
  end
27
32
 
28
33
  token, _, service_name = parse_service_key(service_key)
@@ -30,7 +35,7 @@ module SolarWindsAPM
30
35
  SolarWindsAPM.logger.error do
31
36
  "[#{self.class}/#{__method__}] SW_APM_SERVICE_KEY problem. API Token in wrong format. Masked token: #{token[0..3]}...#{token[-4..]}"
32
37
  end
33
- return ''
38
+ return
34
39
  end
35
40
 
36
41
  # if no service_name from service_key, then the SW_APM_SERVICE_KEY is not right format, return
@@ -39,7 +44,7 @@ module SolarWindsAPM
39
44
  SolarWindsAPM.logger.warn do
40
45
  "[#{self.class}/#{__method__}] SW_APM_SERVICE_KEY format problem. Service Name is missing."
41
46
  end
42
- return ''
47
+ return
43
48
  end
44
49
 
45
50
  service_name = transform_service_name(service_name)
@@ -55,7 +60,8 @@ module SolarWindsAPM
55
60
  service_name = transform_service_name(otel_service_name)
56
61
  end
57
62
 
58
- "#{token}:#{service_name}"
63
+ @token = token
64
+ @service_name = service_name
59
65
  end
60
66
 
61
67
  private
@@ -28,6 +28,12 @@ module SolarWindsAPM
28
28
 
29
29
  private
30
30
 
31
+ # def resolve_config
32
+ # config = SolarWindsAPM::Config if defined?(SolarWindsAPM::Config)
33
+ # config = SolarWindsAPM::OTelNativeConfig if defined?(SolarWindsAPM::OTelNativeConfig)
34
+ # config
35
+ # end
36
+
31
37
  def tracing_enabled?
32
38
  span_layer = "#{@kind}:#{@name}"
33
39
 
@@ -7,32 +7,69 @@
7
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
8
 
9
9
  module SolarWindsAPM
10
- # SolarWindsTxnNameManager
11
10
  # Transaction Name Manager is sole for enabling solarwinds api to call set_transaction_name
11
+ # 200 unique transaction naming per 60 seconds for the transaction naming
12
12
  class TxnNameManager
13
+ MAX_CARDINALITY = 200
14
+ DEFAULT_TXN_NAME = 'other'
15
+ TXN_NAME_POOL_TTL = 60 # 60s
16
+
17
+ # @root_context_h is used for trace api set_transaction_name;
18
+ # it retrieve the span_id based on root trace_id
19
+ # set_root_context_h(trace_id, span_flags)
20
+ # @cache store the transaction name that will be used for exporter
21
+ # to set transaction name for attributes, get by trace_span_id
22
+ # set(trace_span_id, transaction_name)
23
+ # @transaction_name store the transaction name and its expire call
24
+ # set(transaction_name, thread {@cache.del()})
13
25
  def initialize
14
- @cache = {}
15
- @root_context_h = {}
26
+ @cache = {} # for mapping trace_span_id to transaction name
27
+ @transaction_name = {} # only make sure the cardinality requirement that 200 unique txn within 60s
28
+ # use for setting DEFAULT_TXN_NAME (in @cache) when cardinality reach the maximal
29
+ @root_context_h = {} # for set_transaction_name api call
16
30
  @mutex = Mutex.new
31
+ @root_context_mutex = Mutex.new
17
32
  end
18
33
 
19
34
  def get(key)
20
- @cache[key]
35
+ @mutex.synchronize { @cache[key] }
21
36
  end
22
37
 
23
38
  def del(key)
24
- @cache.delete(key)
39
+ @mutex.synchronize { @cache.delete(key) }
25
40
  end
26
41
 
27
42
  def set(key, value)
28
- @cache[key] = value
43
+ # new name and room in pool -> add name to pool and schedule for removal after ttl -> return name
44
+ # new name but no room in pool -> return default name
45
+ # existing name -> cancel previously scheduled removal -> schedule new removal -> return name
46
+ txn_name = value.slice(0, SolarWindsAPM::Constants::MAX_TXN_NAME_LENGTH)
47
+ txn_name_exist = false
48
+
49
+ # thread exit execute ensure block, better option than kill for sleep
50
+ @mutex.synchronize do
51
+ if @transaction_name[txn_name]
52
+ txn_name_exist = true
53
+ @transaction_name[txn_name].exit
54
+ end
55
+ end
56
+
57
+ @mutex.synchronize do
58
+ if txn_name_exist || @transaction_name.size < MAX_CARDINALITY
59
+ @cache[key] = txn_name
60
+ @transaction_name[txn_name] = Thread.new { cleanup_txn(key, txn_name) }
61
+ else
62
+ @cache[key] = DEFAULT_TXN_NAME
63
+ end
64
+ end
65
+
29
66
  SolarWindsAPM.logger.debug { "[#{self.class}/#{__method__}] txn manager current cache #{@cache.inspect}" }
30
67
  end
31
68
 
32
69
  alias []= set
33
70
 
34
71
  def set_root_context_h(key, value)
35
- @mutex.synchronize do
72
+ @root_context_mutex.synchronize do
36
73
  @root_context_h[key] = value
37
74
  end
38
75
  SolarWindsAPM.logger.debug do
@@ -41,13 +78,21 @@ module SolarWindsAPM
41
78
  end
42
79
 
43
80
  def get_root_context_h(key)
44
- @root_context_h[key]
81
+ @root_context_mutex.synchronize { @root_context_h[key] }
45
82
  end
46
83
 
47
84
  def delete_root_context_h(key)
48
- @mutex.synchronize do
85
+ @root_context_mutex.synchronize do
49
86
  @root_context_h.delete(key)
50
87
  end
51
88
  end
89
+
90
+ def cleanup_txn(_key, txn_name)
91
+ sleep(TXN_NAME_POOL_TTL)
92
+ ensure
93
+ @mutex.synchronize do
94
+ @transaction_name.delete(txn_name)
95
+ end
96
+ end
52
97
  end
53
98
  end
@@ -29,5 +29,14 @@ module SolarWindsAPM
29
29
  end
30
30
  xtr
31
31
  end
32
+
33
+ def self.determine_lambda
34
+ if ENV['LAMBDA_TASK_ROOT'].to_s.empty? && ENV['AWS_LAMBDA_FUNCTION_NAME'].to_s.empty?
35
+ false
36
+ else
37
+ SolarWindsAPM.logger.debug { "[#{self.class}/#{__method__}] lambda environment - LAMBDA_TASK_ROOT: #{ENV.fetch('LAMBDA_TASK_ROOT', nil)}; AWS_LAMBDA_FUNCTION_NAME: #{ENV.fetch('AWS_LAMBDA_FUNCTION_NAME', nil)}" }
38
+ true
39
+ end
40
+ end
32
41
  end
33
42
  end
@@ -11,10 +11,9 @@
11
11
  require_relative 'support/logger_formatter'
12
12
  require_relative 'support/logging_log_event'
13
13
  require_relative 'support/lumberjack_formatter'
14
- require_relative 'support/transaction_cache'
15
14
  require_relative 'support/transaction_settings'
16
- require_relative 'support/oboe_tracing_mode'
17
15
  require_relative 'support/txn_name_manager'
18
16
  require_relative 'support/utils'
19
- require_relative 'support/x_trace_options'
20
- require_relative 'support/support_report'
17
+ require_relative 'support/otlp_endpoint'
18
+ require_relative 'support/resource_detector'
19
+ require_relative 'support/aws_resource_detector'
@@ -11,10 +11,10 @@ module SolarWindsAPM
11
11
  # The current version of the gem. Used mainly by
12
12
  # solarwinds_apm.gemspec during gem build process
13
13
  module Version
14
- MAJOR = 6 # breaking,
15
- MINOR = 1 # feature,
16
- PATCH = 2 # fix => BFF
17
- PRE = nil
14
+ MAJOR = 7 # breaking,
15
+ MINOR = 0 # feature,
16
+ PATCH = 0 # fix => BFF
17
+ PRE = 'prev1'
18
18
 
19
19
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
20
20
  end
@@ -9,94 +9,48 @@
9
9
  begin
10
10
  require 'solarwinds_apm/logger'
11
11
  require 'solarwinds_apm/version'
12
- require 'solarwinds_apm/noop'
12
+ require 'solarwinds_apm/constants'
13
13
  require 'opentelemetry-api'
14
14
  if ENV.fetch('SW_APM_ENABLED', 'true') == 'false'
15
15
  SolarWindsAPM.logger.info '==================================================================='
16
16
  SolarWindsAPM.logger.info 'SW_APM_ENABLED environment variable detected and was set to false. SolarWindsAPM disabled'
17
17
  SolarWindsAPM.logger.info '==================================================================='
18
+ require 'solarwinds_apm/noop'
18
19
  return
19
20
  end
20
21
 
21
22
  begin
22
- if RUBY_PLATFORM.include?('linux')
23
- require 'solarwinds_apm/config'
24
- require 'solarwinds_apm/oboe_init_options' # setup oboe reporter options
25
- if !SolarWindsAPM::OboeInitOptions.instance.service_key_ok? && !SolarWindsAPM::OboeInitOptions.instance.lambda_env
26
- SolarWindsAPM.logger.warn '=============================================================='
27
- SolarWindsAPM.logger.warn 'SW_APM_SERVICE_KEY Error. SolarWinds APM disabled'
28
- SolarWindsAPM.logger.warn 'Please check previous log messages for more details.'
29
- SolarWindsAPM.logger.warn '=============================================================='
30
- return
31
- end
32
-
33
- require_relative 'libsolarwinds_apm.so' # load c-lib oboe
34
- require_relative 'oboe_metal' # initialize reporter: SolarWindsAPM.loaded = true
35
-
36
- require 'opentelemetry/sdk/version' # load otel sdk version
37
- require 'opentelemetry/instrumentation/all/version' # load otel instrumentation
38
-
39
- SolarWindsAPM.logger.info '==================================================================='
40
- SolarWindsAPM.logger.info "Ruby #{RUBY_VERSION} on platform #{RUBY_PLATFORM}."
41
- SolarWindsAPM.logger.info "Current solarwinds_apm version: #{SolarWindsAPM::Version::STRING}."
42
- SolarWindsAPM.logger.info "OpenTelemetry version: #{OpenTelemetry::SDK::VERSION}."
43
- SolarWindsAPM.logger.info "OpenTelemetry instrumentation version: #{OpenTelemetry::Instrumentation::All::VERSION}."
44
- SolarWindsAPM.logger.info '==================================================================='
23
+ require 'solarwinds_apm/config'
24
+ require 'solarwinds_apm/otel_native_config'
45
25
 
46
- if SolarWindsAPM::OboeInitOptions.instance.lambda_env
26
+ if ENV['SW_APM_AUTO_CONFIGURE'] != 'false'
27
+ SolarWindsAPM::OTelNativeConfig.initialize
28
+ if SolarWindsAPM::OTelNativeConfig.agent_enabled
47
29
  SolarWindsAPM.logger.info '==================================================================='
48
- SolarWindsAPM.logger.info "Ruby #{RUBY_VERSION} on platform #{RUBY_PLATFORM} is running in lambda environment."
30
+ SolarWindsAPM.logger.info "Ruby #{RUBY_VERSION} on platform #{RUBY_PLATFORM}."
31
+ SolarWindsAPM.logger.info "Current solarwinds_apm version: #{SolarWindsAPM::Version::STRING}."
32
+ SolarWindsAPM.logger.info "OpenTelemetry version: #{OpenTelemetry::SDK::VERSION}."
33
+ SolarWindsAPM.logger.info "OpenTelemetry instrumentation version: #{OpenTelemetry::Instrumentation::All::VERSION}."
49
34
  SolarWindsAPM.logger.info '==================================================================='
50
-
51
- SolarWindsAPM.oboe_api = SolarWindsAPM::OboeAPI.new # start oboe api for lambda env
52
- require 'solarwinds_apm/otel_lambda_config'
53
-
54
- SolarWindsAPM::OTelLambdaConfig.initialize # we don't allow in-code configuration under lambda env
55
35
  else
56
- SolarWindsAPM::Reporter.start # start the reporter, any issue will be logged
57
-
58
- if SolarWindsAPM.loaded
59
- require 'solarwinds_apm/constants'
60
- require 'solarwinds_apm/api'
61
- require 'solarwinds_apm/support'
62
- require 'solarwinds_apm/opentelemetry'
63
- require 'solarwinds_apm/patch'
64
- require 'solarwinds_apm/otel_config'
65
-
66
- if ENV['SW_APM_AUTO_CONFIGURE'] != 'false'
67
- SolarWindsAPM::OTelConfig.initialize
68
- elsif ENV['SW_APM_AUTO_CONFIGURE'] == 'false'
69
- SolarWindsAPM.logger.warn '=============================================================='
70
- SolarWindsAPM.logger.warn 'SW_APM_AUTO_CONFIGURE set to false.'
71
- SolarWindsAPM.logger.warn 'You need to initialize Ruby library in application with'
72
- SolarWindsAPM.logger.warn 'SolarWindsAPM::OTelConfig.initialize_with_config do |config|'
73
- SolarWindsAPM.logger.warn ' # ... your configuration code'
74
- SolarWindsAPM.logger.warn 'end'
75
- SolarWindsAPM.logger.warn 'See: https://github.com/solarwinds/apm-ruby/blob/main/CONFIGURATION.md#in-code-configuration'
76
- SolarWindsAPM.logger.warn "\e[1mPlease discard this message if application have already taken this action.\e[0m"
77
- SolarWindsAPM.logger.warn '=============================================================='
78
- end
79
- else
80
- SolarWindsAPM.logger.warn '=============================================================='
81
- SolarWindsAPM.logger.warn 'SolarWindsAPM not loaded. SolarWinds APM disabled'
82
- SolarWindsAPM.logger.warn 'Please check previous log messages.'
83
- SolarWindsAPM.logger.warn '=============================================================='
84
- end
36
+ SolarWindsAPM.logger.warn '=============================================================='
37
+ SolarWindsAPM.logger.warn 'SolarWindsAPM not loaded. SolarWinds APM disabled'
38
+ SolarWindsAPM.logger.warn 'Please check previous log messages.'
39
+ SolarWindsAPM.logger.warn '=============================================================='
40
+ require 'solarwinds_apm/noop'
85
41
  end
86
- else
87
- SolarWindsAPM.logger.warn '==================================================================='
88
- SolarWindsAPM.logger.warn "SolarWindsAPM warning: Platform #{RUBY_PLATFORM} not yet supported on current solarwinds_apm #{SolarWindsAPM::Version::STRING}"
89
- SolarWindsAPM.logger.warn 'see: https://documentation.solarwinds.com/en/success_center/observability/default.htm#cshid=config-ruby-agent'
90
- SolarWindsAPM.logger.warn 'SolarWinds APM disabled.'
91
- SolarWindsAPM.logger.warn 'Contact technicalsupport@solarwinds.com if this is unexpected.'
92
- SolarWindsAPM.logger.warn '==================================================================='
42
+ elsif ENV['SW_APM_AUTO_CONFIGURE'] == 'false'
43
+ SolarWindsAPM.logger.warn '=============================================================='
44
+ SolarWindsAPM.logger.warn 'SW_APM_AUTO_CONFIGURE set to false.'
45
+ SolarWindsAPM.logger.warn 'You need to initialize Ruby library in application with'
46
+ SolarWindsAPM.logger.warn 'SolarWindsAPM::OTelNativeConfig.initialize_with_config do |config|'
47
+ SolarWindsAPM.logger.warn ' # ... your configuration code'
48
+ SolarWindsAPM.logger.warn 'end'
49
+ SolarWindsAPM.logger.warn 'See: https://github.com/solarwinds/apm-ruby/blob/main/CONFIGURATION.md#in-code-configuration'
50
+ SolarWindsAPM.logger.warn "\e[1mPlease discard this message if application have already taken this action.\e[0m"
51
+ SolarWindsAPM.logger.warn '=============================================================='
52
+ require 'solarwinds_apm/noop'
93
53
  end
94
- rescue LoadError => e
95
- SolarWindsAPM.logger.error '=============================================================='
96
- SolarWindsAPM.logger.error 'Error occurs while loading solarwinds_apm. SolarWinds APM disabled.'
97
- SolarWindsAPM.logger.error "Error: #{e.message}"
98
- SolarWindsAPM.logger.error 'See: https://documentation.solarwinds.com/en/success_center/observability/default.htm#cshid=config-ruby-agent'
99
- SolarWindsAPM.logger.error '=============================================================='
100
54
  end
101
55
  rescue StandardError => e
102
56
  warn "[solarwinds_apm/error] Problem loading: #{e.inspect}"