solarwinds_apm 5.1.9 → 6.0.0.preV2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +28 -55
  3. data/ext/oboe_metal/extconf.rb +37 -41
  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/init_solarwinds_apm.cc +0 -6
  10. data/ext/oboe_metal/src/oboe_debug.h +1 -0
  11. data/lib/oboe_metal.rb +116 -80
  12. data/lib/rails/generators/solarwinds_apm/install_generator.rb +1 -5
  13. data/lib/rails/generators/solarwinds_apm/templates/solarwinds_apm_initializer.rb +42 -267
  14. data/lib/solarwinds_apm/api/current_trace_info.rb +148 -0
  15. data/lib/solarwinds_apm/api/tracing.rb +30 -0
  16. data/lib/solarwinds_apm/api/transaction_name.rb +58 -0
  17. data/lib/solarwinds_apm/api.rb +8 -15
  18. data/lib/solarwinds_apm/base.rb +4 -131
  19. data/lib/solarwinds_apm/config.rb +101 -174
  20. data/lib/solarwinds_apm/constants.rb +32 -0
  21. data/lib/solarwinds_apm/logger.rb +1 -1
  22. data/lib/solarwinds_apm/noop/context.rb +2 -5
  23. data/lib/solarwinds_apm/noop/metadata.rb +1 -2
  24. data/lib/solarwinds_apm/oboe_init_options.rb +74 -38
  25. data/lib/solarwinds_apm/opentelemetry/solarwinds_exporter.rb +204 -0
  26. data/lib/solarwinds_apm/opentelemetry/solarwinds_processor.rb +166 -0
  27. data/lib/solarwinds_apm/opentelemetry/solarwinds_propagator.rb +92 -0
  28. data/lib/solarwinds_apm/opentelemetry/solarwinds_response_propagator.rb +72 -0
  29. data/lib/solarwinds_apm/opentelemetry/solarwinds_sampler.rb +335 -0
  30. data/lib/solarwinds_apm/opentelemetry.rb +8 -0
  31. data/lib/solarwinds_apm/otel_config.rb +161 -0
  32. data/lib/solarwinds_apm/{inst → support}/logger_formatter.rb +5 -6
  33. data/lib/solarwinds_apm/{inst → support}/logging_log_event.rb +3 -6
  34. data/lib/solarwinds_apm/{inst → support}/lumberjack_formatter.rb +1 -4
  35. data/lib/solarwinds_apm/support/oboe_tracing_mode.rb +27 -0
  36. data/lib/solarwinds_apm/support/swomarginalia/LICENSE +20 -0
  37. data/lib/solarwinds_apm/support/swomarginalia/README.md +41 -0
  38. data/lib/solarwinds_apm/support/swomarginalia/comment.rb +205 -0
  39. data/lib/solarwinds_apm/support/swomarginalia/load_swomarginalia.rb +48 -0
  40. data/lib/solarwinds_apm/support/swomarginalia/railtie.rb +22 -0
  41. data/lib/solarwinds_apm/support/swomarginalia/swomarginalia.rb +86 -0
  42. data/lib/solarwinds_apm/support/transaction_cache.rb +24 -0
  43. data/lib/solarwinds_apm/support/transaction_settings.rb +26 -209
  44. data/lib/solarwinds_apm/support/transformer.rb +56 -0
  45. data/lib/solarwinds_apm/support/txn_name_manager.rb +25 -0
  46. data/lib/solarwinds_apm/support/x_trace_options.rb +42 -26
  47. data/lib/solarwinds_apm/support.rb +37 -10
  48. data/lib/solarwinds_apm/support_report.rb +10 -32
  49. data/lib/solarwinds_apm/thread_local.rb +1 -1
  50. data/lib/solarwinds_apm/version.rb +4 -4
  51. data/lib/solarwinds_apm.rb +29 -25
  52. metadata +63 -123
  53. data/.dockerignore +0 -5
  54. data/.gitignore +0 -58
  55. data/.rubocop.yml +0 -29
  56. data/.whitesource +0 -22
  57. data/.yardopts +0 -7
  58. data/CHANGELOG-appoptics.md +0 -766
  59. data/CHANGELOG.md +0 -82
  60. data/CONFIG.md +0 -31
  61. data/Gemfile +0 -15
  62. data/README.md +0 -385
  63. data/bin/solarwinds_apm_config +0 -15
  64. data/examples/prepend.rb +0 -13
  65. data/examples/sdk_examples.rb +0 -158
  66. data/ext/oboe_metal/README.md +0 -69
  67. data/ext/oboe_metal/extconf_local.rb +0 -75
  68. data/ext/oboe_metal/lib/.keep +0 -0
  69. data/ext/oboe_metal/noop/noop.c +0 -8
  70. data/ext/oboe_metal/src/README.md +0 -6
  71. data/ext/oboe_metal/src/frames.cc +0 -247
  72. data/ext/oboe_metal/src/frames.h +0 -40
  73. data/ext/oboe_metal/src/logging.cc +0 -97
  74. data/ext/oboe_metal/src/logging.h +0 -34
  75. data/ext/oboe_metal/src/profiling.cc +0 -435
  76. data/ext/oboe_metal/src/profiling.h +0 -78
  77. data/ext/oboe_metal/test/CMakeLists.txt +0 -53
  78. data/ext/oboe_metal/test/FindGMock.cmake +0 -43
  79. data/ext/oboe_metal/test/README.md +0 -56
  80. data/ext/oboe_metal/test/frames_test.cc +0 -164
  81. data/ext/oboe_metal/test/profiling_test.cc +0 -93
  82. data/ext/oboe_metal/test/ruby_inc_dir.rb +0 -8
  83. data/ext/oboe_metal/test/ruby_prefix.rb +0 -8
  84. data/ext/oboe_metal/test/ruby_test_helper.rb +0 -67
  85. data/ext/oboe_metal/test/test.h +0 -11
  86. data/ext/oboe_metal/test/test_main.cc +0 -32
  87. data/init.rb +0 -4
  88. data/lib/solarwinds_apm/api/layerinit.rb +0 -41
  89. data/lib/solarwinds_apm/api/logging.rb +0 -356
  90. data/lib/solarwinds_apm/api/memcache.rb +0 -37
  91. data/lib/solarwinds_apm/api/metrics.rb +0 -63
  92. data/lib/solarwinds_apm/api/util.rb +0 -98
  93. data/lib/solarwinds_apm/frameworks/grape.rb +0 -96
  94. data/lib/solarwinds_apm/frameworks/padrino.rb +0 -78
  95. data/lib/solarwinds_apm/frameworks/rails/inst/action_controller.rb +0 -100
  96. data/lib/solarwinds_apm/frameworks/rails/inst/action_controller5.rb +0 -50
  97. data/lib/solarwinds_apm/frameworks/rails/inst/action_controller_api.rb +0 -50
  98. data/lib/solarwinds_apm/frameworks/rails/inst/action_view.rb +0 -88
  99. data/lib/solarwinds_apm/frameworks/rails/inst/active_record.rb +0 -26
  100. data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/mysql2.rb +0 -29
  101. data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/postgresql.rb +0 -22
  102. data/lib/solarwinds_apm/frameworks/rails/inst/connection_adapters/utils5x.rb +0 -103
  103. data/lib/solarwinds_apm/frameworks/rails/inst/logger_formatters.rb +0 -14
  104. data/lib/solarwinds_apm/frameworks/rails.rb +0 -100
  105. data/lib/solarwinds_apm/frameworks/sinatra.rb +0 -96
  106. data/lib/solarwinds_apm/inst/bunny-client.rb +0 -157
  107. data/lib/solarwinds_apm/inst/bunny-consumer.rb +0 -102
  108. data/lib/solarwinds_apm/inst/curb.rb +0 -289
  109. data/lib/solarwinds_apm/inst/dalli.rb +0 -89
  110. data/lib/solarwinds_apm/inst/delayed_job.rb +0 -100
  111. data/lib/solarwinds_apm/inst/excon.rb +0 -113
  112. data/lib/solarwinds_apm/inst/faraday.rb +0 -96
  113. data/lib/solarwinds_apm/inst/graphql.rb +0 -206
  114. data/lib/solarwinds_apm/inst/grpc_client.rb +0 -147
  115. data/lib/solarwinds_apm/inst/grpc_server.rb +0 -119
  116. data/lib/solarwinds_apm/inst/httpclient.rb +0 -182
  117. data/lib/solarwinds_apm/inst/memcached.rb +0 -86
  118. data/lib/solarwinds_apm/inst/mongo.rb +0 -246
  119. data/lib/solarwinds_apm/inst/mongo2.rb +0 -225
  120. data/lib/solarwinds_apm/inst/moped.rb +0 -466
  121. data/lib/solarwinds_apm/inst/net_http.rb +0 -60
  122. data/lib/solarwinds_apm/inst/rack.rb +0 -223
  123. data/lib/solarwinds_apm/inst/rack_cache.rb +0 -35
  124. data/lib/solarwinds_apm/inst/redis.rb +0 -280
  125. data/lib/solarwinds_apm/inst/redis_v4.rb +0 -273
  126. data/lib/solarwinds_apm/inst/resque.rb +0 -129
  127. data/lib/solarwinds_apm/inst/rest-client.rb +0 -43
  128. data/lib/solarwinds_apm/inst/sequel.rb +0 -241
  129. data/lib/solarwinds_apm/inst/sidekiq-client.rb +0 -63
  130. data/lib/solarwinds_apm/inst/sidekiq-worker.rb +0 -64
  131. data/lib/solarwinds_apm/inst/typhoeus.rb +0 -90
  132. data/lib/solarwinds_apm/instrumentation.rb +0 -22
  133. data/lib/solarwinds_apm/loading.rb +0 -65
  134. data/lib/solarwinds_apm/noop/profiling.rb +0 -21
  135. data/lib/solarwinds_apm/ruby.rb +0 -35
  136. data/lib/solarwinds_apm/sdk/current_trace_info.rb +0 -123
  137. data/lib/solarwinds_apm/sdk/custom_metrics.rb +0 -94
  138. data/lib/solarwinds_apm/sdk/logging.rb +0 -37
  139. data/lib/solarwinds_apm/sdk/trace_context_headers.rb +0 -69
  140. data/lib/solarwinds_apm/sdk/tracing.rb +0 -432
  141. data/lib/solarwinds_apm/support/profiling.rb +0 -25
  142. data/lib/solarwinds_apm/support/trace_context.rb +0 -53
  143. data/lib/solarwinds_apm/support/trace_state.rb +0 -69
  144. data/lib/solarwinds_apm/support/trace_string.rb +0 -89
  145. data/lib/solarwinds_apm/support/transaction_metrics.rb +0 -67
  146. data/lib/solarwinds_apm/test.rb +0 -165
  147. data/lib/solarwinds_apm/util.rb +0 -426
  148. data/log/.keep +0 -0
  149. data/log/postgresql/.keep +0 -0
  150. data/solarwinds_apm.gemspec +0 -55
  151. data/yardoc_frontpage.md +0 -24
@@ -2,6 +2,7 @@
2
2
  # All rights reserved.
3
3
 
4
4
  module SolarWindsAPM
5
+ # InstallGenerator
5
6
  class InstallGenerator < ::Rails::Generators::Base
6
7
  source_root File.join(File.dirname(__FILE__), 'templates')
7
8
  desc "Copies a SolarWindsAPM gem initializer file to your application."
@@ -9,9 +10,6 @@ module SolarWindsAPM
9
10
  @namespace = "solarwinds_apm:install"
10
11
 
11
12
  def copy_initializer
12
- # Set defaults
13
- @verbose = 'false'
14
-
15
13
  print_header
16
14
  print_footer
17
15
 
@@ -20,7 +18,6 @@ module SolarWindsAPM
20
18
 
21
19
  private
22
20
 
23
- # rubocop:disable Metrics/MethodLength
24
21
  def print_header
25
22
  say ""
26
23
  say shell.set_color "Welcome to the SolarWindsAPM Ruby instrumentation setup.", :green, :bold
@@ -34,7 +31,6 @@ module SolarWindsAPM
34
31
  say "More information on instrumenting Ruby applications can be found here:"
35
32
  say "https://documentation.solarwinds.com/en/success_center/observability/default.htm#cshid=config-ruby-agent"
36
33
  end
37
- # rubocop:enable Metrics/MethodLength
38
34
 
39
35
  def print_footer
40
36
  say ""
@@ -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>
@@ -71,15 +69,6 @@ if defined?(SolarWindsAPM::Config)
71
69
  # The Ruby logger can afterwards be changed to a different level, e.g:
72
70
  # SolarWindsAPM.logger.level = Logger::INFO
73
71
 
74
- #
75
- # Set SW_APM_GEM_VERBOSE
76
- # This setting will be overridden if SW_APM_GEM_VERBOSE is set as an environment variable
77
- #
78
- # On startup the components that are being instrumented will be reported if this is set to true.
79
- # If true and the log level is 4 or higher this may create extra debug log messages
80
- #
81
- SolarWindsAPM::Config[:verbose] = false
82
-
83
72
  #
84
73
  # Turn Tracing on or off
85
74
  #
@@ -88,19 +77,8 @@ if defined?(SolarWindsAPM::Config)
88
77
  # sampling rate and metrics are reported.
89
78
  # :disabled means that there is no sampling and metrics are not reported.
90
79
  #
91
- # The values :always and :never are deprecated
92
- #
93
80
  SolarWindsAPM::Config[:tracing_mode] = :enabled
94
81
 
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
82
  #
105
83
  # Trace Context in Logs
106
84
  #
@@ -109,123 +87,25 @@ if defined?(SolarWindsAPM::Config)
109
87
  # the current Trace ID in log messages.
110
88
  #
111
89
  # The added string will look like:
112
- # "trace_id=7435a9fe510ae4533414d425dadf4e18 span_id=49e60702469db05f trace_flags=00"
90
+ # "trace_id=7435a9fe510ae4533414d425dadf4e18 span_id=49e60702469db05f trace_flags=00 resource.service.name=service_name"
113
91
  #
114
92
  # The following options are available:
115
93
  # :never (default)
116
94
  # :sampled only include the Trace ID of sampled requests
117
95
  # :traced include the Trace ID for all traced requests
118
96
  # :always always add a Trace ID, it will be
119
- # "trace_id=00000000000000000000000000000000 span_id=0000000000000000 trace_flags=00"
97
+ # "trace_id=00000000000000000000000000000000 span_id=0000000000000000 trace_flags=00 resource.service.name=otel_service_name"
120
98
  # when there is no tracing context.
121
99
  #
122
100
  SolarWindsAPM::Config[:log_traceId] = :never
123
101
 
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
102
  #
220
103
  # Transaction Settings
221
104
  #
222
105
  # Use this configuration to add exceptions to the global tracing mode and
223
106
  # disable/enable metrics and traces for certain transactions.
224
107
  #
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']`
108
+ # Currently allowed array of hash
229
109
  #
230
110
  # and the hashes within the :url list either:
231
111
  # :extensions takes an array of strings for filtering (not regular expressions!)
@@ -240,31 +120,20 @@ if defined?(SolarWindsAPM::Config)
240
120
  # Be careful not to add too many :regexp configurations as they will slow
241
121
  # down execution.
242
122
  #
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
123
+ SolarWindsAPM::Config[:transaction_settings] = [
124
+ # {
125
+ # extensions: %w[long_job],
126
+ # tracing: :disabled
127
+ # },
128
+ # {
129
+ # regexp: '^.*\/long_job\/.*$',
130
+ # opts: Regexp::IGNORECASE,
131
+ # tracing: :disabled
132
+ # },
133
+ # {
134
+ # regexp: /batch/,
135
+ # }
136
+ ]
268
137
 
269
138
  #
270
139
  # EC2 Metadata Fetching Timeout
@@ -276,131 +145,37 @@ if defined?(SolarWindsAPM::Config)
276
145
  #
277
146
  SolarWindsAPM::Config[:ec2_metadata_timeout] = 1000
278
147
 
279
-
280
- #############################################
281
- ## SETTINGS FOR INDIVIDUAL GEMS/FRAMEWORKS ##
282
- #############################################
283
-
284
- #
285
- # Bunny Controller and Action
286
148
  #
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.
149
+ # Trigger Trace Mode
292
150
  #
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.
151
+ # Trace options is a custom HTTP header X-Trace-Options that can be set on a request to carry additional information
152
+ # to the agents, one such option being trigger-trace which we’ll call a trigger trace request.
299
153
  #
300
- SolarWindsAPM::Config[:bunnyconsumer][:controller] = :app_id
301
- SolarWindsAPM::Config[:bunnyconsumer][:action] = :type
302
-
303
- #
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
154
+ SolarWindsAPM::Config[:trigger_tracing_mode] = 'enabled'
343
155
 
344
156
  #
345
157
  # Argument logging
346
158
  #
347
- #
348
159
  # For http requests:
349
160
  # By default the query string parameters are included in the URLs reported.
350
161
  # Set :log_args to false and instrumentation will stop collecting
351
162
  # and reporting query arguments from URLs.
352
163
  #
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
164
+ SolarWindsAPM::Config[:log_args] = true
365
165
 
366
166
  #
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
-
167
+ # Tracecontext in sql
168
+ #
169
+ # Appending trace contenxt (i.e. traceparent) as an sql comment
170
+ # at the beginning or end of sql. This modified sql will be
171
+ # sent to sql server for trace correlation.
172
+ #
173
+ # Example:
174
+ # SELECT `posts`.* FROM `posts` /*traceparent=00-a448f096d441e167d12ebd32a927c1a5-a29655a47e430119-01*/
175
+ #
176
+ # This option can add a small overhead for prepared statements since the traceparent value is unique per execution.
177
+ # This feature uses marginalia, see its caveat and possible workaround
178
+ # https://github.com/basecamp/marginalia/blob/master/README.md#prepared-statements
179
+ #
180
+ SolarWindsAPM::Config[:tag_sql] = false
406
181
  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}))$/
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,58 @@
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
+ return true if SolarWindsAPM::Context.toString == '00-00000000000000000000000000000000-0000000000000000-00' # noop
36
+
37
+ solarwinds_processor = SolarWindsAPM::OTelConfig.class_variable_get(:@@config)[:span_processor]
38
+ if solarwinds_processor.nil?
39
+ SolarWindsAPM.logger.warn {"[#{name}/#{__method__}] Solarwinds processor is missing. Set transaction name failed."}
40
+ return false
41
+ end
42
+
43
+ entry_trace_id = ::OpenTelemetry::Baggage.value(::SolarWindsAPM::Constants::INTL_SWO_CURRENT_TRACE_ID)
44
+ entry_span_id = ::OpenTelemetry::Baggage.value(::SolarWindsAPM::Constants::INTL_SWO_CURRENT_SPAN_ID)
45
+
46
+ if entry_trace_id.nil? || entry_span_id.nil?
47
+ SolarWindsAPM.logger.warn {"[#{name}/#{__method__}] Cannot cache custom transaction name #{custom_name} because OTel service entry span not started; ignoring"}
48
+ return false
49
+ end
50
+
51
+ trace_span_id = "#{entry_trace_id}-#{entry_span_id}"
52
+ solarwinds_processor.txn_manager.set(trace_span_id,custom_name)
53
+ SolarWindsAPM.logger.debug {"[#{name}/#{__method__}] Cached custom transaction name for #{trace_span_id} as #{custom_name}"}
54
+ true
55
+ end
56
+ end
57
+ end
58
+ end