solarwinds_apm 6.0.2 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +6 -0
- data/README.md +124 -0
- data/ext/oboe_metal/extconf.rb +32 -21
- data/ext/oboe_metal/lib/liboboe-1.0-aarch64.so.sha256 +1 -1
- data/ext/oboe_metal/lib/liboboe-1.0-alpine-aarch64.so.sha256 +1 -1
- data/ext/oboe_metal/lib/liboboe-1.0-alpine-x86_64.so.sha256 +1 -1
- data/ext/oboe_metal/lib/liboboe-1.0-lambda-aarch64.so.sha256 +1 -1
- data/ext/oboe_metal/lib/liboboe-1.0-lambda-x86_64.so.sha256 +1 -1
- data/ext/oboe_metal/lib/liboboe-1.0-x86_64.so.sha256 +1 -1
- data/ext/oboe_metal/src/VERSION +1 -1
- data/lib/rails/generators/solarwinds_apm/templates/solarwinds_apm_initializer.rb +1 -1
- data/lib/solarwinds_apm/constants.rb +1 -1
- data/lib/solarwinds_apm/noop/README.md +3 -0
- data/lib/solarwinds_apm/opentelemetry/otlp_processor.rb +7 -5
- data/lib/solarwinds_apm/opentelemetry.rb +2 -0
- data/lib/solarwinds_apm/otel_lambda_config.rb +6 -3
- data/lib/solarwinds_apm/support/service_key_checker.rb +2 -7
- data/lib/solarwinds_apm/support/swomarginalia/README.md +9 -4
- data/lib/solarwinds_apm/support/swomarginalia/formatter.rb +20 -0
- data/lib/solarwinds_apm/support.rb +2 -13
- data/lib/solarwinds_apm/version.rb +2 -2
- metadata +5 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 807b88fafed018cf28ab385ea2cb52667127fc4cbab96aac770b5c1f3ab894a6
|
4
|
+
data.tar.gz: b7ec5c206351c3f6fdc90da61550482d9b9e1d2e82f27c1d1a54408111c3f8db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 637ac2da4665dfe45e8095928ca1d46ac2bfdde1f3574913d232c6978d003158a0d94bdb472a5ed65088c89ab070b2e86079e518a9c60503dcd7c3c8af5059c3
|
7
|
+
data.tar.gz: 41dabb11f5b5e692342620a1936224e5acffe738bf01c0f9ca0ceabbec1a882eda455cdfd1fb9c3469e75300e0ef66227ab8699d369c0daf15eba6ff40b057b2
|
data/.yardopts
ADDED
data/README.md
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
# solarwinds_apm
|
2
|
+
|
3
|
+
The `solarwinds_apm` gem starting from version 6.0.0 is an [OpenTelemetry Ruby](https://opentelemetry.io/docs/instrumentation/ruby/) distribution. It provides automatic instrumentation and custom SolarWinds Observability features for Ruby applications.
|
4
|
+
|
5
|
+
## Requirements
|
6
|
+
|
7
|
+
Only Linux is supported, the gem will go into no-op mode on other platforms. MRI Ruby version 3 or above is required. The [SolarWinds Observability documentation website](https://documentation.solarwinds.com/en/success_center/observability/content/configure/services/ruby/install.htm) has details on the supported platforms and system dependencies.
|
8
|
+
|
9
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for how to build for development.
|
10
|
+
|
11
|
+
## Installation and Setup
|
12
|
+
|
13
|
+
`solarwinds_apm` is [available on Rubygems](https://rubygems.org/gems/solarwinds_apm). Install with:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
gem install solarwinds_apm
|
17
|
+
```
|
18
|
+
|
19
|
+
Or add to **the end** of your application Gemfile and run `bundle install` if managing gems with Bundler:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
# application dependencies, eg
|
23
|
+
# gem "rails", "~> 7.0.5", ">= 7.0.5.1"
|
24
|
+
|
25
|
+
# end of Gemfile
|
26
|
+
gem 'solarwinds_apm'
|
27
|
+
```
|
28
|
+
|
29
|
+
Ideally all application gems are required by `Bundler.require`, which guarantees loading in the order they appear in the Gemfile. If `Bundler.require` does not require all application gems, call `require 'solarwinds_apm'` after all gems that need instrumentation are loaded.
|
30
|
+
|
31
|
+
The only required configuration is the service key, which can be set in the `SW_APM_SERVICE_KEY` environment variable or in the configuration file as `:service_key`. See [CONFIGURATION.md](CONFIGURATION.md) for the complete reference.
|
32
|
+
|
33
|
+
## Custom Instrumentation
|
34
|
+
|
35
|
+
`solarwinds_apm` supports the standard OpenTelemetry API for tracing and includes a helper to ease its use in manual instrumentation. Additionally, a set of SolarWindsAPM APIs are provided for features specific to SolarWinds Observability.
|
36
|
+
|
37
|
+
### Using the OpenTelemetry API
|
38
|
+
|
39
|
+
This gem installs the dependencies needed to use the OTel API and initializes the globally-registered `TracerProvider`. So the "Setup" and "Acquiring a Tracer" sections of the [OTel Ruby Manual Instrumentation](https://opentelemetry.io/docs/instrumentation/ruby/manual/) should be skipped. Instead, your application code should acquire a `Tracer` from the global `TracerProvider` as follows.
|
40
|
+
|
41
|
+
The `Tracer` object is determined by the service name, which is the portion after the colon (`:`) set in the `SW_APM_SERVICE_KEY` or `:service_key` configuration. The service name is also automatically set into the `OTEL_SERVICE_NAME` environment variable which can be referenced as shown below. The `Tracer` object can then be used as described in the OTel Ruby documentation.
|
42
|
+
|
43
|
+
The example below shows how the standard OTel API to [create a span](https://opentelemetry.io/docs/instrumentation/ruby/manual/#creating-new-spans) and [get the current span](https://opentelemetry.io/docs/instrumentation/ruby/manual/#get-the-current-span) can be used in an application where `solarwinds_apm` has been loaded. See also the convenience [wrapper for in_span provided by the SolarWindsAPM API](#convenience-method-for-in_span):
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
# acquire the tracer
|
47
|
+
MyAppTracer = ::OpenTelemetry.tracer_provider.tracer(ENV['OTEL_SERVICE_NAME'])
|
48
|
+
|
49
|
+
# create a new span
|
50
|
+
MyAppTracer.in_span('new.span', attributes: {'key1' => 'value1', 'key2' => 'value2'}) do |span|
|
51
|
+
# do things
|
52
|
+
end
|
53
|
+
|
54
|
+
# work with the current span
|
55
|
+
current_span = ::OpenTelemetry::Trace.current_span
|
56
|
+
# current_span.add_attributes
|
57
|
+
# current_span.add_event
|
58
|
+
# current_span.record_exception
|
59
|
+
```
|
60
|
+
|
61
|
+
Note that if `OpenTelemetry::SDK.configure` is used to set up a `TracerProvider`, it will not be configured with our distribution's customizations and manual instrumentation made with its `Tracer` object will not be reported to SolarWinds Observability.
|
62
|
+
|
63
|
+
### Using the SolarWindsAPM API
|
64
|
+
|
65
|
+
Several convenience and vendor-specific APIs are availabe to an application where `solarwinds_apm` has been loaded, below is a quick overview of the features provided. The full reference can be found at the [RubyDoc page for this gem](https://rubydoc.info/github/solarwinds/apm-ruby).
|
66
|
+
|
67
|
+
#### Convenience Method for in_span
|
68
|
+
|
69
|
+
This method acquires the correct `Tracer` so a new span can be created in a single call, below is a simple Rails controller example:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
class StaticController < ApplicationController
|
73
|
+
def home
|
74
|
+
SolarWindsAPM::API.in_span('custom_span') do |span|
|
75
|
+
# do things
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
```
|
80
|
+
|
81
|
+
#### Get Curent Trace Context Information
|
82
|
+
|
83
|
+
The `current_trace_info` method returns a `TraceInfo` object containing string representations of the current trace context that can be used in logging or manual propagation of context. This is a convenience method that wraps the OTel API `::OpenTelemetry::Trace.current_span`.
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
trace = SolarWindsAPM::API.current_trace_info
|
87
|
+
|
88
|
+
trace.tracestring # 00-7435a9fe510ae4533414d425dadf4e18-49e60702469db05f-01
|
89
|
+
trace.trace_id # 7435a9fe510ae4533414d425dadf4e18
|
90
|
+
trace.span_id # 49e60702469db05f
|
91
|
+
trace.trace_flags # 01
|
92
|
+
```
|
93
|
+
|
94
|
+
#### Check if solarwinds_apm Is Ready
|
95
|
+
|
96
|
+
On startup, this library initializes and maintains a connection to a SolarWinds Observability collector, and receives settings used for making tracing decisions. This process can take up to a few seconds depending on the connection. If the application receives requests before initialization has completed, these requests will not be traced. While this is not critical for long-running server processes, it might be a problem for short-running apps such as cron jobs or CLI apps.
|
97
|
+
|
98
|
+
A call to the `solarwinds_ready` method allows the application to block until initialization has completed and the library is ready for tracing. The method accepts an optional timeout parameter in milliseconds.
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
SolarWindsAPM::API.solarwinds_ready(wait_milliseconds=3000)
|
102
|
+
```
|
103
|
+
|
104
|
+
#### Set a Custom Transaction Name
|
105
|
+
|
106
|
+
By default, transaction names are constructed based on attributes such as the requested route in the server framework, or the span name. If this name is not descriptive enough, you can override it with a custom one. If multiple transaction names are set on the same trace, the last transaction name is used.
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
result = SolarWindsAPM::API.set_transaction_name('my-custom-trace-name')
|
110
|
+
```
|
111
|
+
|
112
|
+
#### Send Custom Metrics
|
113
|
+
|
114
|
+
Service metrics are automatically collected by this library. In addition, the following methods support sending two types of custom metrics:
|
115
|
+
|
116
|
+
* `increment_metric` - counts the number of times something has occurred
|
117
|
+
* `summary_metric` - a specific value for the default count of 1, or the sum of values if count > 1
|
118
|
+
|
119
|
+
The metrics submitted are aggregated by metric name and tag(s), then sent every 60 seconds.
|
120
|
+
|
121
|
+
```ruby
|
122
|
+
SolarWindsAPM::API.increment_metric('loop.iteration')
|
123
|
+
SolarWindsAPM::API.summary_metric('sleep.time', 5000)
|
124
|
+
```
|
data/ext/oboe_metal/extconf.rb
CHANGED
@@ -18,22 +18,25 @@ CONFIG['warnflags'] = CONFIG['warnflags'].gsub('-Wdeclaration-after-statement',
|
|
18
18
|
init_mkmf(CONFIG)
|
19
19
|
|
20
20
|
ext_dir = __dir__
|
21
|
+
oboe_debug = ENV['OBOE_DEBUG'].to_s.casecmp('true').zero?
|
22
|
+
non_production = ENV['OBOE_DEV'].to_s.casecmp('true').zero? || ENV['OBOE_STAGING'].to_s.casecmp('true').zero?
|
21
23
|
|
22
|
-
# Set the mkmf lib paths so we have no issues linking to
|
23
|
-
# the SolarWindsAPM libs.
|
24
24
|
swo_lib_dir = File.join(ext_dir, 'lib')
|
25
|
-
|
25
|
+
version = File.read(File.join(ext_dir, 'src', 'VERSION')).strip
|
26
26
|
|
27
|
-
#
|
28
|
-
|
29
|
-
|
27
|
+
# OBOE_DEBUG has the highest priorities over oboe environment
|
28
|
+
if oboe_debug
|
29
|
+
swo_path = File.join('https://agent-binaries.cloud.solarwinds.com/apm/c-lib/', version, 'relwithdebinfo')
|
30
|
+
puts 'Fetching c-lib from PRODUCTION DEBUG Build'
|
31
|
+
elsif ENV['OBOE_DEV'].to_s.casecmp('true').zero?
|
30
32
|
swo_path = 'https://solarwinds-apm-staging.s3.us-west-2.amazonaws.com/apm/c-lib/nightly'
|
31
33
|
puts 'Fetching c-lib from DEVELOPMENT Build'
|
32
34
|
elsif ENV['OBOE_STAGING'].to_s.casecmp('true').zero?
|
33
35
|
swo_path = File.join('https://agent-binaries.global.st-ssp.solarwinds.com/apm/c-lib/', version)
|
34
|
-
puts 'Fetching c-lib from STAGING'
|
36
|
+
puts 'Fetching c-lib from STAGING Build'
|
35
37
|
else
|
36
38
|
swo_path = File.join('https://agent-binaries.cloud.solarwinds.com/apm/c-lib/', version)
|
39
|
+
puts 'Fetching c-lib from PRODUCTION Build'
|
37
40
|
end
|
38
41
|
|
39
42
|
swo_arch = 'x86_64'
|
@@ -70,14 +73,18 @@ while retries.positive?
|
|
70
73
|
begin
|
71
74
|
IO.copy_stream(URI.parse(swo_item).open, clib)
|
72
75
|
clib_checksum = Digest::SHA256.file(clib).hexdigest
|
73
|
-
checksum =
|
76
|
+
checksum = File.read(swo_checksum_file).strip
|
77
|
+
|
78
|
+
# sha256 always from prod, so no matching for stg or nightly build or debug mode
|
79
|
+
# so ignore the sha comparsion when fetching from development and staging build
|
80
|
+
checksum = clib_checksum if non_production || oboe_debug
|
74
81
|
|
75
82
|
# unfortunately these messages only show if the install command is run
|
76
83
|
# with the `--verbose` flag
|
77
84
|
if clib_checksum == checksum
|
78
85
|
success = true
|
79
|
-
retries = 0
|
80
86
|
else
|
87
|
+
puts 'Checksum Verification Fail' # this is mainly for testing
|
81
88
|
warn '== ERROR ================================================================='
|
82
89
|
warn 'Checksum Verification failed for the c-extension of the solarwinds_apm gem'
|
83
90
|
warn 'Installation cannot continue'
|
@@ -85,8 +92,8 @@ while retries.positive?
|
|
85
92
|
warn "Checksum calculated from lib: #{clib_checksum}"
|
86
93
|
warn 'Contact technicalsupport@solarwinds.com if the problem persists'
|
87
94
|
warn '=========================================================================='
|
88
|
-
exit 1
|
89
95
|
end
|
96
|
+
retries = 0
|
90
97
|
rescue StandardError => e
|
91
98
|
File.write(clib, '')
|
92
99
|
retries -= 1
|
@@ -118,22 +125,26 @@ if success
|
|
118
125
|
$libs = append_library($libs, 'stdc++')
|
119
126
|
|
120
127
|
$CFLAGS << " #{ENV.fetch('CFLAGS', nil)}"
|
121
|
-
|
122
|
-
#
|
123
|
-
|
124
|
-
|
125
|
-
|
128
|
+
|
129
|
+
# -pg option is used for generating profiling information with gprof
|
130
|
+
$CPPFLAGS << if oboe_debug
|
131
|
+
" #{ENV.fetch('CPPFLAGS', nil)} -std=c++11 -gdwarf-2 -I$$ORIGIN/../ext/oboe_metal/src"
|
132
|
+
else
|
133
|
+
" #{ENV.fetch('CPPFLAGS', nil)} -std=c++11 -I$$ORIGIN/../ext/oboe_metal/src"
|
134
|
+
end
|
135
|
+
|
126
136
|
$LIBS << " #{ENV.fetch('LIBS', nil)}"
|
127
137
|
|
128
|
-
#
|
129
|
-
#
|
138
|
+
# -lrt option is used when linking programs with the GNU Compiler Collection (GCC) to
|
139
|
+
# include the POSIX real-time extensions library, librt.
|
130
140
|
$LDFLAGS << " #{ENV.fetch('LDFLAGS', nil)} '-Wl,-rpath=$$ORIGIN/../ext/oboe_metal/lib' -lrt"
|
131
141
|
$CXXFLAGS += ' -std=c++11 '
|
132
142
|
|
133
|
-
#
|
134
|
-
|
135
|
-
|
136
|
-
|
143
|
+
# OBOE_DEBUG need to be enabled before downloading and installing the gem
|
144
|
+
if oboe_debug
|
145
|
+
CONFIG['debugflags'] = '-ggdb3 '
|
146
|
+
CONFIG['optflags'] = '-O0'
|
147
|
+
end
|
137
148
|
|
138
149
|
create_makefile('libsolarwinds_apm', 'src')
|
139
150
|
else
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
61538e93d28a320f25615c04330c61c9b85fb61832d0be570b35ac75ce3cb05c
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
84dadb40257d98b3f1a1bf79aec922bd41f35119538ddf128546048738ae7729
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
50ef136fd07dda69b9fed1c7fd61e364aae23402c814b56e03775f32525af348
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
38204cae649edff5ac37ea97b5991ed06ed6dca47201745ac261be9f15386dbc
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
65808108b17f1b883d8fbbcd48eb04c5682b67b5ec04c04c5642f29664aa29af
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
337fb9e998fd2f802b6d8305a45a7d0c6248da621d2607ddf2d0b4254d5a6fde
|
data/ext/oboe_metal/src/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
15.0.
|
1
|
+
15.0.2
|
@@ -7,7 +7,7 @@
|
|
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
|
# SolarWindsAPM Configuration for the Ruby Agent aka solarwinds_apm gem
|
10
|
-
# https://
|
10
|
+
# https://www.solarwinds.com/solarwinds-observability/registration
|
11
11
|
#
|
12
12
|
# More information on configuring the Ruby Agent can be found here:
|
13
13
|
# https://documentation.solarwinds.com/en/success_center/swaas/default.htm#cshid=config-ruby-agent
|
@@ -29,7 +29,7 @@ module SolarWindsAPM
|
|
29
29
|
INTL_SWO_SUPPORT_EMAIL = 'SWO-support@solarwinds.com'
|
30
30
|
INTL_SWO_OTEL_SCOPE_NAME = 'otel.scope.name'
|
31
31
|
INTL_SWO_OTEL_SCOPE_VERSION = 'otel.scope.version'
|
32
|
-
INTL_SWO_OTEL_STATUS = 'otel.
|
32
|
+
INTL_SWO_OTEL_STATUS = 'otel.status_code'
|
33
33
|
INTL_SWO_OTEL_STATUS_DESCRIPTION = 'otel.status_description'
|
34
34
|
INTERNAL_TRIGGERED_TRACE = 'TriggeredTrace'
|
35
35
|
end
|
@@ -22,7 +22,7 @@ module SolarWindsAPM
|
|
22
22
|
# @param [Context] parent_context the
|
23
23
|
# started span.
|
24
24
|
def on_start(span, parent_context)
|
25
|
-
SolarWindsAPM.logger.debug { "[#{self.class}/#{__method__}] processor on_start span: #{span.inspect}" }
|
25
|
+
SolarWindsAPM.logger.debug { "[#{self.class}/#{__method__}] processor on_start span: #{span.to_span_data.inspect}" }
|
26
26
|
|
27
27
|
return if non_entry_span(parent_context: parent_context)
|
28
28
|
|
@@ -70,10 +70,11 @@ module SolarWindsAPM
|
|
70
70
|
'sw.transaction' => calculate_lambda_transaction_name(span)
|
71
71
|
}
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
if span_http?(span)
|
74
|
+
http_status_code = get_http_status_code(span)
|
75
|
+
meter_attrs['http.status_code'] = http_status_code if http_status_code != 0
|
76
|
+
meter_attrs['http.method'] = span.attributes[HTTP_METHOD] if span.attributes[HTTP_METHOD]
|
77
|
+
end
|
77
78
|
SolarWindsAPM.logger.debug { "[#{self.class}/#{__method__}] meter_attrs: #{meter_attrs.inspect}" }
|
78
79
|
meter_attrs
|
79
80
|
end
|
@@ -100,6 +101,7 @@ module SolarWindsAPM
|
|
100
101
|
def record_request_metrics(span)
|
101
102
|
meter_attrs = meter_attributes(span)
|
102
103
|
span_time = calculate_span_time(start_time: span.start_timestamp, end_time: span.end_timestamp)
|
104
|
+
span_time = (span_time / 1e3).round
|
103
105
|
SolarWindsAPM.logger.debug { "[#{self.class}/#{__method__}] entry span, response_time: #{span_time}." }
|
104
106
|
@metrics[:response_time].record(span_time, attributes: meter_attrs)
|
105
107
|
end
|
@@ -9,6 +9,8 @@
|
|
9
9
|
require 'opentelemetry/sdk'
|
10
10
|
require 'opentelemetry/instrumentation/all'
|
11
11
|
|
12
|
+
# TODO: in future, it should add opentelemetry-metrics-sdk and require it here
|
13
|
+
|
12
14
|
require_relative 'opentelemetry/solarwinds_propagator'
|
13
15
|
require_relative 'opentelemetry/solarwinds_processor'
|
14
16
|
require_relative 'opentelemetry/solarwinds_sampler'
|
@@ -30,7 +30,7 @@ module SolarWindsAPM
|
|
30
30
|
::OpenTelemetry.propagation.instance_variable_get(:@propagators).append(SolarWindsAPM::OpenTelemetry::SolarWindsPropagator::TextMapPropagator.new)
|
31
31
|
|
32
32
|
# register metrics_exporter to meter_provider
|
33
|
-
::OpenTelemetry.meter_provider.add_metric_reader(::OpenTelemetry::Exporter::OTLP::MetricsExporter.new)
|
33
|
+
::OpenTelemetry.meter_provider.add_metric_reader(::OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter.new)
|
34
34
|
|
35
35
|
# append our processors
|
36
36
|
::OpenTelemetry.tracer_provider.add_span_processor(SolarWindsAPM::OpenTelemetry::OTLPProcessor.new)
|
@@ -42,9 +42,12 @@ module SolarWindsAPM
|
|
42
42
|
remote_parent_not_sampled: SolarWindsAPM::OpenTelemetry::SolarWindsSampler.new
|
43
43
|
)
|
44
44
|
|
45
|
-
SolarWindsAPM.logger.
|
45
|
+
SolarWindsAPM.logger.info do
|
46
46
|
"[#{name}/#{__method__}] SolarWindsAPM lambda configuration initialized \
|
47
|
-
\
|
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}"
|
48
51
|
end
|
49
52
|
|
50
53
|
nil
|
@@ -26,7 +26,7 @@ module SolarWindsAPM
|
|
26
26
|
end
|
27
27
|
|
28
28
|
token, _, service_name = parse_service_key(service_key)
|
29
|
-
if token.empty?
|
29
|
+
if token.empty?
|
30
30
|
SolarWindsAPM.logger.error do
|
31
31
|
"[#{self.class}/#{__method__}] SW_APM_SERVICE_KEY problem. API Token in wrong format. Masked token: #{token[0..3]}...#{token[-4..]}"
|
32
32
|
end
|
@@ -66,7 +66,7 @@ module SolarWindsAPM
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def parse_service_key(service_key)
|
69
|
-
match = service_key.match(/([^:]
|
69
|
+
match = service_key.match(/([^:]*)(:{0,1})(.*)/)
|
70
70
|
return ['', '', ''] if match.nil?
|
71
71
|
|
72
72
|
[match[1], match[2], match[3]]
|
@@ -84,11 +84,6 @@ module SolarWindsAPM
|
|
84
84
|
end || ''
|
85
85
|
end
|
86
86
|
|
87
|
-
# In case of java-collector, please provide a dummy service key
|
88
|
-
def validate_token(token)
|
89
|
-
/^[0-9a-zA-Z_-]{71}$/.match?(token)
|
90
|
-
end
|
91
|
-
|
92
87
|
def transform_service_name(service_name)
|
93
88
|
name_ = service_name.dup
|
94
89
|
name_.downcase!
|
@@ -1,10 +1,10 @@
|
|
1
|
-
# swomarginalia
|
1
|
+
# swomarginalia
|
2
2
|
|
3
3
|
This folder contains the code that is copied from original [marginalia](https://github.com/basecamp/marginalia)
|
4
4
|
|
5
5
|
## File structure
|
6
6
|
|
7
|
-
```
|
7
|
+
```console
|
8
8
|
|-- swomarginalia
|
9
9
|
| |-- LICENSE
|
10
10
|
| |-- README.md
|
@@ -17,25 +17,30 @@ This folder contains the code that is copied from original [marginalia](https://
|
|
17
17
|
## Modification
|
18
18
|
|
19
19
|
### railitie.rb
|
20
|
+
|
20
21
|
1. Moved prepend logic into load_swomarginalia.rb in case that non-rails app using activerecord
|
21
22
|
|
22
23
|
### swomarginlia.rb
|
24
|
+
|
23
25
|
1. Removed the alias_method to achieve function override; instead, we use prepend.
|
24
26
|
2. Added step of cleaning-up previous transparent comments
|
25
27
|
|
26
28
|
### comment.rb
|
29
|
+
|
27
30
|
1. Added the traceparent comment (trace string constructed based on opentelemetry)
|
28
31
|
|
29
32
|
### load_swomarginalia.rb
|
33
|
+
|
30
34
|
1. (new file) prepend the ActiveRecordInstrumentation to activerecord adapter
|
31
35
|
|
32
36
|
## Example
|
33
37
|
|
34
38
|
### Sample output of rails application
|
35
39
|
|
36
|
-
```
|
40
|
+
```console
|
37
41
|
Post Load (1.1ms) SELECT `posts`.* FROM `posts` /*application=SqlcommenterRailsDemo,controller=posts,action=index,traceparent=00-a448f096d441e167d12ebd32a927c1a5-a29655a47e430119-01*/
|
38
42
|
```
|
39
43
|
|
40
44
|
## License
|
41
|
-
|
45
|
+
|
46
|
+
This project is licensed under the [MIT License](https://github.com/solarwinds/apm-ruby/blob/main/lib/solarwinds_apm/support/swomarginalia/LICENSE).
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolarWindsAPM
|
4
|
+
module SWOMarginalia
|
5
|
+
module Formatter
|
6
|
+
def tag_content
|
7
|
+
comment = super
|
8
|
+
comment.tr!(':', '=')
|
9
|
+
comment
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Prepend the Formatter module to the singleton class of ActiveRecord::QueryLogs
|
16
|
+
if defined?(ActiveRecord::QueryLogs)
|
17
|
+
class << ActiveRecord::QueryLogs
|
18
|
+
prepend SolarWindsAPM::SWOMarginalia::Formatter
|
19
|
+
end
|
20
|
+
end
|
@@ -23,20 +23,9 @@ if SolarWindsAPM::Config[:tag_sql]
|
|
23
23
|
if defined?(Rails)
|
24
24
|
if Rails.version < '7'
|
25
25
|
require_relative 'support/swomarginalia/railtie'
|
26
|
-
|
27
|
-
# User has to define in their config/environments:
|
28
|
-
# config.active_record.query_log_tags = [
|
29
|
-
# {
|
30
|
-
# tracecontext: -> {
|
31
|
-
# SolarWindsAPM::SWOMarginalia::Comment.traceparent
|
32
|
-
# }
|
33
|
-
# }
|
34
|
-
# ]
|
35
|
-
SolarWindsAPM.logger.info do
|
36
|
-
'In Rails 7, tag tracecontext on a query by including SolarWindsAPM::SWOMarginalia::Comment.traceparent as function in config.active_record.query_log_tags.'
|
37
|
-
end
|
38
|
-
SolarWindsAPM.logger.info { 'For more information, please check https://api.rubyonrails.org/classes/ActiveRecord/QueryLogs.html' }
|
26
|
+
else
|
39
27
|
require_relative 'support/swomarginalia/comment'
|
28
|
+
require_relative 'support/swomarginalia/formatter' if Rails.version <= '7.1'
|
40
29
|
end
|
41
30
|
elsif defined?(ActiveRecord)
|
42
31
|
require_relative 'support/swomarginalia/load_swomarginalia'
|
@@ -12,8 +12,8 @@ module SolarWindsAPM
|
|
12
12
|
# solarwinds_apm.gemspec during gem build process
|
13
13
|
module Version
|
14
14
|
MAJOR = 6 # breaking,
|
15
|
-
MINOR =
|
16
|
-
PATCH =
|
15
|
+
MINOR = 1 # feature,
|
16
|
+
PATCH = 0 # fix => BFF
|
17
17
|
PRE = nil
|
18
18
|
|
19
19
|
STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solarwinds_apm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0
|
4
|
+
version: 6.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maia Engeli
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2024-
|
14
|
+
date: 2024-09-18 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: opentelemetry-instrumentation-all
|
@@ -41,20 +41,6 @@ dependencies:
|
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: 1.2.0
|
44
|
-
- !ruby/object:Gem::Dependency
|
45
|
-
name: json
|
46
|
-
requirement: !ruby/object:Gem::Requirement
|
47
|
-
requirements:
|
48
|
-
- - "~>"
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: '2.0'
|
51
|
-
type: :runtime
|
52
|
-
prerelease: false
|
53
|
-
version_requirements: !ruby/object:Gem::Requirement
|
54
|
-
requirements:
|
55
|
-
- - "~>"
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version: '2.0'
|
58
44
|
description: Automatic tracing and metrics for Ruby applications. Get started at cloud.solarwinds.com
|
59
45
|
email: technicalsupport@solarwinds.com
|
60
46
|
executables: []
|
@@ -63,7 +49,9 @@ extensions:
|
|
63
49
|
extra_rdoc_files:
|
64
50
|
- LICENSE
|
65
51
|
files:
|
52
|
+
- ".yardopts"
|
66
53
|
- LICENSE
|
54
|
+
- README.md
|
67
55
|
- ext/oboe_metal/extconf.rb
|
68
56
|
- ext/oboe_metal/lib/liboboe-1.0-aarch64.so.sha256
|
69
57
|
- ext/oboe_metal/lib/liboboe-1.0-alpine-aarch64.so.sha256
|
@@ -122,6 +110,7 @@ files:
|
|
122
110
|
- lib/solarwinds_apm/support/swomarginalia/LICENSE
|
123
111
|
- lib/solarwinds_apm/support/swomarginalia/README.md
|
124
112
|
- lib/solarwinds_apm/support/swomarginalia/comment.rb
|
113
|
+
- lib/solarwinds_apm/support/swomarginalia/formatter.rb
|
125
114
|
- lib/solarwinds_apm/support/swomarginalia/load_swomarginalia.rb
|
126
115
|
- lib/solarwinds_apm/support/swomarginalia/railtie.rb
|
127
116
|
- lib/solarwinds_apm/support/swomarginalia/swomarginalia.rb
|
@@ -139,7 +128,6 @@ metadata:
|
|
139
128
|
documentation_uri: https://documentation.solarwinds.com/en/success_center/observability/default.htm#cshid=config-ruby-agent
|
140
129
|
homepage_uri: https://documentation.solarwinds.com/en/success_center/observability/content/intro/landing-page.html
|
141
130
|
source_code_uri: https://github.com/solarwinds/apm-ruby
|
142
|
-
github_repo: https://github.com/solarwinds/apm-ruby.git
|
143
131
|
rubygems_mfa_required: 'true'
|
144
132
|
post_install_message:
|
145
133
|
rdoc_options: []
|