elastic-apm 4.7.3 → 4.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.ci/.exclude.yml +21 -82
  3. data/.ci/.framework.yml +1 -4
  4. data/.ci/.ruby.yml +1 -1
  5. data/.ci/updatecli/values.d/apm-data-spec.yml +1 -0
  6. data/.ci/updatecli/values.d/apm-gherkin.yml +1 -0
  7. data/.ci/updatecli/values.d/apm-json-specs.yml +1 -0
  8. data/.ci/updatecli/values.d/scm.yml +10 -0
  9. data/.ci/updatecli/values.d/update-compose.yml +3 -0
  10. data/.github/PULL_REQUEST_TEMPLATE.md +2 -2
  11. data/.github/dependabot.yml +24 -19
  12. data/.github/workflows/README.md +1 -2
  13. data/.github/workflows/addToProject.yml +16 -2
  14. data/.github/workflows/ci.yml +6 -6
  15. data/.github/workflows/docs-build.yml +19 -0
  16. data/.github/workflows/docs-cleanup.yml +14 -0
  17. data/.github/workflows/github-commands-comment.yml +38 -0
  18. data/.github/workflows/microbenchmark.yml +7 -24
  19. data/.github/workflows/release.yml +39 -24
  20. data/.github/workflows/run-matrix.yml +21 -12
  21. data/.github/workflows/test-reporter.yml +4 -3
  22. data/.github/workflows/updatecli.yml +45 -13
  23. data/Gemfile +13 -0
  24. data/bin/dev +2 -2
  25. data/docs/docset.yml +9 -0
  26. data/docs/reference/advanced-topics.md +12 -0
  27. data/docs/reference/api-reference.md +422 -0
  28. data/docs/reference/configuration.md +734 -0
  29. data/docs/{context.asciidoc → reference/context.md} +21 -21
  30. data/docs/reference/custom-instrumentation.md +72 -0
  31. data/docs/{getting-started-rack.asciidoc → reference/getting-started-rack.md} +20 -29
  32. data/docs/reference/getting-started-rails.md +27 -0
  33. data/docs/reference/graphql.md +21 -0
  34. data/docs/reference/index.md +24 -0
  35. data/docs/{logs.asciidoc → reference/logs.md} +38 -56
  36. data/docs/reference/metrics.md +199 -0
  37. data/docs/reference/opentracing-api.md +70 -0
  38. data/docs/reference/performance-tuning.md +71 -0
  39. data/docs/reference/set-up-apm-ruby-agent.md +16 -0
  40. data/docs/reference/supported-technologies.md +128 -0
  41. data/docs/reference/toc.yml +22 -0
  42. data/docs/reference/upgrading.md +19 -0
  43. data/docs/release-notes/index.md +166 -0
  44. data/docs/release-notes/known-issues.md +24 -0
  45. data/docs/release-notes/toc.yml +3 -0
  46. data/lib/elastic_apm/context_builder.rb +5 -2
  47. data/lib/elastic_apm/spies/sidekiq.rb +2 -1
  48. data/lib/elastic_apm/stacktrace_builder.rb +3 -3
  49. data/lib/elastic_apm/version.rb +1 -1
  50. data/updatecli-compose.yaml +23 -0
  51. metadata +37 -36
  52. data/.ci/snapshoty.yml +0 -33
  53. data/.ci/updatecli/updatecli.d/update-gherkin-specs.yml +0 -84
  54. data/.ci/updatecli/updatecli.d/update-json-specs.yml +0 -84
  55. data/.ci/updatecli/updatecli.d/update-specs.yml +0 -86
  56. data/.ci/updatecli/values.yml +0 -14
  57. data/.github/workflows/coverage-reporter.yml +0 -34
  58. data/.github/workflows/opentelemetry.yml +0 -22
  59. data/.github/workflows/snapshoty.yml +0 -35
  60. data/CHANGELOG.asciidoc +0 -990
  61. data/docs/advanced.asciidoc +0 -14
  62. data/docs/api.asciidoc +0 -487
  63. data/docs/configuration.asciidoc +0 -889
  64. data/docs/custom-instrumentation.asciidoc +0 -80
  65. data/docs/debugging.asciidoc +0 -44
  66. data/docs/getting-started-rails.asciidoc +0 -30
  67. data/docs/graphql.asciidoc +0 -23
  68. data/docs/index.asciidoc +0 -38
  69. data/docs/introduction.asciidoc +0 -36
  70. data/docs/metrics.asciidoc +0 -235
  71. data/docs/opentracing.asciidoc +0 -94
  72. data/docs/performance-tuning.asciidoc +0 -106
  73. data/docs/redirects.asciidoc +0 -9
  74. data/docs/release-notes.asciidoc +0 -15
  75. data/docs/set-up.asciidoc +0 -19
  76. data/docs/supported-technologies.asciidoc +0 -157
  77. data/docs/upgrading.asciidoc +0 -18
  78. /data/docs/{images → reference/images}/dynamic-config.svg +0 -0
@@ -1,14 +0,0 @@
1
- ifdef::env-github[]
2
- NOTE: For the best reading experience,
3
- please view this documentation at
4
- https://www.elastic.co/guide/en/apm/agent/ruby/current/introduction.html[elastic.co]
5
- endif::[]
6
-
7
- [[advanced]]
8
- == Advanced Topics
9
-
10
- * <<context>>
11
- * <<custom-instrumentation>>
12
-
13
- include::./context.asciidoc[]
14
- include::./custom-instrumentation.asciidoc[]
data/docs/api.asciidoc DELETED
@@ -1,487 +0,0 @@
1
- ifdef::env-github[]
2
- NOTE: For the best reading experience,
3
- please view this documentation at
4
- https://www.elastic.co/guide/en/apm/agent/ruby/current/introduction.html[elastic.co]
5
- endif::[]
6
-
7
- [[api]]
8
- == API reference
9
-
10
- Although most usage is covered automatically, Elastic APM also has a public
11
- API that allows custom usage.
12
-
13
- [float]
14
- [[agent-life-cycle]]
15
- === Agent life cycle
16
-
17
- Controlling when the agent starts and stops.
18
-
19
- [float]
20
- [[api-agent-start]]
21
- ==== `ElasticAPM.start`
22
-
23
- To create and start an ElasticAPM agent use `ElasticAPM.start`:
24
-
25
- [source,ruby]
26
- ----
27
- ElasticAPM.start(server_url: 'http://localhost:8200')
28
- ----
29
-
30
- * `config`: An optional hash or `ElasticAPM::Config` instance with configuration
31
- options. See <<configuration,Configuration>>.
32
-
33
- If you are using <<getting-started-rails,Ruby on Rails>> this is done automatically for you.
34
- If you choose not to require the `elastic_apm` gem and instead want to start the
35
- agent and hook into Rails manually, see <<rails-start,hooking into Rails explicitly>>.
36
- If you're not using Rails, see <<getting-started-rack,Getting started with Rack>>.
37
-
38
- [float]
39
- [[api-agent-stop]]
40
- ==== `ElasticAPM.stop`
41
-
42
- Stop the currently running agent. Use this inside `at_exit` in your
43
- <<getting-started-rack,Rack app>> to gracefully shut down.
44
-
45
- [float]
46
- [[api-agent-restart]]
47
- ==== `ElasticAPM.restart`
48
-
49
- If the agent is already running, this method will stop and start the agent.
50
-
51
- If the agent is not already running, this method will start the agent.
52
-
53
- A config can be passed to the method that will be used to start the agent. If the agent
54
- is already running and no config is passed to the `#restart` method, the running agent's
55
- config will be used.
56
-
57
- [float]
58
- [[api-agent-running]]
59
- ==== `ElasticAPM.running?`
60
-
61
- Returns whether the ElasticAPM Agent is currently running.
62
-
63
- [float]
64
- [[api-agent-agent]]
65
- ==== `ElasticAPM.agent`
66
-
67
- Returns the currently running agent or nil.
68
-
69
- [float]
70
- === Instrumentation
71
-
72
- [float]
73
- [[api-agent-current-transaction]]
74
- ==== `ElasticAPM.current_transaction`
75
-
76
- Returns the current `ElasticAPM::Transaction` or nil.
77
-
78
- [float]
79
- [[api-agent-start_transaction]]
80
- ==== `ElasticAPM.start_transaction`
81
-
82
- Start a _transaction_ eg. an incoming web request or a background job.
83
-
84
- [source,ruby]
85
- ----
86
- # call with block
87
- ElasticAPM.start_transaction('Name')
88
- do_work # ...
89
- ElasticAPM.end_transaction('result')
90
- ----
91
-
92
- Arguments:
93
-
94
- * `name`: A name for your transaction. Transactions are grouped by name. **Required**.
95
- * `type`: A `type` for your transaction eg. `db.postgresql.sql`.
96
- * `context:`: An optional <<api-context,Context>> used to enrich the
97
- transaction with information about the current request.
98
- * `trace_context:`: An optional `TraceContext` object for Distributed Tracing.
99
-
100
- Returns the transaction.
101
-
102
- [float]
103
- [[api-agent-end_transaction]]
104
- ==== `ElasticAPM.end_transaction`
105
-
106
- Ends the currently running transaction.
107
-
108
- Arguments:
109
-
110
- * `result`: A `String` result of the transaction, eg. `'success'`.
111
-
112
- [float]
113
- [[api-agent-with_transaction]]
114
- ==== `ElasticAPM.with_transaction`
115
-
116
- Wrap a block in a Transaction, starting and ending around the block
117
-
118
- [source,ruby]
119
- ----
120
- ElasticAPM.with_transaction 'Do things' do |transaction|
121
- do_work # ...
122
-
123
- transaction.result = 'success'
124
- end
125
- ----
126
-
127
- Arguments:
128
-
129
- * `name`: A name for your transaction. Transactions are grouped by name. **Required**.
130
- * `type`: A `type` for your transaction eg. `db.postgresql.sql`.
131
- * `context:`: An optional <<api-context,Context>> used to enrich the
132
- transaction with information about the current request.
133
- * `trace_context:`: An optional `TraceContext` object for Distributed Tracing.
134
- * `&block`: A block to wrap. Optionally yields the transaction.
135
-
136
- Returns the return value of the given block.
137
-
138
- [float]
139
- [[api-agent-start_span]]
140
- ==== `ElasticAPM.start_span`
141
-
142
- Start a new span.
143
-
144
- [source,ruby]
145
- ----
146
- ElasticAPM.with_transaction 'Do things' do
147
- ElasticAPM.start_span 'Do one of the things'
148
- Database.query # ...
149
- ElasticAPM.end_span
150
- end
151
- ----
152
-
153
- Arguments:
154
-
155
- * `name`: A name for your span. **Required**.
156
- * `type`: The type of span eg. `db`.
157
- * `subtype`: The subtype of span eg. `postgresql`.
158
- * `action`: The action type of span eg. `connect` or `query`.
159
- * `context`: An instance of `Span::Context`.
160
- * `include_stacktrace`: Whether or not to collect a Stacktrace.
161
- * `trace_context:`: An optional `TraceContext` object for Distributed Tracing.
162
- * `parent:`: An optional parent transaction or span. Relevant when the span is created in another thread.
163
- * `sync:`: An boolean to indicate whether the span is created synchronously or not.
164
- * `&block`: An optional block to wrap with the span.
165
- The block is passed the span as an optional argument.
166
-
167
- Returns the created span.
168
-
169
- If you'd like to create an asynchronous span, you have to pass the parent `Span` or `Transaction` to the `start_span` method.
170
- You can also set the `sync` flag to `false`, if you'd like the span to be marked as asynchronous. This has no effect other than being queryable in Elasticsearch.
171
-
172
- [source,ruby]
173
- ----
174
- transaction = ElasticAPM.current_transaction # or start one with `.start_transaction`
175
- Thread.new do
176
- ElasticAPM.start_span(
177
- 'job 1',
178
- parent: transaction,
179
- sync: false
180
- ) { Worker.perform }
181
- ElasticAPM.end_span
182
- end
183
- ----
184
-
185
- [float]
186
- [[api-agent-end_span]]
187
- ==== `ElasticAPM.end_span`
188
-
189
- Ends the currently running span.
190
-
191
- [float]
192
- [[api-agent-with_span]]
193
- ==== `ElasticAPM.with_span`
194
-
195
- Wraps a block in a Span.
196
-
197
- Arguments:
198
-
199
- * `name`: A name for your span. **Required**.
200
- * `type`: The type of span eg. `db`.
201
- * `subtype`: The subtype of span eg. `postgresql`.
202
- * `action`: The action type of span eg. `connect` or `query`.
203
- * `context`: An instance of `Span::Context`.
204
- * `include_stacktrace`: Whether or not to collect a Stacktrace.
205
- * `trace_context:`: An optional `TraceContext` object for Distributed Tracing.
206
- * `parent:`: An optional parent transaction or span. Relevant when the span is created in another thread.
207
- * `sync:`: An boolean to indicate whether the span is created synchronously or not.
208
- * `&block`: An optional block to wrap with the span.
209
- The block is passed the span as an optional argument.
210
-
211
- Returns the return value of the given block.
212
-
213
- If you'd like to create an asynchronous span, you have to pass the parent `Span` or `Transaction` to the `with_span` method.
214
- You can also set the `sync` flag to `false`, if you'd like the span to be marked as asynchronous.
215
-
216
- [source,ruby]
217
- ----
218
- transaction = ElasticAPM.current_transaction # or start one with `.start_transaction`
219
- Thread.new do
220
- ElasticAPM.with_span(
221
- 'job 1',
222
- parent: transaction,
223
- sync: false
224
- ) { Worker.perform }
225
- end
226
- ----
227
-
228
- [float]
229
- [[api-agent-build-context]]
230
- ==== `ElasticAPM.build_context`
231
-
232
- Build a new _Context_ from a Rack `env`.
233
-
234
- A context provides information about the current request, response, user and more.
235
-
236
- Arguments:
237
-
238
- * `rack_env`: An instance of Rack::Env
239
- * `for_type`: Symbol representing type of event, eg. `:transaction` or `error`
240
-
241
- Returns the built context.
242
-
243
- [float]
244
- [[rails-start]]
245
- === Rails
246
-
247
- Start the agent and hook into Rails manually. This is useful if you skip requiring
248
- the gem and using the `Railtie`.
249
-
250
- [source,ruby]
251
- ----
252
- ElasticAPM::Rails.start(server_url: 'http://localhost:8200')
253
- ----
254
-
255
- [float]
256
- [[sinatra-start]]
257
- === Sinatra
258
-
259
- Start the agent and hook into Sinatra.
260
-
261
- [source,ruby]
262
- ----
263
- ElasticAPM::Sinatra.start(MySinatraApp, server_url: 'http://localhost:8200')
264
- ----
265
-
266
- [float]
267
- [[grape-start]]
268
- === Grape
269
-
270
- Start the agent and hook into Grape.
271
-
272
- [source,ruby]
273
- ----
274
- ElasticAPM::Grape.start(MyGrapeApp, server_url: 'http://localhost:8200')
275
- ----
276
-
277
- [float]
278
- === Errors
279
-
280
- [float]
281
- [[api-agent-report]]
282
- ==== `ElasticAPM.report`
283
-
284
- Send an `Exception` to Elastic APM.
285
-
286
- If reported inside a transaction, the context from that will be added.
287
-
288
- [source,ruby]
289
- ----
290
- begin
291
- do_a_thing_and_fail
292
- rescue Exception => e
293
- ElasticAPM.report(e)
294
- end
295
- ----
296
-
297
- Arguments:
298
-
299
- * `exception`: An instance of `Exception`. **Required**.
300
- * `handled`: Whether the error was _handled_ eg. wasn't rescued and was represented
301
- to the user. Default: `true`.
302
-
303
- Returns `[String]` ID of the generated `[ElasticAPM::Error]` object.
304
-
305
- [float]
306
- [[api-agent-report-message]]
307
- ==== `ElasticAPM.report_message`
308
-
309
- Send a custom message to Elastic APM.
310
-
311
- If reported inside a transaction, the context from that will be added.
312
-
313
- [source,ruby]
314
- ----
315
- ElasticAPM.report_message('This should probably never happen?!')
316
- ----
317
-
318
- Arguments:
319
-
320
- * `message`: A custom error string. **Required**.
321
-
322
- Returns `[String]` ID of the generated `[ElasticAPM::Error]` object.
323
-
324
- [float]
325
- [[api-context]]
326
- === Context
327
-
328
- [float]
329
- [[api-agent-set-label]]
330
- ==== `ElasticAPM.set_label`
331
-
332
- Add a label to the current transaction.
333
- Labels are basic key-value pairs that are indexed in your Elasticsearch database and therefore searchable.
334
- The value can be a string, nil, numeric or boolean.
335
-
336
- TIP: Before using custom labels, ensure you understand the different types of
337
- {apm-guide-ref}/data-model-metadata.html[metadata] that are available.
338
-
339
- [source,ruby]
340
- ----
341
- before_action do
342
- ElasticAPM.set_label(:company_id, current_user.company.id)
343
- end
344
- ----
345
-
346
- Arguments:
347
-
348
- * `key`: A string key. Note that `.`, `*` or `"` will be converted to `_`.
349
- * `value`: A value.
350
-
351
- Returns the set `value`.
352
-
353
- WARNING: Be aware that labels are indexed in Elasticsearch. Using too many unique keys will result in *https://www.elastic.co/blog/found-crash-elasticsearch#mapping-explosion[Mapping explosion]*.
354
-
355
- [float]
356
- [[api-agent-set-custom-context]]
357
- ==== `ElasticAPM.set_custom_context`
358
-
359
- Add custom context to the current transaction.
360
- Use this to further specify a context that will help you track or diagnose what's
361
- going on inside your app.
362
-
363
- TIP: Before using custom context, ensure you understand the different types of
364
- {apm-guide-ref}/data-model-metadata.html[metadata] that are available.
365
-
366
- If called several times during a transaction the custom context will be destructively
367
- merged with `merge!`.
368
-
369
- [source,ruby]
370
- ----
371
- before_action do
372
- ElasticAPM.set_custom_context(company: current_user.company.to_h)
373
- end
374
- ----
375
-
376
- Arguments:
377
-
378
- * `context`: A hash of JSON-compatible key-values. Can be nested.
379
-
380
- Returns current custom context.
381
-
382
- [float]
383
- [[api-agent-set-user]]
384
- ==== `ElasticAPM.set_user`
385
-
386
- Add the current user to the current transaction's context.
387
-
388
- Arguments:
389
-
390
- * `user`: An object representing the user
391
-
392
- Returns the given user
393
-
394
- [float]
395
- === Data
396
-
397
- [float]
398
- [[api-agent-add-filter]]
399
- ==== `ElasticAPM.add_filter`
400
-
401
- Provide a filter to transform payloads before sending.
402
-
403
- Arguments:
404
-
405
- * `key`: A unique key identifying the filter
406
- * `callable`: An object or proc (responds to `.call(payload)`)
407
-
408
- Return the altered payload.
409
-
410
- If `nil` is returned all subsequent filters will be skipped and the post request cancelled.
411
-
412
- Example:
413
-
414
- [source,ruby]
415
- ----
416
- ElasticAPM.add_filter(:filter_pings) do |payload|
417
- payload[:transactions]&.reject! do |t|
418
- t[:name] == 'PingsController#index'
419
- end
420
- payload
421
- end
422
- ----
423
-
424
- [float]
425
- [[api-transaction]]
426
- === Transaction
427
-
428
- `ElasticAPM.transaction` returns a `Transaction` (if the agent is running).
429
-
430
- [float]
431
- ==== Properties
432
-
433
- - `name`: String
434
- - `type`: String
435
- - `result`: String
436
- - `outcome`: String ('unknown', 'success', 'failure', nil)
437
- - `trace_id`: String (readonly)
438
-
439
- [float]
440
- [[api-transaction-sampled_]]
441
- ==== `#sampled?`
442
-
443
- Whether the transaction is _sampled_ eg. it includes stacktraces for its spans.
444
-
445
- [float]
446
- [[api-transaction-ensure_parent_id]]
447
- ==== `#ensure_parent_id`
448
-
449
- If the transaction does not have a parent-ID yet, calling this method generates
450
- a new ID, sets it as the parent-ID of this transaction, and returns it as a
451
- `String`.
452
-
453
- This enables the correlation of the spans the JavaScript Real User Monitoring
454
- (RUM) agent creates for the initial page load with the transaction of the
455
- backend service.
456
-
457
- If your service generates the HTML page dynamically, initializing the
458
- JavaScript RUM agent with the value of this method allows analyzing the time
459
- spent in the browser vs in the backend services.
460
-
461
- To enable the JavaScript RUM agent, initialize the RUM agent with the Ruby
462
- agent's current transaction:
463
-
464
- [source,html]
465
- ----
466
- <script src="elastic-apm-js-base/dist/bundles/elastic-apm-js-base.umd.min.js"></script>
467
- <script>
468
- var elasticApm = initApm({
469
- serviceName: '',
470
- serverUrl: 'http://localhost:8200',
471
- pageLoadTraceId: "<%= ElasticAPM.current_transaction&.trace_id %>",
472
- pageLoadSpanId: "<%= ElasticAPM.current_transaction&.ensure_parent_id %>",
473
- pageLoadSampled: <%= ElasticAPM.current_transaction&.sampled? %>
474
- })
475
- </script>
476
- ----
477
- See the {apm-rum-ref}[JavaScript RUM agent documentation] for more information.
478
-
479
- [float]
480
- [[api-span]]
481
- === Span
482
-
483
- [float]
484
- ==== Properties
485
-
486
- - `name`: String
487
- - `type`: String