solarwinds_apm 5.1.8 → 6.0.0.preV1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +0 -1
  3. data/ext/oboe_metal/extconf.rb +19 -23
  4. data/ext/oboe_metal/lib/liboboe-1.0-aarch64.so.sha256 +1 -1
  5. data/ext/oboe_metal/lib/liboboe-1.0-alpine-aarch64.so.sha256 +1 -1
  6. data/ext/oboe_metal/lib/liboboe-1.0-alpine-x86_64.so.sha256 +1 -1
  7. data/ext/oboe_metal/lib/liboboe-1.0-x86_64.so.sha256 +1 -1
  8. data/ext/oboe_metal/src/VERSION +1 -1
  9. data/ext/oboe_metal/src/oboe_api.cpp +9 -7
  10. data/ext/oboe_metal/src/oboe_api.h +7 -7
  11. data/ext/oboe_metal/src/oboe_debug.h +2 -0
  12. data/ext/oboe_metal/src/oboe_swig_wrap.cc +19 -18
  13. data/lib/oboe_metal.rb +116 -80
  14. data/lib/rails/generators/solarwinds_apm/install_generator.rb +1 -2
  15. data/lib/rails/generators/solarwinds_apm/templates/solarwinds_apm_initializer.rb +44 -260
  16. data/lib/solarwinds_apm/api/current_trace_info.rb +148 -0
  17. data/lib/solarwinds_apm/api/tracing.rb +30 -0
  18. data/lib/solarwinds_apm/api/transaction_name.rb +57 -0
  19. data/lib/solarwinds_apm/api.rb +8 -15
  20. data/lib/solarwinds_apm/base.rb +4 -131
  21. data/lib/solarwinds_apm/config.rb +128 -175
  22. data/lib/solarwinds_apm/constants.rb +32 -0
  23. data/lib/solarwinds_apm/logger.rb +1 -1
  24. data/lib/solarwinds_apm/noop/context.rb +2 -5
  25. data/lib/solarwinds_apm/noop/metadata.rb +1 -2
  26. data/lib/solarwinds_apm/noop/profiling.rb +3 -7
  27. data/lib/solarwinds_apm/oboe_init_options.rb +71 -33
  28. data/lib/solarwinds_apm/opentelemetry/solarwinds_exporter.rb +204 -0
  29. data/lib/solarwinds_apm/opentelemetry/solarwinds_processor.rb +163 -0
  30. data/lib/solarwinds_apm/opentelemetry/solarwinds_propagator.rb +92 -0
  31. data/lib/solarwinds_apm/opentelemetry/solarwinds_response_propagator.rb +72 -0
  32. data/lib/solarwinds_apm/opentelemetry/solarwinds_sampler.rb +330 -0
  33. data/lib/solarwinds_apm/opentelemetry.rb +8 -0
  34. data/lib/solarwinds_apm/otel_config.rb +161 -0
  35. data/lib/solarwinds_apm/{inst → support}/logger_formatter.rb +5 -6
  36. data/lib/solarwinds_apm/{inst → support}/logging_log_event.rb +3 -6
  37. data/lib/solarwinds_apm/{inst → support}/lumberjack_formatter.rb +1 -4
  38. data/lib/solarwinds_apm/support/oboe_tracing_mode.rb +27 -0
  39. data/lib/solarwinds_apm/support/swomarginalia/LICENSE +20 -0
  40. data/lib/solarwinds_apm/support/swomarginalia/README.md +41 -0
  41. data/lib/solarwinds_apm/support/swomarginalia/comment.rb +205 -0
  42. data/lib/solarwinds_apm/support/swomarginalia/load_swomarginalia.rb +48 -0
  43. data/lib/solarwinds_apm/support/swomarginalia/railtie.rb +22 -0
  44. data/lib/solarwinds_apm/support/swomarginalia/swomarginalia.rb +86 -0
  45. data/lib/solarwinds_apm/support/transaction_cache.rb +24 -0
  46. data/lib/solarwinds_apm/support/transaction_settings.rb +26 -209
  47. data/lib/solarwinds_apm/support/transformer.rb +56 -0
  48. data/lib/solarwinds_apm/support/txn_name_manager.rb +25 -0
  49. data/lib/solarwinds_apm/support/x_trace_options.rb +42 -26
  50. data/lib/solarwinds_apm/support.rb +33 -10
  51. data/lib/solarwinds_apm/support_report.rb +10 -32
  52. data/lib/solarwinds_apm/thread_local.rb +1 -1
  53. data/lib/solarwinds_apm/version.rb +4 -4
  54. data/lib/solarwinds_apm.rb +31 -26
  55. metadata +76 -121
  56. data/.dockerignore +0 -5
  57. data/.gitignore +0 -58
  58. data/.rubocop.yml +0 -29
  59. data/.whitesource +0 -22
  60. data/.yardopts +0 -7
  61. data/CHANGELOG-appoptics.md +0 -766
  62. data/CHANGELOG.md +0 -72
  63. data/CONFIG.md +0 -31
  64. data/Gemfile +0 -15
  65. data/README.md +0 -385
  66. data/bin/solarwinds_apm_config +0 -15
  67. data/examples/prepend.rb +0 -13
  68. data/examples/sdk_examples.rb +0 -158
  69. data/ext/oboe_metal/README.md +0 -69
  70. data/ext/oboe_metal/extconf_local.rb +0 -75
  71. data/ext/oboe_metal/lib/.keep +0 -0
  72. data/ext/oboe_metal/noop/noop.c +0 -8
  73. data/ext/oboe_metal/src/README.md +0 -6
  74. data/ext/oboe_metal/src/frames.cc +0 -247
  75. data/ext/oboe_metal/src/frames.h +0 -40
  76. data/ext/oboe_metal/src/logging.cc +0 -97
  77. data/ext/oboe_metal/src/logging.h +0 -34
  78. data/ext/oboe_metal/src/profiling.cc +0 -435
  79. data/ext/oboe_metal/src/profiling.h +0 -78
  80. data/ext/oboe_metal/test/CMakeLists.txt +0 -53
  81. data/ext/oboe_metal/test/FindGMock.cmake +0 -43
  82. data/ext/oboe_metal/test/README.md +0 -56
  83. data/ext/oboe_metal/test/frames_test.cc +0 -164
  84. data/ext/oboe_metal/test/profiling_test.cc +0 -93
  85. data/ext/oboe_metal/test/ruby_inc_dir.rb +0 -8
  86. data/ext/oboe_metal/test/ruby_prefix.rb +0 -8
  87. data/ext/oboe_metal/test/ruby_test_helper.rb +0 -67
  88. data/ext/oboe_metal/test/test.h +0 -11
  89. data/ext/oboe_metal/test/test_main.cc +0 -32
  90. data/init.rb +0 -4
  91. data/lib/solarwinds_apm/api/layerinit.rb +0 -41
  92. data/lib/solarwinds_apm/api/logging.rb +0 -356
  93. data/lib/solarwinds_apm/api/memcache.rb +0 -37
  94. data/lib/solarwinds_apm/api/metrics.rb +0 -63
  95. data/lib/solarwinds_apm/api/util.rb +0 -98
  96. data/lib/solarwinds_apm/frameworks/grape.rb +0 -96
  97. data/lib/solarwinds_apm/frameworks/padrino.rb +0 -78
  98. data/lib/solarwinds_apm/frameworks/rails/inst/action_controller.rb +0 -100
  99. data/lib/solarwinds_apm/frameworks/rails/inst/action_controller5.rb +0 -50
  100. data/lib/solarwinds_apm/frameworks/rails/inst/action_controller_api.rb +0 -50
  101. data/lib/solarwinds_apm/frameworks/rails/inst/action_view.rb +0 -88
  102. data/lib/solarwinds_apm/frameworks/rails/inst/active_record.rb +0 -26
  103. data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/mysql2.rb +0 -29
  104. data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/postgresql.rb +0 -22
  105. data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/utils5x.rb +0 -103
  106. data/lib/solarwinds_apm/frameworks/rails/inst/logger_formatters.rb +0 -14
  107. data/lib/solarwinds_apm/frameworks/rails.rb +0 -100
  108. data/lib/solarwinds_apm/frameworks/sinatra.rb +0 -96
  109. data/lib/solarwinds_apm/inst/bunny-client.rb +0 -157
  110. data/lib/solarwinds_apm/inst/bunny-consumer.rb +0 -102
  111. data/lib/solarwinds_apm/inst/curb.rb +0 -289
  112. data/lib/solarwinds_apm/inst/dalli.rb +0 -89
  113. data/lib/solarwinds_apm/inst/delayed_job.rb +0 -100
  114. data/lib/solarwinds_apm/inst/excon.rb +0 -113
  115. data/lib/solarwinds_apm/inst/faraday.rb +0 -96
  116. data/lib/solarwinds_apm/inst/graphql.rb +0 -206
  117. data/lib/solarwinds_apm/inst/grpc_client.rb +0 -147
  118. data/lib/solarwinds_apm/inst/grpc_server.rb +0 -119
  119. data/lib/solarwinds_apm/inst/httpclient.rb +0 -182
  120. data/lib/solarwinds_apm/inst/memcached.rb +0 -86
  121. data/lib/solarwinds_apm/inst/mongo.rb +0 -246
  122. data/lib/solarwinds_apm/inst/mongo2.rb +0 -225
  123. data/lib/solarwinds_apm/inst/moped.rb +0 -466
  124. data/lib/solarwinds_apm/inst/net_http.rb +0 -60
  125. data/lib/solarwinds_apm/inst/rack.rb +0 -223
  126. data/lib/solarwinds_apm/inst/rack_cache.rb +0 -35
  127. data/lib/solarwinds_apm/inst/redis.rb +0 -280
  128. data/lib/solarwinds_apm/inst/redis_v4.rb +0 -273
  129. data/lib/solarwinds_apm/inst/resque.rb +0 -129
  130. data/lib/solarwinds_apm/inst/rest-client.rb +0 -43
  131. data/lib/solarwinds_apm/inst/sequel.rb +0 -241
  132. data/lib/solarwinds_apm/inst/sidekiq-client.rb +0 -63
  133. data/lib/solarwinds_apm/inst/sidekiq-worker.rb +0 -64
  134. data/lib/solarwinds_apm/inst/typhoeus.rb +0 -90
  135. data/lib/solarwinds_apm/instrumentation.rb +0 -22
  136. data/lib/solarwinds_apm/loading.rb +0 -65
  137. data/lib/solarwinds_apm/ruby.rb +0 -35
  138. data/lib/solarwinds_apm/sdk/current_trace_info.rb +0 -123
  139. data/lib/solarwinds_apm/sdk/custom_metrics.rb +0 -94
  140. data/lib/solarwinds_apm/sdk/logging.rb +0 -37
  141. data/lib/solarwinds_apm/sdk/trace_context_headers.rb +0 -69
  142. data/lib/solarwinds_apm/sdk/tracing.rb +0 -432
  143. data/lib/solarwinds_apm/support/profiling.rb +0 -25
  144. data/lib/solarwinds_apm/support/trace_context.rb +0 -53
  145. data/lib/solarwinds_apm/support/trace_state.rb +0 -69
  146. data/lib/solarwinds_apm/support/trace_string.rb +0 -89
  147. data/lib/solarwinds_apm/support/transaction_metrics.rb +0 -67
  148. data/lib/solarwinds_apm/test.rb +0 -165
  149. data/lib/solarwinds_apm/util.rb +0 -426
  150. data/log/.keep +0 -0
  151. data/log/postgresql/.keep +0 -0
  152. data/solarwinds_apm.gemspec +0 -55
  153. data/yardoc_frontpage.md +0 -24
@@ -3,11 +3,11 @@
3
3
  # Copyright (c) 2019 SolarWinds, LLC.
4
4
  # All rights reserved.
5
5
 
6
- # SolarWindsAPM Configuration for the Ruby Library aka solarwinds_apm gem
6
+ # SolarWindsAPM Configuration for the Ruby Agent aka solarwinds_apm gem
7
7
  # https://cloud.solarwinds.com/
8
8
  #
9
- # More information on configuring the Ruby Library can be found here:
10
- # https://documentation.solarwinds.com/en/success_center/observability/default.htm#cshid=config-ruby-agent
9
+ # More information on configuring the Ruby Agent can be found here:
10
+ # https://documentation.solarwinds.com/en/success_center/swaas/default.htm#cshid=config-ruby-agent
11
11
  #
12
12
  # The initial settings in this file represent the defaults
13
13
 
@@ -46,11 +46,9 @@ if defined?(SolarWindsAPM::Config)
46
46
  # to SolarWinds is still encrypted using SSL/TLS.
47
47
  #
48
48
  # It is recommended to configure the proxy in this file or as SW_APM_PROXY
49
- # environment variable. However, the underlying network library for the Ruby
50
- # Instrumentation Library will use a system-wide proxy defined in the environment
51
- # variables grpc_proxy, https_proxy or http_proxy if no SolarWindsAPM-specific
52
- # configuration is set.
53
- #
49
+ # environment variable. However, the agent's underlying network library will
50
+ # use a system-wide proxy defined in the environment variables grpc_proxy,
51
+ # https_proxy or http_proxy if no SolarWindsAPM-specific configuration is set.
54
52
  # Please refer to gRPC environment variables for more information.
55
53
  #
56
54
  # SolarWindsAPM::Config[:http_proxy] = http://<proxyHost>:<proxyPort>
@@ -88,19 +86,8 @@ if defined?(SolarWindsAPM::Config)
88
86
  # sampling rate and metrics are reported.
89
87
  # :disabled means that there is no sampling and metrics are not reported.
90
88
  #
91
- # The values :always and :never are deprecated
92
- #
93
89
  SolarWindsAPM::Config[:tracing_mode] = :enabled
94
90
 
95
- #
96
- # Turn Trigger Tracing on or off
97
- #
98
- # By default trigger tracing is :enabled, the other option is :disabled.
99
- # It allows to use the X-Trace-Options header to force a request to be
100
- # traced (within rate limits set for trigger tracing)
101
- #
102
- SolarWindsAPM::Config[:trigger_tracing_mode] = :enabled
103
-
104
91
  #
105
92
  # Trace Context in Logs
106
93
  #
@@ -109,124 +96,26 @@ if defined?(SolarWindsAPM::Config)
109
96
  # the current Trace ID in log messages.
110
97
  #
111
98
  # The added string will look like:
112
- # "trace_id=7435a9fe510ae4533414d425dadf4e18 span_id=49e60702469db05f trace_flags=00"
99
+ # "trace_id=7435a9fe510ae4533414d425dadf4e18 span_id=49e60702469db05f trace_flags=00 resource.service.name=service_name"
113
100
  #
114
101
  # The following options are available:
115
102
  # :never (default)
116
103
  # :sampled only include the Trace ID of sampled requests
117
104
  # :traced include the Trace ID for all traced requests
118
105
  # :always always add a Trace ID, it will be
119
- # "trace_id=00000000000000000000000000000000 span_id=0000000000000000 trace_flags=00"
106
+ # "trace_id=00000000000000000000000000000000 span_id=0000000000000000 trace_flags=00 resource.service.name=otel_service_name"
120
107
  # when there is no tracing context.
121
108
  #
122
109
  SolarWindsAPM::Config[:log_traceId] = :never
123
110
 
124
- #
125
- # Trace Context in Queries (sql only)
126
- #
127
- # Configure to add the trace context to sql queries so that queries and
128
- # transactions can be linked in the SolarWinds dashboard
129
- #
130
- # This option can add a small overhead for queries that use prepared
131
- # statements as those statements will be recompiled whenever the trace context
132
- # is added (about 10% of the requests)
133
- #
134
- # the options are:
135
- # - true (default) no trace context is added
136
- # - false the tracecontext is added as comment to the start of the query, e.g:
137
- # "/*traceparent='00-268748089f148899e29fc5711aca7760-7c6c704dcbba6682-01'*/SELECT `widgets`.* FROM `widgets` WHERE ..."
138
- #
139
- SolarWindsAPM::Config[:tag_sql] = false
140
-
141
- #
142
- # Sanitize SQL Statements
143
- #
144
- # The SolarWindsAPM Ruby client has the ability to sanitize query literals
145
- # from SQL statements. By default this is enabled. Disable to
146
- # collect and report query literals to SolarWindsAPM.
147
- #
148
- SolarWindsAPM::Config[:sanitize_sql] = true
149
- SolarWindsAPM::Config[:sanitize_sql_regexp] = '(\'[^\']*\'|\d*\.\d+|\d+|NULL)'
150
- SolarWindsAPM::Config[:sanitize_sql_opts] = Regexp::IGNORECASE
151
-
152
- #
153
- # Prepend Domain to Transaction Name
154
- #
155
- # If this is set to `true` transaction names will be composed as
156
- # `my.host.com/controller.action` instead of `controller.action`.
157
- # This configuration applies to all transaction names, whether deduced by the
158
- # instrumentation or implicitly set.
159
- #
160
- SolarWindsAPM::Config[:transaction_name][:prepend_domain] = false
161
-
162
- #
163
- # Do Not Trace - DNT
164
- #
165
- # DEPRECATED
166
- # Please comment out if no filtering is desired, e.g. your static
167
- # assets are served by the web server and not the application
168
- #
169
- # This configuration allows creating a regexp for paths that should be excluded
170
- # from solarwinds_apm processing.
171
- #
172
- # For example:
173
- # - static assets that aren't served by the web server, or
174
- # - healthcheck endpoints that respond to a heart beat.
175
- #
176
- # :dnt_regexp is the regular expression that is applied to the incoming path
177
- # to determine whether the request should be measured and traced or not.
178
- #
179
- # :dnt_opts can be commented out, nil, or Regexp::IGNORECASE
180
- #
181
- # The matching happens before routes are applied.
182
- # The path originates from the rack layer and is retrieved as follows:
183
- # req = ::Rack::Request.new(env)
184
- # path = URI.unescape(req.path)
185
- #
186
- SolarWindsAPM::Config[:dnt_regexp] = '\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|otf|eot|ttf|woff|woff2|svg|less)(\?.+){0,1}$'
187
- SolarWindsAPM::Config[:dnt_opts] = Regexp::IGNORECASE
188
-
189
- #
190
- # GraphQL
191
- #
192
- # Enable tracing for GraphQL.
193
- # (true | false, default: true)
194
- SolarWindsAPM::Config[:graphql][:enabled] = true
195
- # Replace query arguments with a '?' when sent with a trace.
196
- # (true | false, default: true)
197
- SolarWindsAPM::Config[:graphql][:sanitize] = true
198
- # Remove comments from queries when sent with a trace.
199
- # (true | false, default: true)
200
- SolarWindsAPM::Config[:graphql][:remove_comments] = true
201
- # Create a transaction name by combining
202
- # "query" or "mutation" with the first word of the query.
203
- # This overwrites the default transaction name, which is a combination of
204
- # controller + action and would be the same for all graphql queries.
205
- # (true | false, default: true)
206
- SolarWindsAPM::Config[:graphql][:transaction_name] = true
207
-
208
- #
209
- # Rack::Cache
210
- #
211
- # Create a transaction name like `rack-cache.<cache-store>`,
212
- # e.g. `rack-cache.memcached`
213
- # This can reduce the number of transaction names, when many requests are
214
- # served directly from the cache without hitting a controller action.
215
- # When set to `false` the path will be used for the transaction name.
216
- #
217
- SolarWindsAPM::Config[:rack_cache] = { transaction_name: true }
218
-
219
111
  #
220
112
  # Transaction Settings
221
113
  #
222
114
  # Use this configuration to add exceptions to the global tracing mode and
223
115
  # disable/enable metrics and traces for certain transactions.
224
116
  #
225
- # Currently allowed hash keys:
226
- # :url to apply listed filters to urls.
227
- # The matching of settings to urls happens before routes are applied.
228
- # The url is extracted from the env argument passed to rack: `env['PATH_INFO']`
229
- #
117
+ # Currently allowed array of hash
118
+ #
230
119
  # and the hashes within the :url list either:
231
120
  # :extensions takes an array of strings for filtering (not regular expressions!)
232
121
  # :tracing defaults to :disabled, can be set to :enabled to override
@@ -240,31 +129,20 @@ if defined?(SolarWindsAPM::Config)
240
129
  # Be careful not to add too many :regexp configurations as they will slow
241
130
  # down execution.
242
131
  #
243
- SolarWindsAPM::Config[:transaction_settings] = {
244
- url: [
245
- # {
246
- # extensions: %w['long_job'],
247
- # tracing: :disabled
248
- # },
249
- # {
250
- # regexp: '^.*\/long_job\/.*$',
251
- # opts: Regexp::IGNORECASE,
252
- # tracing: :disabled
253
- # },
254
- # {
255
- # regexp: /batch/,
256
- # }
257
- ]
258
- }
259
-
260
- #
261
- # Rails Exception Logging
262
- #
263
- # In Rails, raised exceptions with rescue handlers via
264
- # <tt>rescue_from</tt> are not reported to the SolarWinds # dashboard by default. Setting this value to true will
265
- # report all raised exceptions regardless.
266
- #
267
- SolarWindsAPM::Config[:report_rescued_errors] = false
132
+ SolarWindsAPM::Config[:transaction_settings] = [
133
+ # {
134
+ # extensions: %w[long_job],
135
+ # tracing: :disabled
136
+ # },
137
+ # {
138
+ # regexp: '^.*\/long_job\/.*$',
139
+ # opts: Regexp::IGNORECASE,
140
+ # tracing: :disabled
141
+ # },
142
+ # {
143
+ # regexp: /batch/,
144
+ # }
145
+ ]
268
146
 
269
147
  #
270
148
  # EC2 Metadata Fetching Timeout
@@ -276,131 +154,37 @@ if defined?(SolarWindsAPM::Config)
276
154
  #
277
155
  SolarWindsAPM::Config[:ec2_metadata_timeout] = 1000
278
156
 
279
-
280
- #############################################
281
- ## SETTINGS FOR INDIVIDUAL GEMS/FRAMEWORKS ##
282
- #############################################
283
-
284
- #
285
- # Bunny Controller and Action
286
- #
287
- # The bunny (Rabbitmq) instrumentation can optionally report
288
- # Controller and Action values to allow filtering of bunny
289
- # message handling in # the UI. Use of Controller and Action
290
- # for filters is temporary until the UI is updated with
291
- # additional filters.
292
157
  #
293
- # These values identify which properties of
294
- # Bunny::MessageProperties to report as Controller
295
- # and Action. The defaults are to report :app_id (as
296
- # Controller) and :type (as Action). If these values
297
- # are not specified in the publish, then nothing
298
- # will be reported here.
299
- #
300
- SolarWindsAPM::Config[:bunnyconsumer][:controller] = :app_id
301
- SolarWindsAPM::Config[:bunnyconsumer][:action] = :type
302
-
158
+ # Trigger Trace Mode
159
+ #
160
+ # Trace options is a custom HTTP header X-Trace-Options that can be set on a request to carry additional information
161
+ # to the agents, one such option being trigger-trace which we’ll call a trigger trace request.
303
162
  #
304
- # Enabling/Disabling Instrumentation
305
- #
306
- # If you're having trouble with one of the instrumentation libraries, they
307
- # can be individually disabled here by setting the :enabled
308
- # value to false.
309
- #
310
- # :enabled settings are read on startup and can't be changed afterwards
311
- #
312
- SolarWindsAPM::Config[:action_controller][:enabled] = true
313
- SolarWindsAPM::Config[:action_controller_api][:enabled] = true
314
- SolarWindsAPM::Config[:action_view][:enabled] = true
315
- SolarWindsAPM::Config[:active_record][:enabled] = true
316
- SolarWindsAPM::Config[:bunnyclient][:enabled] = true
317
- SolarWindsAPM::Config[:bunnyconsumer][:enabled] = true
318
- SolarWindsAPM::Config[:curb][:enabled] = true
319
- SolarWindsAPM::Config[:dalli][:enabled] = true
320
- SolarWindsAPM::Config[:delayed_jobclient][:enabled] = true
321
- SolarWindsAPM::Config[:delayed_jobworker][:enabled] = true
322
- SolarWindsAPM::Config[:excon][:enabled] = true
323
- SolarWindsAPM::Config[:faraday][:enabled] = true
324
- SolarWindsAPM::Config[:grpc_client][:enabled] = true
325
- SolarWindsAPM::Config[:grpc_server][:enabled] = true
326
- SolarWindsAPM::Config[:grape][:enabled] = true
327
- SolarWindsAPM::Config[:httpclient][:enabled] = true
328
- SolarWindsAPM::Config[:memcached][:enabled] = true
329
- SolarWindsAPM::Config[:mongo][:enabled] = true
330
- SolarWindsAPM::Config[:moped][:enabled] = true
331
- SolarWindsAPM::Config[:nethttp][:enabled] = true
332
- SolarWindsAPM::Config[:padrino][:enabled] = true
333
- SolarWindsAPM::Config[:rack][:enabled] = true
334
- SolarWindsAPM::Config[:redis][:enabled] = true
335
- SolarWindsAPM::Config[:resqueclient][:enabled] = true
336
- SolarWindsAPM::Config[:resqueworker][:enabled] = true
337
- SolarWindsAPM::Config[:rest_client][:enabled] = true
338
- SolarWindsAPM::Config[:sequel][:enabled] = true
339
- SolarWindsAPM::Config[:sidekiqclient][:enabled] = true
340
- SolarWindsAPM::Config[:sidekiqworker][:enabled] = true
341
- SolarWindsAPM::Config[:sinatra][:enabled] = true
342
- SolarWindsAPM::Config[:typhoeus][:enabled] = true
163
+ SolarWindsAPM::Config[:trigger_tracing_mode] = 'enabled'
343
164
 
344
165
  #
345
166
  # Argument logging
346
167
  #
347
- #
348
168
  # For http requests:
349
169
  # By default the query string parameters are included in the URLs reported.
350
170
  # Set :log_args to false and instrumentation will stop collecting
351
171
  # and reporting query arguments from URLs.
352
172
  #
353
- SolarWindsAPM::Config[:bunnyconsumer][:log_args] = true
354
- SolarWindsAPM::Config[:curb][:log_args] = true
355
- SolarWindsAPM::Config[:excon][:log_args] = true
356
- SolarWindsAPM::Config[:httpclient][:log_args] = true
357
- SolarWindsAPM::Config[:mongo][:log_args] = true
358
- SolarWindsAPM::Config[:nethttp][:log_args] = true
359
- SolarWindsAPM::Config[:rack][:log_args] = true
360
- SolarWindsAPM::Config[:resqueclient][:log_args] = true
361
- SolarWindsAPM::Config[:resqueworker][:log_args] = true
362
- SolarWindsAPM::Config[:sidekiqclient][:log_args] = true
363
- SolarWindsAPM::Config[:sidekiqworker][:log_args] = true
364
- SolarWindsAPM::Config[:typhoeus][:log_args] = true
173
+ SolarWindsAPM::Config[:log_args] = true
365
174
 
366
175
  #
367
- # Enabling/Disabling Backtrace Collection
368
- #
369
- # Instrumentation can optionally collect backtraces as they collect
370
- # performance metrics. Note that this has a negative impact on
371
- # performance but can be useful when trying to locate the source of
372
- # a certain call or operation.
373
- #
374
- SolarWindsAPM::Config[:action_controller][:collect_backtraces] = true
375
- SolarWindsAPM::Config[:action_controller_api][:collect_backtraces] = true
376
- SolarWindsAPM::Config[:action_view][:collect_backtraces] = true
377
- SolarWindsAPM::Config[:active_record][:collect_backtraces] = true
378
- SolarWindsAPM::Config[:bunnyclient][:collect_backtraces] = false
379
- SolarWindsAPM::Config[:bunnyconsumer][:collect_backtraces] = false
380
- SolarWindsAPM::Config[:curb][:collect_backtraces] = true
381
- SolarWindsAPM::Config[:dalli][:collect_backtraces] = false
382
- SolarWindsAPM::Config[:delayed_jobclient][:collect_backtraces] = false
383
- SolarWindsAPM::Config[:delayed_jobworker][:collect_backtraces] = false
384
- SolarWindsAPM::Config[:excon][:collect_backtraces] = true
385
- SolarWindsAPM::Config[:faraday][:collect_backtraces] = false
386
- SolarWindsAPM::Config[:grape][:collect_backtraces] = true
387
- SolarWindsAPM::Config[:grpc_client][:collect_backtraces] = false
388
- SolarWindsAPM::Config[:grpc_server][:collect_backtraces] = false
389
- SolarWindsAPM::Config[:httpclient][:collect_backtraces] = true
390
- SolarWindsAPM::Config[:memcached][:collect_backtraces] = false
391
- SolarWindsAPM::Config[:mongo][:collect_backtraces] = true
392
- SolarWindsAPM::Config[:moped][:collect_backtraces] = true
393
- SolarWindsAPM::Config[:nethttp][:collect_backtraces] = true
394
- SolarWindsAPM::Config[:padrino][:collect_backtraces] = true
395
- SolarWindsAPM::Config[:rack][:collect_backtraces] = true
396
- SolarWindsAPM::Config[:redis][:collect_backtraces] = false
397
- SolarWindsAPM::Config[:resqueclient][:collect_backtraces] = true
398
- SolarWindsAPM::Config[:resqueworker][:collect_backtraces] = true
399
- SolarWindsAPM::Config[:rest_client][:collect_backtraces] = true
400
- SolarWindsAPM::Config[:sequel][:collect_backtraces] = true
401
- SolarWindsAPM::Config[:sidekiqclient][:collect_backtraces] = false
402
- SolarWindsAPM::Config[:sidekiqworker][:collect_backtraces] = false
403
- SolarWindsAPM::Config[:sinatra][:collect_backtraces] = true
404
- SolarWindsAPM::Config[:typhoeus][:collect_backtraces] = false
405
-
176
+ # Tracecontext in sql
177
+ #
178
+ # Appending trace contenxt (i.e. traceparent) as an sql comment
179
+ # at the beginning or end of sql. This modified sql will be
180
+ # sent to sql server for trace correlation.
181
+ #
182
+ # Example:
183
+ # SELECT `posts`.* FROM `posts` /*traceparent=00-a448f096d441e167d12ebd32a927c1a5-a29655a47e430119-01*/
184
+ #
185
+ # This option can add a small overhead for prepared statements since the traceparent value is unique per execution.
186
+ # This feature uses marginalia, see its caveat and possible workaround
187
+ # https://github.com/basecamp/marginalia/blob/master/README.md#prepared-statements
188
+ #
189
+ SolarWindsAPM::Config[:tag_sql] = false
406
190
  end
@@ -0,0 +1,148 @@
1
+ #--
2
+ # Copyright (c) SolarWinds, LLC.
3
+ # All rights reserved.
4
+ #++
5
+ module SolarWindsAPM
6
+ module API
7
+ module CurrentTraceInfo
8
+ # Creates an instance of {TraceInfo} with instance methods:<br>
9
+ # {TraceInfo#trace_id}<br>
10
+ # {TraceInfo#span_id}<br>
11
+ # {TraceInfo#trace_flags}<br>
12
+ # {TraceInfo#for_log}<br>
13
+ # {TraceInfo#hash_for_log}
14
+ #
15
+ # The <tt>SolarWindsAPM::Config[:log_traceId]</tt> configuration setting for automatic trace context in logs affects the
16
+ # return value of methods in this module.
17
+ #
18
+ # The following options are available:<br>
19
+ # <tt>:never</tt> (default)<br>
20
+ # <tt>:sampled</tt> only include the Trace ID of sampled requests<br>
21
+ # <tt>:traced</tt> include the Trace ID for all traced requests<br>
22
+ # <tt>:always</tt> always add a Trace ID, it will be "trace_id=00000000000000000000000000000000 span_id=0000000000000000 trace_flags=00 resource.service.name=otel_service_name" when there is no tracing context.
23
+ #
24
+ # === Example:
25
+ #
26
+ # trace = SolarWindsAPM::API.current_trace_info
27
+ # trace.for_log # 'trace_id=7435a9fe510ae4533414d425dadf4e18 span_id=49e60702469db05f trace_flags=01 resource.service.name=otel_service_name' or '' depends on Config
28
+ # trace.hash_for_log # { trace_id: '7435a9fe510ae4533414d425dadf4e18',
29
+ # span_id: '49e60702469db05f',
30
+ # trace_flags: '',
31
+ # resource.service.name: 'otel_service_name' } or {} depends on Config
32
+ #
33
+ #
34
+ # Configure trace info injection with lograge:
35
+ #
36
+ # Lograge.custom_options = lambda do |event|
37
+ # SolarWindsAPM::API.current_trace_info.hash_for_log
38
+ # end
39
+ #
40
+ def current_trace_info
41
+ TraceInfo.new
42
+ end
43
+
44
+ # @attr [String] tracestring
45
+ # @attr [String] trace_id
46
+ # @attr [String] span_id
47
+ # @attr [String] trace_flags
48
+ # @attr [Boolean] do_log
49
+ class TraceInfo
50
+ attr_reader :tracestring, :trace_id, :span_id, :trace_flags, :do_log
51
+
52
+ REGEXP = /^(?<tracestring>(?<version>[a-f0-9]{2})-(?<trace_id>[a-f0-9]{32})-(?<span_id>[a-f0-9]{16})-(?<flags>[a-f0-9]{2}))$/.freeze
53
+ private_constant :REGEXP
54
+
55
+ def initialize
56
+ @trace_id, @span_id, @trace_flags, @tracestring = current_span
57
+ @service_name = ENV['OTEL_SERVICE_NAME']
58
+ @do_log = log? # true if the tracecontext should be added to logs
59
+ end
60
+
61
+ # for_log returns a string in the format
62
+ # 'trace_id=<trace_id> span_id=<span_id> trace_flags=<trace_flags>' or empty string.
63
+ #
64
+ # An empty string is returned depending on the setting for
65
+ # <tt>SolarWindsAPM::Config[:log_traceId]</tt>, which can be :never,
66
+ # :sampled, :traced, or :always.
67
+ #
68
+ # === Example:
69
+ #
70
+ # trace = SolarWindsAPM::API.current_trace_info
71
+ # trace.for_log # 'trace_id=7435a9fe510ae4533414d425dadf4e18 span_id=49e60702469db05f trace_flags=01 resource.service.name=otel_service_name' or '' depends on Config
72
+ #
73
+ # === Returns:
74
+ # * String
75
+ #
76
+ def for_log
77
+ @for_log ||= @do_log ? "trace_id=#{@trace_id} span_id=#{@span_id} trace_flags=#{@trace_flags} resource.service.name=#{@service_name}" : ''
78
+ end
79
+
80
+ # Construct the trace_id, span_id, trace_flags and resource.service.name for log insertion.
81
+ #
82
+ # === Example:
83
+ #
84
+ # trace = SolarWindsAPM::API.current_trace_info
85
+ # trace.hash_for_log # { trace_id: '7435a9fe510ae4533414d425dadf4e18',
86
+ # span_id: '49e60702469db05f',
87
+ # trace_flags: 01,
88
+ # resource.service.name: 'otel_service_name' } or {} depends on Config
89
+ #
90
+ # # For lograge:
91
+ # Lograge.custom_options = lambda do |event|
92
+ # SolarWindsAPM::API.current_trace_info.hash_for_log
93
+ # end
94
+ #
95
+ # === Returns:
96
+ # * Hash
97
+ #
98
+ def hash_for_log
99
+ @hash_for_log = {}
100
+ @hash_for_log = {trace_id: @trace_id, span_id: @span_id, trace_flags: @trace_flags, service_name: @service_name} if @do_log
101
+ end
102
+
103
+ private
104
+
105
+ def current_span
106
+ span = ::OpenTelemetry::Trace.current_span if defined?(::OpenTelemetry::Trace)
107
+ trace_id = span.context.hex_trace_id
108
+ span_id = span.context.hex_span_id
109
+ trace_flags = span.context.trace_flags.sampled?? '01' : '00'
110
+ tracestring = "00-#{trace_id}-#{span_id}-#{trace_flags}"
111
+
112
+ [trace_id, span_id, trace_flags, tracestring]
113
+ end
114
+
115
+ # if true the trace info should be added to the log message
116
+ def log?
117
+ case SolarWindsAPM::Config[:log_traceId]
118
+ when :never, nil
119
+ false
120
+ when :always
121
+ true
122
+ when :traced
123
+ valid?(@tracestring)
124
+ when :sampled
125
+ sampled?(@tracestring)
126
+ end
127
+ end
128
+
129
+ # un-initialized (all 0 trace-id) tracestrings are not valid
130
+ def valid?(tracestring)
131
+ matches = REGEXP.match(tracestring)
132
+
133
+ matches && matches[:trace_id] != ("0" * 32)
134
+ end
135
+
136
+ def sampled?(tracestring)
137
+ matches = REGEXP.match(tracestring)
138
+
139
+ matches && matches[:flags][-1].to_i & 1 == 1
140
+ end
141
+
142
+ def split(tracestring)
143
+ REGEXP.match(tracestring)
144
+ end
145
+ end
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,30 @@
1
+ module SolarWindsAPM
2
+ module API
3
+ module Tracing
4
+ # Wait for SolarWinds to be ready to send traces.
5
+ #
6
+ # This may be useful in short lived background processes when it is important to capture
7
+ # information during the whole time the process is running. Usually SolarWinds doesn't block an
8
+ # application while it is starting up.
9
+ #
10
+ # === Argument:
11
+ #
12
+ # * +wait_milliseconds+ - (int, default 3000) the maximum time to wait in milliseconds
13
+ #
14
+ # === Example:
15
+ #
16
+ # unless SolarWindsAPM::API.solarwinds_ready?(10_000)
17
+ # Logger.info "SolarWindsAPM not ready after 10 seconds, no metrics will be sent"
18
+ # end
19
+ #
20
+ # === Returns:
21
+ # * Boolean
22
+ #
23
+ def solarwinds_ready?(wait_milliseconds=3000)
24
+ return false unless SolarWindsAPM.loaded
25
+
26
+ SolarWindsAPM::Context.isReady(wait_milliseconds) == 1
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,57 @@
1
+ module SolarWindsAPM
2
+ module API
3
+ module TransactionName
4
+ # Provide a custom transaction name
5
+ #
6
+ # The SolarWindsAPM gem tries to create meaningful transaction names from controller+action
7
+ # or something similar depending on the framework used. However, you may want to override the
8
+ # transaction name to better describe your instrumented operation.
9
+ #
10
+ # === Argument:
11
+ #
12
+ # * +custom_name+ - A non-empty string with the custom transaction name
13
+ #
14
+ # === Example:
15
+ #
16
+ # class DogfoodsController < ApplicationController
17
+ #
18
+ # def create
19
+ # @dogfood = Dogfood.new(params.permit(:brand, :name))
20
+ # @dogfood.save
21
+ #
22
+ # SolarWindsAPM::API.set_transaction_name("dogfoodscontroller.create_for_#{params[:brand]}")
23
+ #
24
+ # redirect_to @dogfood
25
+ # end
26
+ #
27
+ # end
28
+ #
29
+ # === Returns:
30
+ # * Boolean
31
+ #
32
+ def set_transaction_name(custom_name=nil)
33
+
34
+ return false if custom_name.nil? || custom_name.empty?
35
+
36
+ solarwinds_processor = SolarWindsAPM::OTelConfig.class_variable_get(:@@config)[:span_processor]
37
+ if solarwinds_processor.nil?
38
+ SolarWindsAPM.logger.warn {"[#{self.name}/#{__method__}] Solarwinds processor is missing. Set transaction name failed."}
39
+ return false
40
+ end
41
+
42
+ entry_trace_id = ::OpenTelemetry::Baggage.value(::SolarWindsAPM::Constants::INTL_SWO_CURRENT_TRACE_ID)
43
+ entry_span_id = ::OpenTelemetry::Baggage.value(::SolarWindsAPM::Constants::INTL_SWO_CURRENT_SPAN_ID)
44
+
45
+ if entry_trace_id.nil? || entry_span_id.nil?
46
+ SolarWindsAPM.logger.warn {"[#{self.name}/#{__method__}] Cannot cache custom transaction name #{custom_name} because OTel service entry span not started; ignoring"}
47
+ return false
48
+ end
49
+
50
+ trace_span_id = "#{entry_trace_id}-#{entry_span_id}"
51
+ solarwinds_processor.txn_manager.set(trace_span_id,custom_name)
52
+ SolarWindsAPM.logger.debug {"[#{self.name}/#{__method__}] Cached custom transaction name for #{trace_span_id} as #{custom_name}"}
53
+ true
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,21 +1,14 @@
1
1
  # Copyright (c) 2016 SolarWinds, LLC.
2
2
  # All rights reserved.
3
3
 
4
- module SolarWindsAPM
4
+ require_relative './api/transaction_name'
5
+ require_relative './api/current_trace_info'
6
+ require_relative './api/tracing'
5
7
 
8
+ module SolarWindsAPM
6
9
  module API
7
- extend SolarWindsAPM::API::Logging
8
- extend SolarWindsAPM::API::Metrics
9
- extend SolarWindsAPM::API::LayerInit
10
- extend SolarWindsAPM::API::Util
11
-
12
- require_relative './sdk/trace_context_headers'
13
- require_relative './sdk/tracing'
14
- require_relative './sdk/custom_metrics'
15
- require_relative './sdk/current_trace_info'
16
- require_relative './sdk/logging' # to make sure it is loaded <- not very elegant
17
-
18
- extend SolarWindsAPM::SDK::Tracing
19
- extend SolarWindsAPM::SDK::CustomMetrics
10
+ extend SolarWindsAPM::API::TransactionName
11
+ extend SolarWindsAPM::API::CurrentTraceInfo
12
+ extend SolarWindsAPM::API::Tracing
20
13
  end
21
- end
14
+ end