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.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/solarwinds_apm/api/current_trace_info.rb +10 -6
- data/lib/solarwinds_apm/api/custom_metrics.rb +8 -25
- data/lib/solarwinds_apm/api/tracing.rb +12 -27
- data/lib/solarwinds_apm/api/transaction_name.rb +6 -10
- data/lib/solarwinds_apm/config.rb +1 -1
- data/lib/solarwinds_apm/constants.rb +1 -0
- data/lib/solarwinds_apm/noop/api.rb +5 -2
- data/lib/solarwinds_apm/noop.rb +0 -24
- data/lib/solarwinds_apm/opentelemetry/otlp_processor.rb +90 -69
- data/lib/solarwinds_apm/opentelemetry/solarwinds_propagator.rb +0 -2
- data/lib/solarwinds_apm/opentelemetry/solarwinds_response_propagator.rb +5 -4
- data/lib/solarwinds_apm/opentelemetry.rb +5 -7
- data/lib/solarwinds_apm/otel_native_config.rb +177 -0
- data/lib/solarwinds_apm/patch/README.md +15 -0
- data/lib/solarwinds_apm/{noop/metadata.rb → sampling/dice.rb} +19 -17
- data/lib/solarwinds_apm/sampling/http_sampler.rb +87 -0
- data/lib/solarwinds_apm/sampling/json_sampler.rb +52 -0
- data/lib/solarwinds_apm/sampling/metrics.rb +38 -0
- data/lib/solarwinds_apm/sampling/oboe_sampler.rb +348 -0
- data/lib/solarwinds_apm/sampling/sampler.rb +197 -0
- data/lib/solarwinds_apm/sampling/sampling_constants.rb +127 -0
- data/lib/solarwinds_apm/sampling/sampling_patch.rb +49 -0
- data/lib/solarwinds_apm/sampling/setting_example.txt +1 -0
- data/lib/solarwinds_apm/{noop/context.rb → sampling/settings.rb} +14 -25
- data/lib/solarwinds_apm/sampling/token_bucket.rb +126 -0
- data/lib/solarwinds_apm/sampling/trace_options.rb +100 -0
- data/lib/solarwinds_apm/{patch.rb → sampling.rb} +20 -4
- data/lib/solarwinds_apm/{noop/span.rb → support/aws_resource_detector.rb} +5 -18
- data/lib/solarwinds_apm/support/logger_formatter.rb +1 -1
- data/lib/solarwinds_apm/support/logging_log_event.rb +1 -1
- data/lib/solarwinds_apm/support/lumberjack_formatter.rb +1 -1
- data/lib/solarwinds_apm/support/otlp_endpoint.rb +99 -0
- data/lib/solarwinds_apm/support/resource_detector/aws/beanstalk.rb +51 -0
- data/lib/solarwinds_apm/support/resource_detector/aws/ec2.rb +145 -0
- data/lib/solarwinds_apm/support/resource_detector/aws/ecs.rb +173 -0
- data/lib/solarwinds_apm/support/resource_detector/aws/eks.rb +174 -0
- data/lib/solarwinds_apm/support/resource_detector/aws/lambda.rb +66 -0
- data/lib/solarwinds_apm/support/resource_detector.rb +192 -0
- data/lib/solarwinds_apm/support/service_key_checker.rb +12 -6
- data/lib/solarwinds_apm/support/transaction_settings.rb +6 -0
- data/lib/solarwinds_apm/support/txn_name_manager.rb +54 -9
- data/lib/solarwinds_apm/support/utils.rb +9 -0
- data/lib/solarwinds_apm/support.rb +3 -4
- data/lib/solarwinds_apm/version.rb +4 -4
- data/lib/solarwinds_apm.rb +27 -73
- metadata +99 -40
- data/ext/oboe_metal/extconf.rb +0 -168
- data/ext/oboe_metal/lib/liboboe-1.0-aarch64.so.sha256 +0 -1
- data/ext/oboe_metal/lib/liboboe-1.0-alpine-aarch64.so.sha256 +0 -1
- data/ext/oboe_metal/lib/liboboe-1.0-alpine-x86_64.so.sha256 +0 -1
- data/ext/oboe_metal/lib/liboboe-1.0-lambda-aarch64.so.sha256 +0 -1
- data/ext/oboe_metal/lib/liboboe-1.0-lambda-x86_64.so.sha256 +0 -1
- data/ext/oboe_metal/lib/liboboe-1.0-x86_64.so.sha256 +0 -1
- data/ext/oboe_metal/src/VERSION +0 -1
- data/ext/oboe_metal/src/bson/bson.h +0 -220
- data/ext/oboe_metal/src/bson/platform_hacks.h +0 -91
- data/ext/oboe_metal/src/init_solarwinds_apm.cc +0 -18
- data/ext/oboe_metal/src/oboe.h +0 -930
- data/ext/oboe_metal/src/oboe_api.cpp +0 -793
- data/ext/oboe_metal/src/oboe_api.h +0 -621
- data/ext/oboe_metal/src/oboe_debug.h +0 -17
- data/ext/oboe_metal/src/oboe_swig_wrap.cc +0 -11045
- data/lib/oboe_metal.rb +0 -187
- data/lib/solarwinds_apm/cert/star.appoptics.com.issuer.crt +0 -24
- data/lib/solarwinds_apm/oboe_init_options.rb +0 -222
- data/lib/solarwinds_apm/opentelemetry/solarwinds_exporter.rb +0 -239
- data/lib/solarwinds_apm/opentelemetry/solarwinds_processor.rb +0 -174
- data/lib/solarwinds_apm/opentelemetry/solarwinds_sampler.rb +0 -333
- data/lib/solarwinds_apm/otel_config.rb +0 -174
- data/lib/solarwinds_apm/otel_lambda_config.rb +0 -56
- data/lib/solarwinds_apm/patch/dummy_patch.rb +0 -12
- data/lib/solarwinds_apm/support/oboe_tracing_mode.rb +0 -33
- data/lib/solarwinds_apm/support/support_report.rb +0 -99
- data/lib/solarwinds_apm/support/transaction_cache.rb +0 -57
- data/lib/solarwinds_apm/support/x_trace_options.rb +0 -138
@@ -1,56 +0,0 @@
|
|
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 'solarwinds_apm/constants'
|
10
|
-
require 'solarwinds_apm/api'
|
11
|
-
require 'solarwinds_apm/support'
|
12
|
-
require 'solarwinds_apm/opentelemetry'
|
13
|
-
|
14
|
-
module SolarWindsAPM
|
15
|
-
# OTelLambdaConfig module
|
16
|
-
module OTelLambdaConfig
|
17
|
-
def self.initialize
|
18
|
-
return unless defined?(::OpenTelemetry::SDK::Configurator)
|
19
|
-
|
20
|
-
if ENV['OTEL_TRACES_EXPORTER'].to_s.empty?
|
21
|
-
ENV['OTEL_TRACES_EXPORTER'] = 'otlp'
|
22
|
-
elsif !ENV['OTEL_TRACES_EXPORTER'].include? 'otlp'
|
23
|
-
ENV['OTEL_TRACES_EXPORTER'] += ',otlp'
|
24
|
-
end
|
25
|
-
|
26
|
-
ENV['OTEL_RESOURCE_ATTRIBUTES'] = "sw.apm.version=#{SolarWindsAPM::Version::STRING},sw.data.module=apm,service.name=#{ENV['OTEL_SERVICE_NAME'] || ENV.fetch('AWS_LAMBDA_FUNCTION_NAME', nil)}," + ENV['OTEL_RESOURCE_ATTRIBUTES'].to_s
|
27
|
-
::OpenTelemetry::SDK.configure(&:use_all)
|
28
|
-
|
29
|
-
# append our propagators
|
30
|
-
::OpenTelemetry.propagation.instance_variable_get(:@propagators).append(SolarWindsAPM::OpenTelemetry::SolarWindsPropagator::TextMapPropagator.new)
|
31
|
-
|
32
|
-
# register metrics_exporter to meter_provider
|
33
|
-
::OpenTelemetry.meter_provider.add_metric_reader(::OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter.new)
|
34
|
-
|
35
|
-
# append our processors
|
36
|
-
::OpenTelemetry.tracer_provider.add_span_processor(SolarWindsAPM::OpenTelemetry::OTLPProcessor.new)
|
37
|
-
|
38
|
-
# configure sampler afterwards
|
39
|
-
::OpenTelemetry.tracer_provider.sampler = ::OpenTelemetry::SDK::Trace::Samplers.parent_based(
|
40
|
-
root: SolarWindsAPM::OpenTelemetry::SolarWindsSampler.new,
|
41
|
-
remote_parent_sampled: SolarWindsAPM::OpenTelemetry::SolarWindsSampler.new,
|
42
|
-
remote_parent_not_sampled: SolarWindsAPM::OpenTelemetry::SolarWindsSampler.new
|
43
|
-
)
|
44
|
-
|
45
|
-
SolarWindsAPM.logger.info do
|
46
|
-
"[#{name}/#{__method__}] SolarWindsAPM lambda configuration initialized \
|
47
|
-
\n Installed instrumentation: #{::OpenTelemetry.tracer_provider.instance_variable_get(:@registry).keys} \
|
48
|
-
\n SpanProcessor: #{::OpenTelemetry.tracer_provider.instance_variable_get(:@span_processors).map(&:class)} \
|
49
|
-
\n Sampler: #{::OpenTelemetry.tracer_provider.instance_variable_get(:@sampler).inspect} \
|
50
|
-
\n Resource: #{::OpenTelemetry.tracer_provider.instance_variable_get(:@resource).inspect}"
|
51
|
-
end
|
52
|
-
|
53
|
-
nil
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,33 +0,0 @@
|
|
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
|
-
module SolarWindsAPM
|
10
|
-
# OboeTracingMode
|
11
|
-
# Used in solarwinds_sampler
|
12
|
-
class OboeTracingMode
|
13
|
-
OBOE_SETTINGS_UNSET = -1
|
14
|
-
OBOE_TRACE_DISABLED = 0
|
15
|
-
OBOE_TRACE_ENABLED = 1
|
16
|
-
OBOE_TRIGGER_DISABLED = 0
|
17
|
-
OBOE_TRIGGER_ENABLED = 1
|
18
|
-
|
19
|
-
def self.get_oboe_trace_mode(tracing_mode)
|
20
|
-
mode = OBOE_SETTINGS_UNSET
|
21
|
-
mode = OBOE_TRACE_ENABLED if tracing_mode == :enabled
|
22
|
-
mode = OBOE_TRACE_DISABLED if tracing_mode == :disabled
|
23
|
-
mode
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.get_oboe_trigger_trace_mode(trigger_trace_mode)
|
27
|
-
mode = OBOE_SETTINGS_UNSET
|
28
|
-
mode = OBOE_TRIGGER_ENABLED if trigger_trace_mode == :enabled
|
29
|
-
mode = OBOE_TRIGGER_DISABLED if trigger_trace_mode == :disabled
|
30
|
-
mode
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,99 +0,0 @@
|
|
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 'rbconfig'
|
10
|
-
require 'logger'
|
11
|
-
|
12
|
-
##
|
13
|
-
# This module is used to debug problematic setups and/or environments.
|
14
|
-
# Depending on the environment, output may be to stdout or the framework
|
15
|
-
# log file (e.g. log/production.log)
|
16
|
-
module SolarWindsAPM
|
17
|
-
##
|
18
|
-
# yesno
|
19
|
-
#
|
20
|
-
# Utility method to translate value/nil to "yes"/"no" strings
|
21
|
-
def self.yesno(condition)
|
22
|
-
condition ? 'yes' : 'no'
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.support_report
|
26
|
-
@logger_level = SolarWindsAPM.logger.level
|
27
|
-
SolarWindsAPM.logger.level = ::Logger::DEBUG
|
28
|
-
|
29
|
-
SolarWindsAPM.logger.warn '********************************************************'
|
30
|
-
SolarWindsAPM.logger.warn '* BEGIN SolarWindsAPM Support Report'
|
31
|
-
SolarWindsAPM.logger.warn '* Please email the output of this report to SWO-support@solarwinds.com'
|
32
|
-
SolarWindsAPM.logger.warn '********************************************************'
|
33
|
-
SolarWindsAPM.logger.warn "Ruby: #{RUBY_DESCRIPTION}"
|
34
|
-
SolarWindsAPM.logger.warn "PROGRAM_NAME: #{$PROGRAM_NAME}" # replace $0 to get executing script
|
35
|
-
SolarWindsAPM.logger.warn "ARGV: #{ARGV.inspect}"
|
36
|
-
SolarWindsAPM.logger.warn "SolarWindsAPM.loaded == #{SolarWindsAPM.loaded}"
|
37
|
-
|
38
|
-
SolarWindsAPM.logger.warn "SolarWindsAPM::Ruby defined?: #{yesno(defined?(SolarWindsAPM::Ruby))}"
|
39
|
-
SolarWindsAPM.logger.warn "SolarWindsAPM.reporter: #{SolarWindsAPM.reporter}"
|
40
|
-
|
41
|
-
SolarWindsAPM.logger.warn '********************************************************'
|
42
|
-
SolarWindsAPM.logger.warn '* Frameworks'
|
43
|
-
SolarWindsAPM.logger.warn '********************************************************'
|
44
|
-
|
45
|
-
using_rails = defined?(::Rails)
|
46
|
-
SolarWindsAPM.logger.warn "Using Rails?: #{yesno(using_rails)}"
|
47
|
-
if using_rails
|
48
|
-
SolarWindsAPM.logger.warn "SolarWindsAPM::Rails loaded?: #{yesno(defined?(SolarWindsAPM::Rails))}"
|
49
|
-
SolarWindsAPM.logger.warn "SolarWindsAPM::Rack middleware loaded?: #{yesno(::Rails.configuration.middleware.include?(SolarWindsAPM::Rack))}" if defined?(SolarWindsAPM::Rack)
|
50
|
-
end
|
51
|
-
|
52
|
-
using_sinatra = defined?(::Sinatra)
|
53
|
-
SolarWindsAPM.logger.warn "Using Sinatra?: #{yesno(using_sinatra)}"
|
54
|
-
|
55
|
-
using_padrino = defined?(::Padrino)
|
56
|
-
SolarWindsAPM.logger.warn "Using Padrino?: #{yesno(using_padrino)}"
|
57
|
-
|
58
|
-
using_grape = defined?(::Grape)
|
59
|
-
SolarWindsAPM.logger.warn "Using Grape?: #{yesno(using_grape)}"
|
60
|
-
|
61
|
-
SolarWindsAPM.logger.warn '********************************************************'
|
62
|
-
SolarWindsAPM.logger.warn '* ActiveRecord Adapter'
|
63
|
-
SolarWindsAPM.logger.warn '********************************************************'
|
64
|
-
if defined?(::ActiveRecord)
|
65
|
-
if defined?(::ActiveRecord::Base.connection.adapter_name)
|
66
|
-
SolarWindsAPM.logger.warn "ActiveRecord adapter: #{::ActiveRecord::Base.connection.adapter_name}"
|
67
|
-
end
|
68
|
-
else
|
69
|
-
SolarWindsAPM.logger.warn 'No ActiveRecord'
|
70
|
-
end
|
71
|
-
|
72
|
-
SolarWindsAPM.logger.warn '********************************************************'
|
73
|
-
SolarWindsAPM.logger.warn '* SolarWindsAPM::Config Values'
|
74
|
-
SolarWindsAPM.logger.warn '********************************************************'
|
75
|
-
SolarWindsAPM.logger.warn SolarWindsAPM::Config.print_config.to_s
|
76
|
-
|
77
|
-
SolarWindsAPM.logger.warn '********************************************************'
|
78
|
-
SolarWindsAPM.logger.warn '* SolarWindsAPM::OTelConfig Values'
|
79
|
-
SolarWindsAPM.logger.warn '********************************************************'
|
80
|
-
SolarWindsAPM.logger.warn SolarWindsAPM::OTelConfig.print_config.to_s
|
81
|
-
|
82
|
-
SolarWindsAPM.logger.warn '********************************************************'
|
83
|
-
SolarWindsAPM.logger.warn '* OS, Platform + Env'
|
84
|
-
SolarWindsAPM.logger.warn '********************************************************'
|
85
|
-
SolarWindsAPM.logger.warn "host_os: #{RbConfig::CONFIG['host_os']}"
|
86
|
-
SolarWindsAPM.logger.warn "sitearch: #{RbConfig::CONFIG['sitearch']}"
|
87
|
-
SolarWindsAPM.logger.warn "arch: #{RbConfig::CONFIG['arch']}"
|
88
|
-
SolarWindsAPM.logger.warn "Platform: #{RUBY_PLATFORM}"
|
89
|
-
|
90
|
-
SolarWindsAPM.logger.warn '********************************************************'
|
91
|
-
SolarWindsAPM.logger.warn '* END SolarWindsAPM Support Report'
|
92
|
-
SolarWindsAPM.logger.warn '* Support Email: technicalsupport@solarwinds.com'
|
93
|
-
SolarWindsAPM.logger.warn '* Github: https://github.com/solarwinds/apm-ruby'
|
94
|
-
SolarWindsAPM.logger.warn '********************************************************'
|
95
|
-
|
96
|
-
SolarWindsAPM.logger.level = @logger_level
|
97
|
-
nil
|
98
|
-
end
|
99
|
-
end
|
@@ -1,57 +0,0 @@
|
|
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
|
-
module SolarWindsAPM
|
10
|
-
# LRU TransactionCache with initial limit 1000
|
11
|
-
module TransactionCache
|
12
|
-
attr_reader :capacity
|
13
|
-
|
14
|
-
def self.initialize
|
15
|
-
@capacity = 1000
|
16
|
-
@cache = {}
|
17
|
-
@order = []
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.get(key)
|
21
|
-
return nil unless @cache.key?(key)
|
22
|
-
|
23
|
-
@order.delete(key)
|
24
|
-
@order.push(key)
|
25
|
-
@cache[key]
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.del(key)
|
29
|
-
@cache.delete(key)
|
30
|
-
@order.delete(key)
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.clear
|
34
|
-
@cache.clear
|
35
|
-
@order.clear
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.size
|
39
|
-
@cache.size
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.set(key, value)
|
43
|
-
if @cache.key?(key)
|
44
|
-
@cache.delete(key)
|
45
|
-
elsif @order.size >= @capacity
|
46
|
-
evict_key = @order.shift
|
47
|
-
@cache.delete(evict_key)
|
48
|
-
end
|
49
|
-
|
50
|
-
@cache[key] = value
|
51
|
-
@order.push(key)
|
52
|
-
SolarWindsAPM.logger.debug { "[#{self.class}/#{__method__}] current TransactionCache #{@cache.inspect}" }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
SolarWindsAPM::TransactionCache.initialize
|
@@ -1,138 +0,0 @@
|
|
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
|
-
module SolarWindsAPM
|
10
|
-
# XTraceOptions
|
11
|
-
class XTraceOptions
|
12
|
-
attr_reader :options, :signature, :trigger_trace, :timestamp,
|
13
|
-
:sw_keys, :custom_kvs, :ignored
|
14
|
-
|
15
|
-
##
|
16
|
-
# use by Trigger Tracing
|
17
|
-
# TODO - refactor for w3c when ticket ready
|
18
|
-
#
|
19
|
-
# Params:
|
20
|
-
# +options+ : An X-Trace-Options @options string
|
21
|
-
# +signature+ : hmac signature to pass on for verification
|
22
|
-
#
|
23
|
-
# populates:
|
24
|
-
# - @force_trace (true|false)
|
25
|
-
# - @app_id (as given by Pingdom)
|
26
|
-
# - @probe_id (as given by Pingdom)
|
27
|
-
# - @loc (2 characters given by Pingdom)
|
28
|
-
# - @custom_kvs (hash)
|
29
|
-
# - @ignored (array)
|
30
|
-
#
|
31
|
-
# split it up by ';' separator
|
32
|
-
# kv assignment by '='
|
33
|
-
# currently valid keys:
|
34
|
-
# - force_trace (valid: 0,1) unless we use just a kv
|
35
|
-
# - application_id (format defined by pingdom (no validation))
|
36
|
-
# - probe_id
|
37
|
-
# - custom_* (';=' not allowed in key), value (validate max. length)
|
38
|
-
# - ts (unix timestamp)
|
39
|
-
# - other keys will be reported in the response options as ignored
|
40
|
-
|
41
|
-
SW_XTRACEOPTIONS_RESPONSE_KEY = 'xtrace_options_response'
|
42
|
-
|
43
|
-
def initialize(context)
|
44
|
-
SolarWindsAPM.logger.debug { "[#{self.class}/#{__method__}] x_trace_options context: #{context.inspect}" }
|
45
|
-
@context = context.dup
|
46
|
-
@trigger_trace = false
|
47
|
-
@custom_kvs = {}
|
48
|
-
@sw_keys = nil
|
49
|
-
@ignored = []
|
50
|
-
@timestamp = 0
|
51
|
-
@options = options_header
|
52
|
-
@signature = obtain_signature
|
53
|
-
|
54
|
-
@options&.split(/;+/)&.each do |val|
|
55
|
-
k = val.split('=', 2)
|
56
|
-
|
57
|
-
next unless k[0] # it can be nil, eg when the header starts with ';'
|
58
|
-
|
59
|
-
k[0]&.strip!
|
60
|
-
case k[0]
|
61
|
-
when 'trigger-trace'
|
62
|
-
if k[1]
|
63
|
-
@ignored << 'trigger-trace'
|
64
|
-
else
|
65
|
-
@trigger_trace = true
|
66
|
-
end
|
67
|
-
when 'sw-keys'
|
68
|
-
if @sw_keys
|
69
|
-
SolarWindsAPM.logger.info { "[#{self.class}/#{__method__}] Duplicate key: #{k[0]}" }
|
70
|
-
else
|
71
|
-
@sw_keys = k[1].strip
|
72
|
-
end
|
73
|
-
when /^custom-[^\s]*$/
|
74
|
-
if @custom_kvs[k[0]]
|
75
|
-
SolarWindsAPM.logger.info { "[#{self.class}/#{__method__}] Duplicate key: #{k[0]}" }
|
76
|
-
else
|
77
|
-
@custom_kvs[k[0]] = k[1].strip
|
78
|
-
end
|
79
|
-
when 'ts'
|
80
|
-
if @timestamp.positive?
|
81
|
-
SolarWindsAPM.logger.info { "[#{self.class}/#{__method__}] Duplicate key: #{k[0]}" }
|
82
|
-
else
|
83
|
-
@timestamp = k[1].to_i
|
84
|
-
end
|
85
|
-
else
|
86
|
-
@ignored << k[0]
|
87
|
-
end
|
88
|
-
end
|
89
|
-
return if @ignored.empty?
|
90
|
-
|
91
|
-
SolarWindsAPM.logger.info("[#{self.class}/#{__method__}] Some keys were ignored: #{@ignored.join(',')}")
|
92
|
-
end
|
93
|
-
|
94
|
-
def add_kvs(kvs, settings)
|
95
|
-
return unless settings.auth_ok?
|
96
|
-
|
97
|
-
@custom_kvs.each { |k, v| kvs[k] = v } unless @custom_kvs.empty?
|
98
|
-
kvs['SWKeys'] = @sw_keys if @sw_keys
|
99
|
-
kvs['TriggeredTrace'] = true if settings.triggered_trace?
|
100
|
-
end
|
101
|
-
|
102
|
-
def obtain_signature
|
103
|
-
# INTL_SWO_SIGNATURE_KEY = sw_signature
|
104
|
-
signature = obtain_sw_value(SolarWindsAPM::Constants::INTL_SWO_SIGNATURE_KEY)
|
105
|
-
SolarWindsAPM.logger.debug { "[#{self.class}/#{__method__}] x_trace_options option_signature: #{signature}" }
|
106
|
-
signature
|
107
|
-
end
|
108
|
-
|
109
|
-
def options_header
|
110
|
-
# INTL_SWO_X_OPTIONS_KEY = sw_xtraceoptions
|
111
|
-
header = obtain_sw_value(SolarWindsAPM::Constants::INTL_SWO_X_OPTIONS_KEY)
|
112
|
-
SolarWindsAPM.logger.debug { "[#{self.class}/#{__method__}] x_trace_options option_header: #{header}" }
|
113
|
-
header
|
114
|
-
end
|
115
|
-
|
116
|
-
def obtain_sw_value(type)
|
117
|
-
sw_value = nil
|
118
|
-
instance_variable = @context&.instance_variable_get('@entries')
|
119
|
-
instance_variable&.each do |key, value|
|
120
|
-
next unless key.instance_of?(::String)
|
121
|
-
|
122
|
-
sw_value = value if key == type
|
123
|
-
SolarWindsAPM.logger.debug do
|
124
|
-
"[#{self.class}/#{__method__}] obtained sw value: #{type} #{key}: #{value.inspect}"
|
125
|
-
end
|
126
|
-
end
|
127
|
-
sw_value
|
128
|
-
end
|
129
|
-
|
130
|
-
def intify_trigger_trace
|
131
|
-
@trigger_trace ? 1 : 0
|
132
|
-
end
|
133
|
-
|
134
|
-
def self.sw_xtraceoptions_response_key
|
135
|
-
SW_XTRACEOPTIONS_RESPONSE_KEY
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|