solarwinds_apm 5.1.9 → 6.0.0.preV1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +0 -1
- data/ext/oboe_metal/extconf.rb +19 -23
- 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-x86_64.so.sha256 +1 -1
- data/ext/oboe_metal/src/VERSION +1 -1
- data/ext/oboe_metal/src/oboe_debug.h +1 -0
- data/lib/oboe_metal.rb +116 -80
- data/lib/rails/generators/solarwinds_apm/install_generator.rb +1 -2
- data/lib/rails/generators/solarwinds_apm/templates/solarwinds_apm_initializer.rb +44 -260
- data/lib/solarwinds_apm/api/current_trace_info.rb +148 -0
- data/lib/solarwinds_apm/api/tracing.rb +30 -0
- data/lib/solarwinds_apm/api/transaction_name.rb +57 -0
- data/lib/solarwinds_apm/api.rb +8 -15
- data/lib/solarwinds_apm/base.rb +4 -131
- data/lib/solarwinds_apm/config.rb +128 -175
- data/lib/solarwinds_apm/constants.rb +32 -0
- data/lib/solarwinds_apm/logger.rb +1 -1
- data/lib/solarwinds_apm/noop/context.rb +2 -5
- data/lib/solarwinds_apm/noop/metadata.rb +1 -2
- data/lib/solarwinds_apm/noop/profiling.rb +3 -7
- data/lib/solarwinds_apm/oboe_init_options.rb +71 -33
- data/lib/solarwinds_apm/opentelemetry/solarwinds_exporter.rb +204 -0
- data/lib/solarwinds_apm/opentelemetry/solarwinds_processor.rb +163 -0
- data/lib/solarwinds_apm/opentelemetry/solarwinds_propagator.rb +92 -0
- data/lib/solarwinds_apm/opentelemetry/solarwinds_response_propagator.rb +72 -0
- data/lib/solarwinds_apm/opentelemetry/solarwinds_sampler.rb +330 -0
- data/lib/solarwinds_apm/opentelemetry.rb +8 -0
- data/lib/solarwinds_apm/otel_config.rb +161 -0
- data/lib/solarwinds_apm/{inst → support}/logger_formatter.rb +5 -6
- data/lib/solarwinds_apm/{inst → support}/logging_log_event.rb +3 -6
- data/lib/solarwinds_apm/{inst → support}/lumberjack_formatter.rb +1 -4
- data/lib/solarwinds_apm/support/oboe_tracing_mode.rb +27 -0
- data/lib/solarwinds_apm/support/swomarginalia/LICENSE +20 -0
- data/lib/solarwinds_apm/support/swomarginalia/README.md +41 -0
- data/lib/solarwinds_apm/support/swomarginalia/comment.rb +205 -0
- data/lib/solarwinds_apm/support/swomarginalia/load_swomarginalia.rb +48 -0
- data/lib/solarwinds_apm/support/swomarginalia/railtie.rb +22 -0
- data/lib/solarwinds_apm/support/swomarginalia/swomarginalia.rb +86 -0
- data/lib/solarwinds_apm/support/transaction_cache.rb +24 -0
- data/lib/solarwinds_apm/support/transaction_settings.rb +26 -209
- data/lib/solarwinds_apm/support/transformer.rb +56 -0
- data/lib/solarwinds_apm/support/txn_name_manager.rb +25 -0
- data/lib/solarwinds_apm/support/x_trace_options.rb +42 -26
- data/lib/solarwinds_apm/support.rb +33 -10
- data/lib/solarwinds_apm/support_report.rb +10 -32
- data/lib/solarwinds_apm/thread_local.rb +1 -1
- data/lib/solarwinds_apm/version.rb +4 -4
- data/lib/solarwinds_apm.rb +31 -26
- metadata +76 -121
- data/.dockerignore +0 -5
- data/.gitignore +0 -58
- data/.rubocop.yml +0 -29
- data/.whitesource +0 -22
- data/.yardopts +0 -7
- data/CHANGELOG-appoptics.md +0 -766
- data/CHANGELOG.md +0 -82
- data/CONFIG.md +0 -31
- data/Gemfile +0 -15
- data/README.md +0 -385
- data/bin/solarwinds_apm_config +0 -15
- data/examples/prepend.rb +0 -13
- data/examples/sdk_examples.rb +0 -158
- data/ext/oboe_metal/README.md +0 -69
- data/ext/oboe_metal/extconf_local.rb +0 -75
- data/ext/oboe_metal/lib/.keep +0 -0
- data/ext/oboe_metal/noop/noop.c +0 -8
- data/ext/oboe_metal/src/README.md +0 -6
- data/ext/oboe_metal/src/frames.cc +0 -247
- data/ext/oboe_metal/src/frames.h +0 -40
- data/ext/oboe_metal/src/logging.cc +0 -97
- data/ext/oboe_metal/src/logging.h +0 -34
- data/ext/oboe_metal/src/profiling.cc +0 -435
- data/ext/oboe_metal/src/profiling.h +0 -78
- data/ext/oboe_metal/test/CMakeLists.txt +0 -53
- data/ext/oboe_metal/test/FindGMock.cmake +0 -43
- data/ext/oboe_metal/test/README.md +0 -56
- data/ext/oboe_metal/test/frames_test.cc +0 -164
- data/ext/oboe_metal/test/profiling_test.cc +0 -93
- data/ext/oboe_metal/test/ruby_inc_dir.rb +0 -8
- data/ext/oboe_metal/test/ruby_prefix.rb +0 -8
- data/ext/oboe_metal/test/ruby_test_helper.rb +0 -67
- data/ext/oboe_metal/test/test.h +0 -11
- data/ext/oboe_metal/test/test_main.cc +0 -32
- data/init.rb +0 -4
- data/lib/solarwinds_apm/api/layerinit.rb +0 -41
- data/lib/solarwinds_apm/api/logging.rb +0 -356
- data/lib/solarwinds_apm/api/memcache.rb +0 -37
- data/lib/solarwinds_apm/api/metrics.rb +0 -63
- data/lib/solarwinds_apm/api/util.rb +0 -98
- data/lib/solarwinds_apm/frameworks/grape.rb +0 -96
- data/lib/solarwinds_apm/frameworks/padrino.rb +0 -78
- data/lib/solarwinds_apm/frameworks/rails/inst/action_controller.rb +0 -100
- data/lib/solarwinds_apm/frameworks/rails/inst/action_controller5.rb +0 -50
- data/lib/solarwinds_apm/frameworks/rails/inst/action_controller_api.rb +0 -50
- data/lib/solarwinds_apm/frameworks/rails/inst/action_view.rb +0 -88
- data/lib/solarwinds_apm/frameworks/rails/inst/active_record.rb +0 -26
- data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/mysql2.rb +0 -29
- data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/postgresql.rb +0 -22
- data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/utils5x.rb +0 -103
- data/lib/solarwinds_apm/frameworks/rails/inst/logger_formatters.rb +0 -14
- data/lib/solarwinds_apm/frameworks/rails.rb +0 -100
- data/lib/solarwinds_apm/frameworks/sinatra.rb +0 -96
- data/lib/solarwinds_apm/inst/bunny-client.rb +0 -157
- data/lib/solarwinds_apm/inst/bunny-consumer.rb +0 -102
- data/lib/solarwinds_apm/inst/curb.rb +0 -289
- data/lib/solarwinds_apm/inst/dalli.rb +0 -89
- data/lib/solarwinds_apm/inst/delayed_job.rb +0 -100
- data/lib/solarwinds_apm/inst/excon.rb +0 -113
- data/lib/solarwinds_apm/inst/faraday.rb +0 -96
- data/lib/solarwinds_apm/inst/graphql.rb +0 -206
- data/lib/solarwinds_apm/inst/grpc_client.rb +0 -147
- data/lib/solarwinds_apm/inst/grpc_server.rb +0 -119
- data/lib/solarwinds_apm/inst/httpclient.rb +0 -182
- data/lib/solarwinds_apm/inst/memcached.rb +0 -86
- data/lib/solarwinds_apm/inst/mongo.rb +0 -246
- data/lib/solarwinds_apm/inst/mongo2.rb +0 -225
- data/lib/solarwinds_apm/inst/moped.rb +0 -466
- data/lib/solarwinds_apm/inst/net_http.rb +0 -60
- data/lib/solarwinds_apm/inst/rack.rb +0 -223
- data/lib/solarwinds_apm/inst/rack_cache.rb +0 -35
- data/lib/solarwinds_apm/inst/redis.rb +0 -280
- data/lib/solarwinds_apm/inst/redis_v4.rb +0 -273
- data/lib/solarwinds_apm/inst/resque.rb +0 -129
- data/lib/solarwinds_apm/inst/rest-client.rb +0 -43
- data/lib/solarwinds_apm/inst/sequel.rb +0 -241
- data/lib/solarwinds_apm/inst/sidekiq-client.rb +0 -63
- data/lib/solarwinds_apm/inst/sidekiq-worker.rb +0 -64
- data/lib/solarwinds_apm/inst/typhoeus.rb +0 -90
- data/lib/solarwinds_apm/instrumentation.rb +0 -22
- data/lib/solarwinds_apm/loading.rb +0 -65
- data/lib/solarwinds_apm/ruby.rb +0 -35
- data/lib/solarwinds_apm/sdk/current_trace_info.rb +0 -123
- data/lib/solarwinds_apm/sdk/custom_metrics.rb +0 -94
- data/lib/solarwinds_apm/sdk/logging.rb +0 -37
- data/lib/solarwinds_apm/sdk/trace_context_headers.rb +0 -69
- data/lib/solarwinds_apm/sdk/tracing.rb +0 -432
- data/lib/solarwinds_apm/support/profiling.rb +0 -25
- data/lib/solarwinds_apm/support/trace_context.rb +0 -53
- data/lib/solarwinds_apm/support/trace_state.rb +0 -69
- data/lib/solarwinds_apm/support/trace_string.rb +0 -89
- data/lib/solarwinds_apm/support/transaction_metrics.rb +0 -67
- data/lib/solarwinds_apm/test.rb +0 -165
- data/lib/solarwinds_apm/util.rb +0 -426
- data/log/.keep +0 -0
- data/log/postgresql/.keep +0 -0
- data/solarwinds_apm.gemspec +0 -55
- data/yardoc_frontpage.md +0 -24
data/CHANGELOG.md
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
For the latest release info, see here:
|
2
|
-
https://github.com/solarwindscloud/solarwinds-apm-ruby/releases
|
3
|
-
|
4
|
-
Dates in this file are in the format MM/DD/YYYY.
|
5
|
-
|
6
|
-
# solarwinds_apm 5.1.9 (05/025/2023)
|
7
|
-
|
8
|
-
This release includes the following features:
|
9
|
-
|
10
|
-
* Update latest liboboe library (12.3.0)
|
11
|
-
|
12
|
-
Pushed to Rubygems:
|
13
|
-
|
14
|
-
https://rubygems.org/gems/solarwinds_apm/versions/5.1.9
|
15
|
-
|
16
|
-
# solarwinds_apm 5.1.8 (05/09/2023)
|
17
|
-
|
18
|
-
This release includes the following features:
|
19
|
-
|
20
|
-
* Update latest liboboe library (12.2.0)
|
21
|
-
|
22
|
-
Pushed to Rubygems:
|
23
|
-
|
24
|
-
https://rubygems.org/gems/solarwinds_apm/versions/5.1.8
|
25
|
-
|
26
|
-
# solarwinds_apm 5.1.7 (03/14/2023)
|
27
|
-
|
28
|
-
This release includes the following features:
|
29
|
-
|
30
|
-
* Update latest liboboe library (12.1.0)
|
31
|
-
|
32
|
-
Pushed to Rubygems:
|
33
|
-
|
34
|
-
https://rubygems.org/gems/solarwinds_apm/versions/5.1.7
|
35
|
-
|
36
|
-
# solarwinds_apm 5.1.6 (03/14/2023)
|
37
|
-
|
38
|
-
This release includes the following features:
|
39
|
-
|
40
|
-
* Update latest liboboe library (12.0.0)
|
41
|
-
* Remove centos as testing environments and include amazonlinux as alternatives of RHEL distro
|
42
|
-
* Include sanitize RemoteURL for kvs (p.s. RemoteHost is sanitized in library code)
|
43
|
-
|
44
|
-
Pushed to Rubygems:
|
45
|
-
|
46
|
-
https://rubygems.org/gems/solarwinds_apm/versions/5.1.6
|
47
|
-
|
48
|
-
|
49
|
-
# solarwinds_apm 5.1.4 (11/23/2022)
|
50
|
-
|
51
|
-
This release includes the following features:
|
52
|
-
|
53
|
-
* Update to the latest redis-rb gem (> 5.x)
|
54
|
-
* Update latest liboboe library (11.1.0)
|
55
|
-
* Start to support solarwinds-apm-ruby arm64/aarch64
|
56
|
-
* Init message update for swo/nh backends
|
57
|
-
|
58
|
-
Pushed to Rubygems:
|
59
|
-
|
60
|
-
https://rubygems.org/gems/solarwinds_apm/versions/5.1.4
|
61
|
-
|
62
|
-
|
63
|
-
# solarwinds_apm 5.1.0 (09/15/2022)
|
64
|
-
|
65
|
-
This release includes the following features:
|
66
|
-
|
67
|
-
* Using latest liboboe library (10.6.1)
|
68
|
-
|
69
|
-
Pushed to Rubygems:
|
70
|
-
|
71
|
-
https://rubygems.org/gems/solarwinds_apm/versions/5.1.0
|
72
|
-
|
73
|
-
|
74
|
-
# solarwinds_apm 5.0.0 (09/15/2022)
|
75
|
-
|
76
|
-
This release includes the following features:
|
77
|
-
|
78
|
-
* Migrated Github repo
|
79
|
-
|
80
|
-
Pushed to Rubygems:
|
81
|
-
|
82
|
-
https://rubygems.org/gems/solarwinds_apm/versions/5.0.0
|
data/CONFIG.md
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# SolarWindsAPM Gem Configuration
|
2
|
-
|
3
|
-
## Environment Variables
|
4
|
-
|
5
|
-
The following environment variables are detected by the solarwinds_apm gem and affect how the gem functions.
|
6
|
-
|
7
|
-
### General
|
8
|
-
|
9
|
-
Name | Description | Default
|
10
|
-
---- | ----------- | -------
|
11
|
-
`SW_APM_SERVICE_KEY` | API token + service name combination, mandatory for metrics and traces to show in the dashboard |
|
12
|
-
`SW_APM_GEM_VERBOSE` | sets the verbose flag (`SolarWindsAPM::Config[:verbose]`) early in the gem loading process which may output valuable information | `false`
|
13
|
-
`SW_APM_NO_LIBRARIES_WARNING` | tells the solarwinds_apm gem to __not__ output the _missing SolarWindsAPM libraries_ message on stack initialization | `false`
|
14
|
-
|
15
|
-
# Related to Tests
|
16
|
-
|
17
|
-
Name | Description | Default
|
18
|
-
---- | ----------- | -------
|
19
|
-
`SW_APM_GEM_TEST` | puts the gem in test mode to avoid restarting certain background services used in testing. `false`
|
20
|
-
`DBTYPE` | For tests on Ruby on Rails, specifies the database type to test against. `postgres`, `mysql` and `mysql2` are valid options. | `postgres`
|
21
|
-
`MONGO_SERVER` | specifies the Mongo server to test against. | `127.0.0.1:27017`
|
22
|
-
`RABBITMQ_SERVER` | specifies the RabbitMQ server to test against. | `127.0.0.1`
|
23
|
-
`RABBITMQ_PORT` | port for the RabbitMQ connection. | `5672`
|
24
|
-
`RABBITMQ_USERNAME` | username for the RabbitMQ connection | `guest`
|
25
|
-
`RABBITMQ_PASSWORD` | password for the RabbitMQ connection | `guest`
|
26
|
-
|
27
|
-
## SolarWindsAPM::Config
|
28
|
-
|
29
|
-
`SolarWindsAPM::Config` is a nested hash used by the solarwinds_apm gem to store preferences and switches.
|
30
|
-
|
31
|
-
See [this Rails generator template file](https://github.com/librato/ruby-solarwinds/blob/master/lib/rails/generators/solarwinds_apm/templates/sw_apm_initializer.rb) for documentation on all of the supported values.
|
data/Gemfile
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# this Gemfile is very minimal
|
4
|
-
# use rake commands or gemfiles in the gemfiles directory for testing
|
5
|
-
|
6
|
-
gem 'rake', '>= 0.9.0'
|
7
|
-
|
8
|
-
group :development, :test do
|
9
|
-
gem 'byebug', '>= 8.0.0'
|
10
|
-
gem 'irb', '>= 1.0.0' # if RUBY_VERSION >= '2.6.0'
|
11
|
-
gem 'memory_profiler'
|
12
|
-
gem 'package_cloud'
|
13
|
-
end
|
14
|
-
|
15
|
-
gemspec
|
data/README.md
DELETED
@@ -1,385 +0,0 @@
|
|
1
|
-
# Welcome to the SolarWindsAPM Ruby Gem
|
2
|
-
|
3
|
-
The solarwinds_apm gem provides [SolarWindsAPM](https://cloud.solarwinds.com/) performance instrumentation for Ruby.
|
4
|
-
|
5
|
-
It has the ability to report performance metrics on an array of libraries, databases and frameworks such as Rails,
|
6
|
-
Rack, ActiveRecord, Mongo, Memcache, Resque
|
7
|
-
[and more](https://documentation.solarwinds.com/en/success_center/observability/default.htm#cshid=config-ruby-agent).
|
8
|
-
|
9
|
-
It requires an [Solarwinds] account to view metrics. Get yours,
|
10
|
-
[it's free](https://cloud.solarwinds.com).
|
11
|
-
|
12
|
-
[![Gem Version](https://badge.fury.io/rb/solarwinds_apm.svg)](https://badge.fury.io/rb/solarwinds_apm)
|
13
|
-
|
14
|
-
[![Run All Tests](https://github.com/solarwindscloud/solarwinds-apm-ruby/actions/workflows/test_on_4_linux.yml/badge.svg)](https://github.com/solarwindscloud/solarwinds-apm-ruby/actions/workflows/test_on_4_linux.yml)
|
15
|
-
|
16
|
-
[![C++ Tests](https://github.com/solarwindscloud/solarwinds-apm-ruby/actions/workflows/run_cpluplus_tests.yml/badge.svg)](https://github.com/solarwindscloud/solarwinds-apm-ruby/actions/workflows/run_cpluplus_tests.yml)
|
17
|
-
|
18
|
-
[comment]: <> ([![Maintainability](https://api.codeclimate.com/v1/badges/ac7f36241a23a3a82fc5/maintainability)](https://codeclimate.com/github/appoptics/appoptics-apm-ruby/maintainability))
|
19
|
-
|
20
|
-
# Documentation
|
21
|
-
|
22
|
-
* [SolarWindsAPM Knowledge Base](https://documentation.solarwinds.com/en/success_center/observability/default.htm#cshid=config-ruby-agent)
|
23
|
-
|
24
|
-
# Installation
|
25
|
-
|
26
|
-
_Before installing the gem below, make sure that you have the
|
27
|
-
[dependencies](https://documentation.solarwinds.com/en/success_center/observability/default.htm#cshid=config-ruby-install) installed on your host first._
|
28
|
-
|
29
|
-
The solarwinds_apm gem is [available on Rubygems](https://rubygems.org/gems/solarwinds_apm) and can be installed with:
|
30
|
-
|
31
|
-
```bash
|
32
|
-
gem install solarwinds_apm
|
33
|
-
```
|
34
|
-
|
35
|
-
or added to **the end** of your Gemfile and running `bundle install`:
|
36
|
-
|
37
|
-
```ruby
|
38
|
-
gem 'solarwinds_apm'
|
39
|
-
```
|
40
|
-
|
41
|
-
# Running
|
42
|
-
|
43
|
-
Make sure to set `SW_APM_SERVICE_KEY` in the environment from where the app or service is run, e.g:
|
44
|
-
```
|
45
|
-
export SW_APM_SERVICE_KEY=795fb4947d15275d208c49cfd2412d4a5bf38742045b47236c94c4fe5f5b17c7:<your_app_name>
|
46
|
-
```
|
47
|
-
|
48
|
-
## Rails
|
49
|
-
|
50
|
-
No special steps are needed to instrument Ruby on Rails. Once part of the bundle, the solarwinds-apm gem will automatically
|
51
|
-
detect Rails and instrument on stack initialization.
|
52
|
-
|
53
|
-
### The Install Generator
|
54
|
-
|
55
|
-
The solarwinds_apm gem provides a Rails generator used to seed an initializer where you can configure and control
|
56
|
-
`tracing_mode` and [other options](https://documentation.solarwinds.com/en/success_center/observability/default.htm#cshid=config-ruby-config-file).
|
57
|
-
|
58
|
-
To run the install generator run:
|
59
|
-
|
60
|
-
```bash
|
61
|
-
bundle exec rails generate solarwinds_apm:install
|
62
|
-
```
|
63
|
-
|
64
|
-
After the prompts, this will create an initializer: `config/initializers/solarwinds_apm.rb`.
|
65
|
-
|
66
|
-
## Sinatra
|
67
|
-
|
68
|
-
You can instrument your Sinatra application by adding the following code to your `config.ru` Rackup file:
|
69
|
-
|
70
|
-
```ruby
|
71
|
-
# If you're not using Bundler.require. Make sure this is done
|
72
|
-
# after the Sinatra require directive.
|
73
|
-
require 'solarwinds_apm'
|
74
|
-
```
|
75
|
-
|
76
|
-
Make sure that the solarwinds_apm gem is loaded _after_ Sinatra either by listing `gem 'solarwinds_apm'` after Sinatra in
|
77
|
-
your Gemfile or calling the `require 'solarwinds_gem'` directive after Sinatra is loaded.
|
78
|
-
|
79
|
-
With this, the solarwinds_apm gem will automatically detect Sinatra on boot and instrument key components.
|
80
|
-
|
81
|
-
## Padrino
|
82
|
-
|
83
|
-
As long as the solarwinds_apm gem is in your `Gemfile` (inserted after the `gem 'padrino'` directive) and you are calling
|
84
|
-
`Bundler.require`, the solarwinds_apm gem will automatically instrument Padrino applications.
|
85
|
-
|
86
|
-
If you need to set `SolarWindsAPM::Config` values on stack boot, you can do so by adding the following
|
87
|
-
to your `config/boot.rb` file:
|
88
|
-
|
89
|
-
```ruby
|
90
|
-
Padrino.before_load do
|
91
|
-
# Verbose output of instrumentation initialization
|
92
|
-
SolarWindsAPM
|
93
|
-
end
|
94
|
-
```
|
95
|
-
|
96
|
-
## Grape
|
97
|
-
|
98
|
-
You can instrument your Grape application by adding the following code to your `config.ru` Rackup file:
|
99
|
-
|
100
|
-
```ruby
|
101
|
-
# If you're not using Bundler.require. Make sure this is done
|
102
|
-
# after the Grape require directive.
|
103
|
-
require 'solarwinds_apm'
|
104
|
-
|
105
|
-
...
|
106
|
-
|
107
|
-
class App < Grape::API
|
108
|
-
use SolarWindsAPM::Rack
|
109
|
-
end
|
110
|
-
```
|
111
|
-
|
112
|
-
Make sure that the solarwinds gem is loaded _after_ Grape either by listing `gem 'solarwinds_apm'` after Grape in your
|
113
|
-
Gemfile or calling the `require 'solarwinds_apm'` directive after Grape is loaded.
|
114
|
-
|
115
|
-
You must explicitly tell your Grape application to use SolarWindsAPM::Rack for tracing to occur.
|
116
|
-
|
117
|
-
|
118
|
-
# SDK for Custom Tracing
|
119
|
-
|
120
|
-
The solarwinds_apm gem has the ability to instrument any arbitrary Ruby application or script.
|
121
|
-
|
122
|
-
```ruby
|
123
|
-
require 'rubygems'
|
124
|
-
require 'bundler'
|
125
|
-
|
126
|
-
Bundler.require
|
127
|
-
|
128
|
-
require 'solarwinds_apm'
|
129
|
-
```
|
130
|
-
|
131
|
-
You can add even more visibility into any part of your application or scripts by adding custom instrumentation.
|
132
|
-
|
133
|
-
## SolarWindsAPM::SDK.trace
|
134
|
-
You can instrument any arbitrary block of code using `SolarWindsAPM::SDK.trace`.
|
135
|
-
|
136
|
-
```ruby
|
137
|
-
# layer_name will show up in the SolarWinds dashboard
|
138
|
-
layer_name = 'subsystemX'
|
139
|
-
|
140
|
-
# report_kvs are a set of information Key/Value pairs that are sent to
|
141
|
-
# SolarWinds dashboard along with the performance metrics. These KV
|
142
|
-
# pairs are used to report request, environment and/or client specific
|
143
|
-
# information.
|
144
|
-
|
145
|
-
report_kvs = {}
|
146
|
-
report_kvs[:mykey] = @client.id
|
147
|
-
|
148
|
-
SolarWindsAPM::SDK.trace(layer_name, kvs: report_kvs) do
|
149
|
-
# the block of code to be traced
|
150
|
-
end
|
151
|
-
```
|
152
|
-
|
153
|
-
`SolarWindsAPM::SDK.trace` is used within the context of a request. It will follow the upstream state of the request
|
154
|
-
being traced. i.e. the block of code will only be traced when the parent request is being traced.
|
155
|
-
|
156
|
-
This tracing state of a request can also be queried by using `SolarWindsAPM.tracing?`.
|
157
|
-
|
158
|
-
## SolarWindsAPM::SDK.start_trace
|
159
|
-
|
160
|
-
If you need to instrument code outside the context of a request (such as a cron job, background job or an arbitrary
|
161
|
-
ruby script), use `SolarWindsAPM::SDK.start_trace` instead which will initiate a new trace based on configuration and
|
162
|
-
probability (based on the sample rate).
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
### Example
|
167
|
-
|
168
|
-
```ruby
|
169
|
-
require 'rubygems'
|
170
|
-
require 'bundler'
|
171
|
-
|
172
|
-
Bundler.require
|
173
|
-
|
174
|
-
# Make sure solarwinds_apm is at the bottom of your Gemfile.
|
175
|
-
# This is likely redundant but just in case.
|
176
|
-
require 'solarwinds_apm'
|
177
|
-
|
178
|
-
|
179
|
-
# Tracing mode can be :enabled or :disabled
|
180
|
-
SolarWindsAPM::Config[:tracing_mode] = :enabled
|
181
|
-
|
182
|
-
#
|
183
|
-
# Update April 9, 2015 - this is done automagically now
|
184
|
-
# and doesn't have to be called manually
|
185
|
-
#
|
186
|
-
# Load library instrumentation to auto-capture stuff we know about...
|
187
|
-
# e.g. ActiveRecord, Dalli, Redis, memcache, mongo
|
188
|
-
# TraceView::Ruby.load
|
189
|
-
|
190
|
-
# Some KVs to report to the dashboard
|
191
|
-
report_kvs = {}
|
192
|
-
report_kvs[:command_line_params] = ARGV.to_s
|
193
|
-
report_kvs[:user_id] = `whoami`
|
194
|
-
|
195
|
-
SolarWindsAPM::SDK.start_trace('my_background_job', kvs: report_kvs) do
|
196
|
-
#
|
197
|
-
# Initialization code
|
198
|
-
#
|
199
|
-
|
200
|
-
tasks = get_all_tasks
|
201
|
-
|
202
|
-
tasks.each do |t|
|
203
|
-
# Optional: Here we embed another 'trace' to separate actual
|
204
|
-
# work for each task. In the traces dashboard this will show
|
205
|
-
# up as a large 'my_background_job' parent layer with many
|
206
|
-
# child 'task' layers.
|
207
|
-
SolarWindsAPM::SDK.trace('task', kvs: { :task_id => t.id }) do
|
208
|
-
t.perform
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
#
|
213
|
-
# cleanup code
|
214
|
-
#
|
215
|
-
end
|
216
|
-
|
217
|
-
|
218
|
-
# Note that we use 'start_trace' in the outer block and 'trace' for
|
219
|
-
# any sub-blocks of code we wish to instrument. The arguments for
|
220
|
-
# both methods vary slightly.
|
221
|
-
```
|
222
|
-
|
223
|
-
Find more details in the [RubyDoc page](https://www.rubydoc.info/gems/solarwinds_apm/SolarWindsAPM/SDK) on how to use the Tracing SDK in an independent Ruby script.
|
224
|
-
|
225
|
-
# Support
|
226
|
-
|
227
|
-
If you run into a problem, find a bug, or would like to request an enhancement, feel free to contact our tech support
|
228
|
-
[technicalsupport@solarwinds.com](technicalsupport@solarwinds.com).
|
229
|
-
|
230
|
-
# Contributing
|
231
|
-
|
232
|
-
You are obviously a person of great sense and intelligence. We happily appreciate all contributions to the solarwinds_apm
|
233
|
-
gem whether it is documentation, a bug fix, new instrumentation for a library or framework or anything else we haven't
|
234
|
-
thought of.
|
235
|
-
|
236
|
-
We welcome you to send us PRs. We also humbly request that any new instrumentation submissions have corresponding tests
|
237
|
-
that accompany them. This way we don't break any of your additions when we (and others) make changes after the fact.
|
238
|
-
|
239
|
-
|
240
|
-
## Layout of the Gem
|
241
|
-
|
242
|
-
The solarwinds_apm gem uses a standard gem layout. Here are the notable directories.
|
243
|
-
|
244
|
-
lib/solarwinds_apm/inst # Auto load directory for various instrumented libraries
|
245
|
-
lib/solarwinds_apm/frameworks # Framework instrumentation directory
|
246
|
-
lib/solarwinds_apm/frameworks/rails # Files specific to Rails instrumentation
|
247
|
-
lib/rails # A Rails required directory for the Rails install generator
|
248
|
-
lib/api # The SolarWindsAPM Tracing API: layers, logging, tracing
|
249
|
-
ext/oboe_metal # The Ruby c extension that links against the system liboboe library
|
250
|
-
|
251
|
-
## Building the Gem
|
252
|
-
|
253
|
-
The solarwinds_apm gem is built with the standard `gem build` command passing in the gemspec:
|
254
|
-
|
255
|
-
```bash
|
256
|
-
gem build solarwinds_apm.gemspec
|
257
|
-
```
|
258
|
-
|
259
|
-
## Writing Custom Instrumentation
|
260
|
-
|
261
|
-
Custom instrumentation for a library, database or other service can be authored fairly easily. Generally,
|
262
|
-
instrumentation of a library is done by wrapping select operations of that library and timing their execution using the
|
263
|
-
SolarWindsAPM Tracing SDK which then reports the metrics to the users' SolarWinds dashboard.
|
264
|
-
|
265
|
-
Here, I'll use a stripped down version of the Dalli instrumentation (`lib/solarwinds_apm/inst/dalli.rb`) as a quick example
|
266
|
-
of how to instrument a client library (the dalli gem).
|
267
|
-
|
268
|
-
The Dalli gem nicely routes all memcache operations through a single `perform` operation. Wrapping this method allows
|
269
|
-
us to capture all Dalli operations called by an application.
|
270
|
-
|
271
|
-
First, we define a module (SolarWindsAPM::Inst::Dalli) and our own custom `perform_with_sw_apm` method that we will
|
272
|
-
use as a wrapper around Dalli's `perform` method. We also declare an `included` method which automatically gets called
|
273
|
-
when this module is included by another.
|
274
|
-
See [`Module#included` Ruby reference documentation](https://devdocs.io/ruby~2.5/module#method-i-included).
|
275
|
-
|
276
|
-
```ruby
|
277
|
-
module SolarWindsAPM
|
278
|
-
module Inst
|
279
|
-
module Dalli
|
280
|
-
include SolarWindsAPM::API::Memcache
|
281
|
-
|
282
|
-
def self.included(cls)
|
283
|
-
cls.class_eval do
|
284
|
-
if ::Dalli::Client.private_method_defined? :perform
|
285
|
-
alias perform_without_sw_apm perform
|
286
|
-
alias perform perform_with_sw_apm
|
287
|
-
end
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
|
-
def perform_with_sw_apm(*all_args, &blk)
|
292
|
-
op, key, *args = *all_args
|
293
|
-
|
294
|
-
if SolarWindsAPM.tracing?
|
295
|
-
opts = {}
|
296
|
-
opts[:KVOp] = op
|
297
|
-
opts[:KVKey] = key
|
298
|
-
|
299
|
-
SolarWindsAPM::SDK.trace('memcache', kvs: opts) do
|
300
|
-
result = perform_without_sw_apm(*all_args, &blk)
|
301
|
-
if op == :get and key.class == String
|
302
|
-
SolarWindsAPM::API.log_info('memcache', { :KVHit => memcache_hit?(result) })
|
303
|
-
end
|
304
|
-
result
|
305
|
-
end
|
306
|
-
else
|
307
|
-
perform_without_sw_apm(*all_args, &blk)
|
308
|
-
end
|
309
|
-
end
|
310
|
-
|
311
|
-
end
|
312
|
-
end
|
313
|
-
end
|
314
|
-
```
|
315
|
-
|
316
|
-
Second, we tail onto the end of the instrumentation file a simple `::Dalli::Client.module_eval` call to tell the Dalli
|
317
|
-
module to include our newly defined instrumentation module. Doing this will invoke our previously defined `included` method.
|
318
|
-
|
319
|
-
```ruby
|
320
|
-
if defined?(Dalli) and SolarWindsAPM::Config[:dalli][:enabled]
|
321
|
-
::Dalli::Client.module_eval do
|
322
|
-
include SolarWindsAPM::Inst::Dalli
|
323
|
-
end
|
324
|
-
end
|
325
|
-
```
|
326
|
-
|
327
|
-
Third, in our wrapper method, we capture the arguments passed in, collect the operation and key information into a local
|
328
|
-
hash and then invoke the `SolarWindsAPM::SDK.trace` method to time the execution of the original operation.
|
329
|
-
|
330
|
-
The `SolarWindsAPM::SDK.trace` method calls Dalli's native operation and reports the timing metrics and your custom
|
331
|
-
`report_kvs` up to SolarWinds servers to be shown on the user's dashboard.
|
332
|
-
|
333
|
-
Some other tips and guidelines:
|
334
|
-
|
335
|
-
* You can point your Gemfile directly at your cloned solarwinds_apm gem source by using
|
336
|
-
`gem 'solarwinds_apm', :path => '/path/to/ruby-solarwinds'`
|
337
|
-
|
338
|
-
* If instrumenting a library, database or service, place your new instrumentation file into the `lib/solarwinds_apm/inst/`
|
339
|
-
directory. From there, the solarwinds_apm gem will detect it and automatically load the instrumentation file.
|
340
|
-
|
341
|
-
* If instrumenting a new framework, place your instrumentation file in `lib/solarwinds_apm/frameworks`. Refer to the Rails
|
342
|
-
instrumentation for on ideas on how to load the solarwinds_apm gem correctly in your framework.
|
343
|
-
|
344
|
-
* Review other existing instrumentation similar to the one you wish to author. `lib/solarwinds_apm/inst/` is a great place
|
345
|
-
to start.
|
346
|
-
|
347
|
-
* Depending on the configured `:sample_rate`, not all requests will be traced. Use `SolarWindsAPM.tracing?` to determine
|
348
|
-
of this is a request that is being traced.
|
349
|
-
|
350
|
-
* Performance is paramount. Make sure that your wrapped methods don't slow down users applications.
|
351
|
-
|
352
|
-
* Include tests with your instrumentation. See `test/instrumentation/` for some examples of existing instrumentation
|
353
|
-
tests.
|
354
|
-
|
355
|
-
## Compiling the C extension
|
356
|
-
|
357
|
-
The solarwinds_apm gem utilizes a C extension to interface with a core library bundled in with the gem which handles
|
358
|
-
reporting the trace and performance data back to SolarWinds servers.
|
359
|
-
|
360
|
-
C extensions are usually built on `gem install` but when working out of a local git repository, it's required that you
|
361
|
-
manually build this C extension for the gem to function.
|
362
|
-
|
363
|
-
To make this simpler, we've included a few rake tasks to automate this process:
|
364
|
-
|
365
|
-
```bash
|
366
|
-
rake clean # make sure no old stuff is around
|
367
|
-
rake fetch_oboe_file["stg"] # download c-files from staging
|
368
|
-
rake compile # Build the gem's c extension
|
369
|
-
```
|
370
|
-
|
371
|
-
To see the code related to the C extension, take a look at `ext/oboe_metal/extconf.rb` for details.
|
372
|
-
|
373
|
-
You can read more about Ruby gems with C extensions in the
|
374
|
-
[Rubygems Guides](http://guides.rubygems.org/gems-with-extensions/).
|
375
|
-
|
376
|
-
## Running the Tests
|
377
|
-
|
378
|
-
See the README in the test directory.
|
379
|
-
|
380
|
-
# License
|
381
|
-
|
382
|
-
Copyright (c) 2018 SolarWinds, LLC
|
383
|
-
|
384
|
-
Released under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
385
|
-
|
data/bin/solarwinds_apm_config
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
##
|
4
|
-
# execute this with `bundle exec solarwinds_apm_config`
|
5
|
-
# copies the configuration template file into the current directory
|
6
|
-
#
|
7
|
-
|
8
|
-
puts "Copying the configuration template file to solarwinds_apm_config_tmp.rb"
|
9
|
-
puts "Edit and save as solarwinds_apm_config.rb"
|
10
|
-
|
11
|
-
target_file = File.join(Dir.pwd, 'solarwinds_apm_config_tmp.rb')
|
12
|
-
temp_orig = File.join(File.dirname(File.dirname(__FILE__)),
|
13
|
-
'lib/rails/generators/solarwinds_apm/templates/solarwinds_apm_initializer.rb')
|
14
|
-
|
15
|
-
FileUtils.copy(temp_orig, target_file)
|
data/examples/prepend.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'solarwinds_apm'
|
2
|
-
|
3
|
-
module Measurements
|
4
|
-
def request(*args, &block)
|
5
|
-
req = args.first
|
6
|
-
SolarWindsAPM::SDK.summary_metric("request_size", req.to_hash.to_s.size)
|
7
|
-
resp = super
|
8
|
-
SolarWindsAPM::SDK.summary_metric("response_size", resp.to_hash.to_s.size)
|
9
|
-
return resp
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
Net::HTTP.send(:prepend, :Measurements)
|