solarwinds_apm 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.dockerignore +5 -0
- data/.github/ISSUE_TEMPLATE/bug-or-feature-request.md +16 -0
- data/.github/workflows/build_and_release_gem.yml +112 -0
- data/.github/workflows/build_for_packagecloud.yml +70 -0
- data/.github/workflows/docker-images.yml +47 -0
- data/.github/workflows/run_cpluplus_tests.yml +73 -0
- data/.github/workflows/run_tests.yml +155 -0
- data/.github/workflows/scripts/test_install.rb +23 -0
- data/.github/workflows/swig/swig-v4.0.2.tar.gz +0 -0
- data/.github/workflows/test_on_4_linux.yml +161 -0
- data/.gitignore +39 -0
- data/.rubocop.yml +29 -0
- data/.yardopts +7 -0
- data/CHANGELOG.md +769 -0
- data/CONFIG.md +31 -0
- data/Gemfile +14 -0
- data/LICENSE +202 -0
- data/README.md +383 -0
- data/bin/solarwinds_apm_config +15 -0
- data/examples/prepend.rb +13 -0
- data/examples/sdk_examples.rb +158 -0
- data/ext/oboe_metal/README.md +69 -0
- data/ext/oboe_metal/extconf.rb +141 -0
- data/ext/oboe_metal/extconf_local.rb +75 -0
- data/ext/oboe_metal/lib/.keep +0 -0
- data/ext/oboe_metal/lib/liboboe-1.0-alpine-x86_64.so.0.0.0.sha256 +1 -0
- data/ext/oboe_metal/lib/liboboe-1.0-x86_64.so.0.0.0.sha256 +1 -0
- data/ext/oboe_metal/noop/noop.c +8 -0
- data/ext/oboe_metal/src/README.md +6 -0
- data/ext/oboe_metal/src/VERSION +2 -0
- data/ext/oboe_metal/src/bson/bson.h +220 -0
- data/ext/oboe_metal/src/bson/platform_hacks.h +91 -0
- data/ext/oboe_metal/src/frames.cc +247 -0
- data/ext/oboe_metal/src/frames.h +40 -0
- data/ext/oboe_metal/src/init_solarwinds_apm.cc +21 -0
- data/ext/oboe_metal/src/logging.cc +95 -0
- data/ext/oboe_metal/src/logging.h +35 -0
- data/ext/oboe_metal/src/oboe.h +1169 -0
- data/ext/oboe_metal/src/oboe_api.cpp +658 -0
- data/ext/oboe_metal/src/oboe_api.hpp +433 -0
- data/ext/oboe_metal/src/oboe_debug.h +59 -0
- data/ext/oboe_metal/src/oboe_swig_wrap.cc +7562 -0
- data/ext/oboe_metal/src/profiling.cc +435 -0
- data/ext/oboe_metal/src/profiling.h +78 -0
- data/ext/oboe_metal/test/CMakeLists.txt +53 -0
- data/ext/oboe_metal/test/FindGMock.cmake +43 -0
- data/ext/oboe_metal/test/README.md +56 -0
- data/ext/oboe_metal/test/frames_test.cc +164 -0
- data/ext/oboe_metal/test/profiling_test.cc +93 -0
- data/ext/oboe_metal/test/ruby_inc_dir.rb +8 -0
- data/ext/oboe_metal/test/ruby_prefix.rb +8 -0
- data/ext/oboe_metal/test/ruby_test_helper.rb +67 -0
- data/ext/oboe_metal/test/test.h +11 -0
- data/ext/oboe_metal/test/test_main.cc +32 -0
- data/init.rb +4 -0
- data/lib/oboe.rb +7 -0
- data/lib/oboe_metal.rb +172 -0
- data/lib/rails/generators/solarwinds_apm/install_generator.rb +47 -0
- data/lib/rails/generators/solarwinds_apm/templates/solarwinds_apm_initializer.rb +424 -0
- data/lib/solarwinds_apm/api/layerinit.rb +41 -0
- data/lib/solarwinds_apm/api/logging.rb +356 -0
- data/lib/solarwinds_apm/api/memcache.rb +37 -0
- data/lib/solarwinds_apm/api/metrics.rb +63 -0
- data/lib/solarwinds_apm/api/util.rb +98 -0
- data/lib/solarwinds_apm/api.rb +21 -0
- data/lib/solarwinds_apm/base.rb +160 -0
- data/lib/solarwinds_apm/config.rb +301 -0
- data/lib/solarwinds_apm/frameworks/grape.rb +96 -0
- data/lib/solarwinds_apm/frameworks/padrino.rb +78 -0
- data/lib/solarwinds_apm/frameworks/rails/inst/action_controller.rb +100 -0
- data/lib/solarwinds_apm/frameworks/rails/inst/action_controller5.rb +50 -0
- data/lib/solarwinds_apm/frameworks/rails/inst/action_controller_api.rb +50 -0
- data/lib/solarwinds_apm/frameworks/rails/inst/action_view.rb +88 -0
- data/lib/solarwinds_apm/frameworks/rails/inst/active_record.rb +26 -0
- data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/mysql2.rb +29 -0
- data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/postgresql.rb +22 -0
- data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/utils5x.rb +103 -0
- data/lib/solarwinds_apm/frameworks/rails/inst/logger_formatters.rb +14 -0
- data/lib/solarwinds_apm/frameworks/rails.rb +100 -0
- data/lib/solarwinds_apm/frameworks/sinatra.rb +96 -0
- data/lib/solarwinds_apm/inst/bunny-client.rb +157 -0
- data/lib/solarwinds_apm/inst/bunny-consumer.rb +102 -0
- data/lib/solarwinds_apm/inst/curb.rb +288 -0
- data/lib/solarwinds_apm/inst/dalli.rb +89 -0
- data/lib/solarwinds_apm/inst/delayed_job.rb +100 -0
- data/lib/solarwinds_apm/inst/excon.rb +113 -0
- data/lib/solarwinds_apm/inst/faraday.rb +96 -0
- data/lib/solarwinds_apm/inst/graphql.rb +206 -0
- data/lib/solarwinds_apm/inst/grpc_client.rb +147 -0
- data/lib/solarwinds_apm/inst/grpc_server.rb +119 -0
- data/lib/solarwinds_apm/inst/httpclient.rb +181 -0
- data/lib/solarwinds_apm/inst/logger_formatter.rb +46 -0
- data/lib/solarwinds_apm/inst/logging_log_event.rb +24 -0
- data/lib/solarwinds_apm/inst/lumberjack_formatter.rb +9 -0
- data/lib/solarwinds_apm/inst/memcached.rb +86 -0
- data/lib/solarwinds_apm/inst/mongo.rb +246 -0
- data/lib/solarwinds_apm/inst/mongo2.rb +225 -0
- data/lib/solarwinds_apm/inst/moped.rb +466 -0
- data/lib/solarwinds_apm/inst/net_http.rb +60 -0
- data/lib/solarwinds_apm/inst/rack.rb +217 -0
- data/lib/solarwinds_apm/inst/rack_cache.rb +35 -0
- data/lib/solarwinds_apm/inst/redis.rb +273 -0
- data/lib/solarwinds_apm/inst/resque.rb +129 -0
- data/lib/solarwinds_apm/inst/rest-client.rb +43 -0
- data/lib/solarwinds_apm/inst/sequel.rb +241 -0
- data/lib/solarwinds_apm/inst/sidekiq-client.rb +63 -0
- data/lib/solarwinds_apm/inst/sidekiq-worker.rb +64 -0
- data/lib/solarwinds_apm/inst/typhoeus.rb +90 -0
- data/lib/solarwinds_apm/instrumentation.rb +22 -0
- data/lib/solarwinds_apm/loading.rb +65 -0
- data/lib/solarwinds_apm/logger.rb +14 -0
- data/lib/solarwinds_apm/noop/README.md +9 -0
- data/lib/solarwinds_apm/noop/context.rb +26 -0
- data/lib/solarwinds_apm/noop/metadata.rb +25 -0
- data/lib/solarwinds_apm/noop/profiling.rb +21 -0
- data/lib/solarwinds_apm/oboe_init_options.rb +191 -0
- data/lib/solarwinds_apm/ruby.rb +35 -0
- data/lib/solarwinds_apm/sdk/current_trace_info.rb +123 -0
- data/lib/solarwinds_apm/sdk/custom_metrics.rb +94 -0
- data/lib/solarwinds_apm/sdk/logging.rb +37 -0
- data/lib/solarwinds_apm/sdk/trace_context_headers.rb +69 -0
- data/lib/solarwinds_apm/sdk/tracing.rb +432 -0
- data/lib/solarwinds_apm/support/profiling.rb +22 -0
- data/lib/solarwinds_apm/support/trace_context.rb +53 -0
- data/lib/solarwinds_apm/support/trace_state.rb +69 -0
- data/lib/solarwinds_apm/support/trace_string.rb +89 -0
- data/lib/solarwinds_apm/support/transaction_metrics.rb +67 -0
- data/lib/solarwinds_apm/support/transaction_settings.rb +233 -0
- data/lib/solarwinds_apm/support/x_trace_options.rb +113 -0
- data/lib/solarwinds_apm/support.rb +12 -0
- data/lib/solarwinds_apm/support_report.rb +113 -0
- data/lib/solarwinds_apm/test.rb +165 -0
- data/lib/solarwinds_apm/thread_local.rb +26 -0
- data/lib/solarwinds_apm/util.rb +334 -0
- data/lib/solarwinds_apm/version.rb +17 -0
- data/lib/solarwinds_apm.rb +72 -0
- data/log/.keep +0 -0
- data/log/postgresql/.keep +0 -0
- data/solarwinds_apm.gemspec +52 -0
- data/yardoc_frontpage.md +24 -0
- metadata +228 -0
data/CONFIG.md
ADDED
@@ -0,0 +1,31 @@
|
|
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
ADDED
@@ -0,0 +1,14 @@
|
|
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
|
+
end
|
13
|
+
|
14
|
+
gemspec
|
data/LICENSE
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
180
|
+
|
181
|
+
To apply the Apache License to your work, attach the following
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
+
replaced with your own identifying information. (Don't include
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
185
|
+
comment syntax for the file format. We also recommend that a
|
186
|
+
file or class name and description of purpose be included on the
|
187
|
+
same "printed page" as the copyright notice for easier
|
188
|
+
identification within third-party archives.
|
189
|
+
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,383 @@
|
|
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/appoptics/appoptics-apm-ruby/actions/workflows/run_tests.yml/badge.svg)](https://github.com/appoptics/appoptics-apm-ruby/actions/workflows/run_tests.yml)
|
15
|
+
[![C++ Tests](https://github.com/appoptics/appoptics-apm-ruby/actions/workflows/run_cpluplus_tests.yml/badge.svg)](https://github.com/appoptics/appoptics-apm-ruby/actions/workflows/run_cpluplus_tests.yml)
|
16
|
+
|
17
|
+
[comment]: <> ([![Maintainability](https://api.codeclimate.com/v1/badges/ac7f36241a23a3a82fc5/maintainability)](https://codeclimate.com/github/appoptics/appoptics-apm-ruby/maintainability))
|
18
|
+
|
19
|
+
# Documentation
|
20
|
+
|
21
|
+
* [SolarWindsAPM Knowledge Base](https://documentation.solarwinds.com/en/success_center/observability/default.htm#cshid=config-ruby-agent)
|
22
|
+
|
23
|
+
# Installation
|
24
|
+
|
25
|
+
_Before installing the gem below, make sure that you have the
|
26
|
+
[dependencies](https://documentation.solarwinds.com/en/success_center/observability/default.htm#cshid=config-ruby-install) installed on your host first._
|
27
|
+
|
28
|
+
The solarwinds_apm gem is [available on Rubygems](https://rubygems.org/gems/solarwinds_apm) and can be installed with:
|
29
|
+
|
30
|
+
```bash
|
31
|
+
gem install solarwinds_apm
|
32
|
+
```
|
33
|
+
|
34
|
+
or added to **the end** of your Gemfile and running `bundle install`:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
gem 'solarwinds_apm'
|
38
|
+
```
|
39
|
+
|
40
|
+
# Running
|
41
|
+
|
42
|
+
Make sure to set `SW_APM_SERVICE_KEY` in the environment from where the app or service is run, e.g:
|
43
|
+
```
|
44
|
+
export SW_APM_SERVICE_KEY=795fb4947d15275d208c49cfd2412d4a5bf38742045b47236c94c4fe5f5b17c7:<your_app_name>
|
45
|
+
```
|
46
|
+
|
47
|
+
## Rails
|
48
|
+
|
49
|
+
No special steps are needed to instrument Ruby on Rails. Once part of the bundle, the solarwinds-apm gem will automatically
|
50
|
+
detect Rails and instrument on stack initialization.
|
51
|
+
|
52
|
+
### The Install Generator
|
53
|
+
|
54
|
+
The solarwinds_apm gem provides a Rails generator used to seed an initializer where you can configure and control
|
55
|
+
`tracing_mode` and [other options](https://documentation.solarwinds.com/en/success_center/observability/default.htm#cshid=config-ruby-config-file).
|
56
|
+
|
57
|
+
To run the install generator run:
|
58
|
+
|
59
|
+
```bash
|
60
|
+
bundle exec rails generate solarwinds_apm:install
|
61
|
+
```
|
62
|
+
|
63
|
+
After the prompts, this will create an initializer: `config/initializers/solarwinds_apm.rb`.
|
64
|
+
|
65
|
+
## Sinatra
|
66
|
+
|
67
|
+
You can instrument your Sinatra application by adding the following code to your `config.ru` Rackup file:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
# If you're not using Bundler.require. Make sure this is done
|
71
|
+
# after the Sinatra require directive.
|
72
|
+
require 'solarwinds_apm'
|
73
|
+
```
|
74
|
+
|
75
|
+
Make sure that the solarwinds_apm gem is loaded _after_ Sinatra either by listing `gem 'solarwinds_apm'` after Sinatra in
|
76
|
+
your Gemfile or calling the `require 'solarwinds_gem'` directive after Sinatra is loaded.
|
77
|
+
|
78
|
+
With this, the solarwinds_apm gem will automatically detect Sinatra on boot and instrument key components.
|
79
|
+
|
80
|
+
## Padrino
|
81
|
+
|
82
|
+
As long as the solarwinds_apm gem is in your `Gemfile` (inserted after the `gem 'padrino'` directive) and you are calling
|
83
|
+
`Bundler.require`, the solarwinds_apm gem will automatically instrument Padrino applications.
|
84
|
+
|
85
|
+
If you need to set `SolarWindsAPM::Config` values on stack boot, you can do so by adding the following
|
86
|
+
to your `config/boot.rb` file:
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
Padrino.before_load do
|
90
|
+
# Verbose output of instrumentation initialization
|
91
|
+
SolarWindsAPM
|
92
|
+
end
|
93
|
+
```
|
94
|
+
|
95
|
+
## Grape
|
96
|
+
|
97
|
+
You can instrument your Grape application by adding the following code to your `config.ru` Rackup file:
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
# If you're not using Bundler.require. Make sure this is done
|
101
|
+
# after the Grape require directive.
|
102
|
+
require 'solarwinds_apm'
|
103
|
+
|
104
|
+
...
|
105
|
+
|
106
|
+
class App < Grape::API
|
107
|
+
use SolarWindsAPM::Rack
|
108
|
+
end
|
109
|
+
```
|
110
|
+
|
111
|
+
Make sure that the solarwinds gem is loaded _after_ Grape either by listing `gem 'solarwinds_apm'` after Grape in your
|
112
|
+
Gemfile or calling the `require 'solarwinds_apm'` directive after Grape is loaded.
|
113
|
+
|
114
|
+
You must explicitly tell your Grape application to use SolarWindsAPM::Rack for tracing to occur.
|
115
|
+
|
116
|
+
|
117
|
+
# SDK for Custom Tracing
|
118
|
+
|
119
|
+
The solarwinds_apm gem has the ability to instrument any arbitrary Ruby application or script.
|
120
|
+
|
121
|
+
```ruby
|
122
|
+
require 'rubygems'
|
123
|
+
require 'bundler'
|
124
|
+
|
125
|
+
Bundler.require
|
126
|
+
|
127
|
+
require 'solarwinds_apm'
|
128
|
+
```
|
129
|
+
|
130
|
+
You can add even more visibility into any part of your application or scripts by adding custom instrumentation.
|
131
|
+
|
132
|
+
## SolarWindsAPM::SDK.trace
|
133
|
+
You can instrument any arbitrary block of code using `SolarWindsAPM::SDK.trace`.
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
# layer_name will show up in the SolarWinds dashboard
|
137
|
+
layer_name = 'subsystemX'
|
138
|
+
|
139
|
+
# report_kvs are a set of information Key/Value pairs that are sent to
|
140
|
+
# SolarWinds dashboard along with the performance metrics. These KV
|
141
|
+
# pairs are used to report request, environment and/or client specific
|
142
|
+
# information.
|
143
|
+
|
144
|
+
report_kvs = {}
|
145
|
+
report_kvs[:mykey] = @client.id
|
146
|
+
|
147
|
+
SolarWindsAPM::SDK.trace(layer_name, kvs: report_kvs) do
|
148
|
+
# the block of code to be traced
|
149
|
+
end
|
150
|
+
```
|
151
|
+
|
152
|
+
`SolarWindsAPM::SDK.trace` is used within the context of a request. It will follow the upstream state of the request
|
153
|
+
being traced. i.e. the block of code will only be traced when the parent request is being traced.
|
154
|
+
|
155
|
+
This tracing state of a request can also be queried by using `SolarWindsAPM.tracing?`.
|
156
|
+
|
157
|
+
## SolarWindsAPM::SDK.start_trace
|
158
|
+
|
159
|
+
If you need to instrument code outside the context of a request (such as a cron job, background job or an arbitrary
|
160
|
+
ruby script), use `SolarWindsAPM::SDK.start_trace` instead which will initiate a new trace based on configuration and
|
161
|
+
probability (based on the sample rate).
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
### Example
|
166
|
+
|
167
|
+
```ruby
|
168
|
+
require 'rubygems'
|
169
|
+
require 'bundler'
|
170
|
+
|
171
|
+
Bundler.require
|
172
|
+
|
173
|
+
# Make sure solarwinds_apm is at the bottom of your Gemfile.
|
174
|
+
# This is likely redundant but just in case.
|
175
|
+
require 'solarwinds_apm'
|
176
|
+
|
177
|
+
|
178
|
+
# Tracing mode can be :enabled or :disabled
|
179
|
+
SolarWindsAPM::Config[:tracing_mode] = :enabled
|
180
|
+
|
181
|
+
#
|
182
|
+
# Update April 9, 2015 - this is done automagically now
|
183
|
+
# and doesn't have to be called manually
|
184
|
+
#
|
185
|
+
# Load library instrumentation to auto-capture stuff we know about...
|
186
|
+
# e.g. ActiveRecord, Dalli, Redis, memcache, mongo
|
187
|
+
# TraceView::Ruby.load
|
188
|
+
|
189
|
+
# Some KVs to report to the dashboard
|
190
|
+
report_kvs = {}
|
191
|
+
report_kvs[:command_line_params] = ARGV.to_s
|
192
|
+
report_kvs[:user_id] = `whoami`
|
193
|
+
|
194
|
+
SolarWindsAPM::SDK.start_trace('my_background_job', kvs: report_kvs) do
|
195
|
+
#
|
196
|
+
# Initialization code
|
197
|
+
#
|
198
|
+
|
199
|
+
tasks = get_all_tasks
|
200
|
+
|
201
|
+
tasks.each do |t|
|
202
|
+
# Optional: Here we embed another 'trace' to separate actual
|
203
|
+
# work for each task. In the traces dashboard this will show
|
204
|
+
# up as a large 'my_background_job' parent layer with many
|
205
|
+
# child 'task' layers.
|
206
|
+
SolarWindsAPM::SDK.trace('task', kvs: { :task_id => t.id }) do
|
207
|
+
t.perform
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
#
|
212
|
+
# cleanup code
|
213
|
+
#
|
214
|
+
end
|
215
|
+
|
216
|
+
|
217
|
+
# Note that we use 'start_trace' in the outer block and 'trace' for
|
218
|
+
# any sub-blocks of code we wish to instrument. The arguments for
|
219
|
+
# both methods vary slightly.
|
220
|
+
```
|
221
|
+
|
222
|
+
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.
|
223
|
+
|
224
|
+
# Support
|
225
|
+
|
226
|
+
If you run into a problem, find a bug, or would like to request an enhancement, feel free to contact our tech support
|
227
|
+
[technicalsupport@solarwinds.com](technicalsupport@solarwinds.com).
|
228
|
+
|
229
|
+
# Contributing
|
230
|
+
|
231
|
+
You are obviously a person of great sense and intelligence. We happily appreciate all contributions to the solarwinds_apm
|
232
|
+
gem whether it is documentation, a bug fix, new instrumentation for a library or framework or anything else we haven't
|
233
|
+
thought of.
|
234
|
+
|
235
|
+
We welcome you to send us PRs. We also humbly request that any new instrumentation submissions have corresponding tests
|
236
|
+
that accompany them. This way we don't break any of your additions when we (and others) make changes after the fact.
|
237
|
+
|
238
|
+
|
239
|
+
## Layout of the Gem
|
240
|
+
|
241
|
+
The solarwinds_apm gem uses a standard gem layout. Here are the notable directories.
|
242
|
+
|
243
|
+
lib/solarwinds_apm/inst # Auto load directory for various instrumented libraries
|
244
|
+
lib/solarwinds_apm/frameworks # Framework instrumentation directory
|
245
|
+
lib/solarwinds_apm/frameworks/rails # Files specific to Rails instrumentation
|
246
|
+
lib/rails # A Rails required directory for the Rails install generator
|
247
|
+
lib/api # The SolarWindsAPM Tracing API: layers, logging, tracing
|
248
|
+
ext/oboe_metal # The Ruby c extension that links against the system liboboe library
|
249
|
+
|
250
|
+
## Building the Gem
|
251
|
+
|
252
|
+
The solarwinds_apm gem is built with the standard `gem build` command passing in the gemspec:
|
253
|
+
|
254
|
+
```bash
|
255
|
+
gem build solarwinds_apm.gemspec
|
256
|
+
```
|
257
|
+
|
258
|
+
## Writing Custom Instrumentation
|
259
|
+
|
260
|
+
Custom instrumentation for a library, database or other service can be authored fairly easily. Generally,
|
261
|
+
instrumentation of a library is done by wrapping select operations of that library and timing their execution using the
|
262
|
+
SolarWindsAPM Tracing SDK which then reports the metrics to the users' SolarWinds dashboard.
|
263
|
+
|
264
|
+
Here, I'll use a stripped down version of the Dalli instrumentation (`lib/solarwinds_apm/inst/dalli.rb`) as a quick example
|
265
|
+
of how to instrument a client library (the dalli gem).
|
266
|
+
|
267
|
+
The Dalli gem nicely routes all memcache operations through a single `perform` operation. Wrapping this method allows
|
268
|
+
us to capture all Dalli operations called by an application.
|
269
|
+
|
270
|
+
First, we define a module (SolarWindsAPM::Inst::Dalli) and our own custom `perform_with_sw_apm` method that we will
|
271
|
+
use as a wrapper around Dalli's `perform` method. We also declare an `included` method which automatically gets called
|
272
|
+
when this module is included by another.
|
273
|
+
See [`Module#included` Ruby reference documentation](https://devdocs.io/ruby~2.5/module#method-i-included).
|
274
|
+
|
275
|
+
```ruby
|
276
|
+
module SolarWindsAPM
|
277
|
+
module Inst
|
278
|
+
module Dalli
|
279
|
+
include SolarWindsAPM::API::Memcache
|
280
|
+
|
281
|
+
def self.included(cls)
|
282
|
+
cls.class_eval do
|
283
|
+
if ::Dalli::Client.private_method_defined? :perform
|
284
|
+
alias perform_without_sw_apm perform
|
285
|
+
alias perform perform_with_sw_apm
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
def perform_with_sw_apm(*all_args, &blk)
|
291
|
+
op, key, *args = *all_args
|
292
|
+
|
293
|
+
if SolarWindsAPM.tracing?
|
294
|
+
opts = {}
|
295
|
+
opts[:KVOp] = op
|
296
|
+
opts[:KVKey] = key
|
297
|
+
|
298
|
+
SolarWindsAPM::SDK.trace('memcache', kvs: opts) do
|
299
|
+
result = perform_without_sw_apm(*all_args, &blk)
|
300
|
+
if op == :get and key.class == String
|
301
|
+
SolarWindsAPM::API.log_info('memcache', { :KVHit => memcache_hit?(result) })
|
302
|
+
end
|
303
|
+
result
|
304
|
+
end
|
305
|
+
else
|
306
|
+
perform_without_sw_apm(*all_args, &blk)
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
end
|
311
|
+
end
|
312
|
+
end
|
313
|
+
```
|
314
|
+
|
315
|
+
Second, we tail onto the end of the instrumentation file a simple `::Dalli::Client.module_eval` call to tell the Dalli
|
316
|
+
module to include our newly defined instrumentation module. Doing this will invoke our previously defined `included` method.
|
317
|
+
|
318
|
+
```ruby
|
319
|
+
if defined?(Dalli) and SolarWindsAPM::Config[:dalli][:enabled]
|
320
|
+
::Dalli::Client.module_eval do
|
321
|
+
include SolarWindsAPM::Inst::Dalli
|
322
|
+
end
|
323
|
+
end
|
324
|
+
```
|
325
|
+
|
326
|
+
Third, in our wrapper method, we capture the arguments passed in, collect the operation and key information into a local
|
327
|
+
hash and then invoke the `SolarWindsAPM::SDK.trace` method to time the execution of the original operation.
|
328
|
+
|
329
|
+
The `SolarWindsAPM::SDK.trace` method calls Dalli's native operation and reports the timing metrics and your custom
|
330
|
+
`report_kvs` up to SolarWinds servers to be shown on the user's dashboard.
|
331
|
+
|
332
|
+
Some other tips and guidelines:
|
333
|
+
|
334
|
+
* You can point your Gemfile directly at your cloned solarwinds_apm gem source by using
|
335
|
+
`gem 'solarwinds_apm', :path => '/path/to/ruby-solarwinds'`
|
336
|
+
|
337
|
+
* If instrumenting a library, database or service, place your new instrumentation file into the `lib/solarwinds_apm/inst/`
|
338
|
+
directory. From there, the solarwinds_apm gem will detect it and automatically load the instrumentation file.
|
339
|
+
|
340
|
+
* If instrumenting a new framework, place your instrumentation file in `lib/solarwinds_apm/frameworks`. Refer to the Rails
|
341
|
+
instrumentation for on ideas on how to load the solarwinds_apm gem correctly in your framework.
|
342
|
+
|
343
|
+
* Review other existing instrumentation similar to the one you wish to author. `lib/solarwinds_apm/inst/` is a great place
|
344
|
+
to start.
|
345
|
+
|
346
|
+
* Depending on the configured `:sample_rate`, not all requests will be traced. Use `SolarWindsAPM.tracing?` to determine
|
347
|
+
of this is a request that is being traced.
|
348
|
+
|
349
|
+
* Performance is paramount. Make sure that your wrapped methods don't slow down users applications.
|
350
|
+
|
351
|
+
* Include tests with your instrumentation. See `test/instrumentation/` for some examples of existing instrumentation
|
352
|
+
tests.
|
353
|
+
|
354
|
+
## Compiling the C extension
|
355
|
+
|
356
|
+
The solarwinds_apm gem utilizes a C extension to interface with a core library bundled in with the gem which handles
|
357
|
+
reporting the trace and performance data back to SolarWinds servers.
|
358
|
+
|
359
|
+
C extensions are usually built on `gem install` but when working out of a local git repository, it's required that you
|
360
|
+
manually build this C extension for the gem to function.
|
361
|
+
|
362
|
+
To make this simpler, we've included a few rake tasks to automate this process:
|
363
|
+
|
364
|
+
```bash
|
365
|
+
rake clean # make sure no old stuff is around
|
366
|
+
rake fetch_ext_deps # download c-files
|
367
|
+
rake compile # Build the gem's c extension
|
368
|
+
```
|
369
|
+
|
370
|
+
To see the code related to the C extension, take a look at `ext/oboe_metal/extconf.rb` for details.
|
371
|
+
|
372
|
+
You can read more about Ruby gems with C extensions in the
|
373
|
+
[Rubygems Guides](http://guides.rubygems.org/gems-with-extensions/).
|
374
|
+
|
375
|
+
## Running the Tests
|
376
|
+
|
377
|
+
See the README in the test directory.
|
378
|
+
|
379
|
+
# License
|
380
|
+
|
381
|
+
Copyright (c) 2018 SolarWinds, LLC
|
382
|
+
|
383
|
+
Released under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
@@ -0,0 +1,15 @@
|
|
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
ADDED
@@ -0,0 +1,13 @@
|
|
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)
|