elastic-apm 4.7.3 → 4.9.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 (91) hide show
  1. checksums.yaml +4 -4
  2. data/.ci/.exclude.yml +27 -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/CODEOWNERS +1 -0
  11. data/.github/PULL_REQUEST_TEMPLATE.md +2 -2
  12. data/.github/dependabot.yml +22 -19
  13. data/.github/workflows/README.md +1 -2
  14. data/.github/workflows/addToProject.yml +43 -12
  15. data/.github/workflows/ci.yml +6 -6
  16. data/.github/workflows/docs-build.yml +16 -0
  17. data/.github/workflows/docs-deploy.yml +16 -0
  18. data/.github/workflows/docs-preview-cleanup.yml +12 -0
  19. data/.github/workflows/github-commands-comment.yml +18 -0
  20. data/.github/workflows/microbenchmark.yml +7 -24
  21. data/.github/workflows/release.yml +40 -24
  22. data/.github/workflows/run-matrix.yml +21 -12
  23. data/.github/workflows/test-reporter.yml +4 -3
  24. data/.github/workflows/updatecli.yml +45 -13
  25. data/Dockerfile +38 -12
  26. data/Gemfile +38 -3
  27. data/bin/dev +16 -4
  28. data/bin/run-bdd +2 -2
  29. data/docker-compose.yml +12 -5
  30. data/docs/docset.yml +11 -0
  31. data/docs/reference/advanced-topics.md +18 -0
  32. data/docs/reference/api-reference.md +428 -0
  33. data/docs/reference/configuration.md +751 -0
  34. data/docs/{context.asciidoc → reference/context.md} +27 -21
  35. data/docs/reference/custom-instrumentation.md +78 -0
  36. data/docs/{getting-started-rack.asciidoc → reference/getting-started-rack.md} +27 -30
  37. data/docs/reference/getting-started-rails.md +33 -0
  38. data/docs/reference/graphql.md +27 -0
  39. data/docs/reference/index.md +33 -0
  40. data/docs/{logs.asciidoc → reference/logs.md} +45 -57
  41. data/docs/reference/metrics.md +205 -0
  42. data/docs/reference/opentracing-api.md +76 -0
  43. data/docs/reference/performance-tuning.md +77 -0
  44. data/docs/reference/set-up-apm-ruby-agent.md +22 -0
  45. data/docs/reference/supported-technologies.md +134 -0
  46. data/docs/reference/toc.yml +24 -0
  47. data/docs/reference/upgrading.md +25 -0
  48. data/docs/release-notes/index.md +182 -0
  49. data/docs/release-notes/known-issues.md +29 -0
  50. data/docs/release-notes/toc.yml +3 -0
  51. data/elastic-apm.gemspec +2 -2
  52. data/lib/elastic_apm/central_config.rb +1 -1
  53. data/lib/elastic_apm/config/round_float_hash_value.rb +35 -0
  54. data/lib/elastic_apm/config.rb +2 -0
  55. data/lib/elastic_apm/context_builder.rb +5 -2
  56. data/lib/elastic_apm/instrumenter.rb +23 -3
  57. data/lib/elastic_apm/spies/http.rb +1 -1
  58. data/lib/elastic_apm/spies/sidekiq.rb +2 -1
  59. data/lib/elastic_apm/stacktrace_builder.rb +3 -3
  60. data/lib/elastic_apm/transaction.rb +11 -4
  61. data/lib/elastic_apm/version.rb +1 -1
  62. data/updatecli-compose.yaml +23 -0
  63. metadata +49 -37
  64. data/.ci/snapshoty.yml +0 -33
  65. data/.ci/updatecli/updatecli.d/update-gherkin-specs.yml +0 -84
  66. data/.ci/updatecli/updatecli.d/update-json-specs.yml +0 -84
  67. data/.ci/updatecli/updatecli.d/update-specs.yml +0 -86
  68. data/.ci/updatecli/values.yml +0 -14
  69. data/.github/workflows/coverage-reporter.yml +0 -34
  70. data/.github/workflows/opentelemetry.yml +0 -22
  71. data/.github/workflows/snapshoty.yml +0 -35
  72. data/CHANGELOG.asciidoc +0 -990
  73. data/SECURITY.md +0 -7
  74. data/docs/advanced.asciidoc +0 -14
  75. data/docs/api.asciidoc +0 -487
  76. data/docs/configuration.asciidoc +0 -889
  77. data/docs/custom-instrumentation.asciidoc +0 -80
  78. data/docs/debugging.asciidoc +0 -44
  79. data/docs/getting-started-rails.asciidoc +0 -30
  80. data/docs/graphql.asciidoc +0 -23
  81. data/docs/index.asciidoc +0 -38
  82. data/docs/introduction.asciidoc +0 -36
  83. data/docs/metrics.asciidoc +0 -235
  84. data/docs/opentracing.asciidoc +0 -94
  85. data/docs/performance-tuning.asciidoc +0 -106
  86. data/docs/redirects.asciidoc +0 -9
  87. data/docs/release-notes.asciidoc +0 -15
  88. data/docs/set-up.asciidoc +0 -19
  89. data/docs/supported-technologies.asciidoc +0 -157
  90. data/docs/upgrading.asciidoc +0 -18
  91. /data/docs/{images → reference/images}/dynamic-config.svg +0 -0
@@ -1,14 +1,22 @@
1
- [[context]]
2
- === Adding additional context
1
+ ---
2
+ mapped_pages:
3
+ - https://www.elastic.co/guide/en/apm/agent/ruby/current/context.html
4
+ applies_to:
5
+ stack:
6
+ serverless:
7
+ observability:
8
+ product:
9
+ apm_agent_ruby: ga
10
+ ---
3
11
 
4
- [float]
5
- ==== Adding custom context
12
+ # Adding additional context [context]
6
13
 
7
- You can add your own custom, nested JSON-compatible data to the current
8
- transaction using `ElasticAPM.set_custom_context(hash)` eg.:
9
14
 
10
- [source,ruby]
11
- ----
15
+ ## Adding custom context [_adding_custom_context]
16
+
17
+ You can add your own custom, nested JSON-compatible data to the current transaction using `ElasticAPM.set_custom_context(hash)` eg.:
18
+
19
+ ```ruby
12
20
  class ThingsController < ApplicationController
13
21
  before_action do
14
22
  ElasticAPM.set_custom_context(company: current_user.company)
@@ -16,31 +24,29 @@ class ThingsController < ApplicationController
16
24
 
17
25
  # ...
18
26
  end
19
- ----
27
+ ```
28
+
20
29
 
21
- [float]
22
- ==== Adding labels
30
+ ## Adding labels [_adding_labels]
23
31
 
24
- Labels are special in that they are indexed in your Elasticsearch database and
25
- therefore queryable.
32
+ Labels are special in that they are indexed in your Elasticsearch database and therefore queryable.
26
33
 
27
- [source,ruby]
28
- ----
34
+ ```ruby
29
35
  ElasticAPM.set_label(:company_name, 'Acme, Inc.')
30
- ----
36
+ ```
31
37
 
32
38
  Note that `.`, `*` and `"` in keys are converted to `_`.
33
39
 
34
- [float]
35
- ==== Providing info about the user
40
+
41
+ ## Providing info about the user [_providing_info_about_the_user]
36
42
 
37
43
  You can provide ElasticAPM with info about the current user.
38
44
 
39
- [source,ruby]
40
- ----
45
+ ```ruby
41
46
  class ApplicationController < ActionController::Base
42
47
  before_action do
43
48
  current_user && ElasticAPM.set_user(current_user)
44
49
  end
45
50
  end
46
- ----
51
+ ```
52
+
@@ -0,0 +1,78 @@
1
+ ---
2
+ mapped_pages:
3
+ - https://www.elastic.co/guide/en/apm/agent/ruby/current/custom-instrumentation.html
4
+ applies_to:
5
+ stack:
6
+ serverless:
7
+ observability:
8
+ product:
9
+ apm_agent_ruby: ga
10
+ ---
11
+
12
+ # Custom instrumentation [custom-instrumentation]
13
+
14
+ When installed and properly configured, ElasticAPM will automatically wrap your app’s request/responses in transactions and report its errors. It also wraps each background job if you use Sidekiq or DelayedJob.
15
+
16
+ But it is also possible to create your own transactions as well as provide spans for any automatic or custom transaction.
17
+
18
+ See [`ElasticAPM.start_transaction`](/reference/api-reference.md#api-agent-start_transaction) and [`ElasticAPM.start_span`](/reference/api-reference.md#api-agent-start_span).
19
+
20
+
21
+ ## Helpers [_helpers]
22
+
23
+ ElasticAPM includes some nifty helpers if you just want to instrument a regular method.
24
+
25
+ ```ruby
26
+ class Thing
27
+ include ElasticAPM::SpanHelpers
28
+
29
+ def do_the_work
30
+ # ...
31
+ end
32
+ span_method :do_hard_work # takes optional `name` and `type`
33
+
34
+ def self.do_all_the_work
35
+ # ...
36
+ end
37
+ span_class_method :do_hard_work, 'Custom name', 'custom.work_thing'
38
+ end
39
+ ```
40
+
41
+
42
+ ## Custom span example [_custom_span_example]
43
+
44
+ If you are already inside a Transaction (most likely) and you want to instrument some work inside it, add a custom span:
45
+
46
+ ```ruby
47
+ class ThingsController < ApplicationController
48
+ def index
49
+ @result_of_work = ElasticAPM.with_span "Heavy work" do
50
+ do_the_heavy_work
51
+ end
52
+ end
53
+ end
54
+ ```
55
+
56
+
57
+ ## Custom transaction example [_custom_transaction_example]
58
+
59
+ If you are **not** inside a Transaction already (eg. outside of your common web application) start and manage your own transactions like so:
60
+
61
+ ```ruby
62
+ class Something
63
+ def do_work
64
+ transaction = ElasticAPM.start_transaction 'Something#do_work'
65
+
66
+ begin
67
+ Sequel[:users] # many third party libs will be automatically instrumented
68
+ rescue Exception => e
69
+ ElasticAPM.report(e)
70
+ raise
71
+ ensure
72
+ ElasticAPM.end_transaction('result')
73
+ end
74
+ end
75
+ end
76
+ ```
77
+
78
+ **Note:** If the agent isn’t started beforehand this will do nothing. See [ElasticAPM.start](/reference/api-reference.md#api-agent-start).
@@ -1,31 +1,32 @@
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
- [[getting-started-rack]]
8
- === Getting started with Rack
1
+ ---
2
+ mapped_pages:
3
+ - https://www.elastic.co/guide/en/apm/agent/ruby/current/getting-started-rack.html
4
+ applies_to:
5
+ stack:
6
+ serverless:
7
+ observability:
8
+ product:
9
+ apm_agent_ruby: ga
10
+ ---
11
+
12
+ # Getting started with Rack [getting-started-rack]
9
13
 
10
14
  Add the gem to your `Gemfile`:
11
15
 
12
- [source,ruby]
13
- ----
16
+ ```ruby
14
17
  gem 'elastic-apm'
15
- ----
18
+ ```
16
19
 
17
20
  Create a file `config/elastic_apm.yml`:
18
21
 
19
- [source,yaml]
20
- ----
22
+ ```yaml
21
23
  server_url: http://localhost:8200
22
24
  secret_token: ''
23
- ----
25
+ ```
24
26
 
25
27
  Include the middleware, start (and stop) Elastic APM when booting your app:
26
28
 
27
- [source,ruby]
28
- ----
29
+ ```ruby
29
30
  # config.ru
30
31
 
31
32
  app = lambda do |env|
@@ -43,21 +44,19 @@ run app
43
44
  # Gracefully stop the agent when process exits.
44
45
  # Makes sure any pending transactions are sent.
45
46
  at_exit { ElasticAPM.stop }
46
- ----
47
+ ```
48
+
47
49
 
48
- [float]
49
- [[getting-started-sinatra]]
50
- ==== Sinatra example
50
+ ## Sinatra example [getting-started-sinatra]
51
51
 
52
- [source,ruby]
53
- ----
52
+ ```ruby
54
53
  # Example config.ru
55
54
 
56
55
  require 'sinatra/base'
57
56
 
58
57
  class MySinatraApp < Sinatra::Base
59
58
  use ElasticAPM::Middleware
60
-
59
+
61
60
  # ...
62
61
  end
63
62
 
@@ -70,14 +69,12 @@ ElasticAPM.start(app: MySinatraApp, ...)
70
69
  run MySinatraApp
71
70
 
72
71
  at_exit { ElasticAPM.stop }
73
- ----
72
+ ```
73
+
74
74
 
75
- [float]
76
- [[getting-started-grape]]
77
- ==== Grape example
75
+ ## Grape example [getting-started-grape]
78
76
 
79
- [source,ruby]
80
- ----
77
+ ```ruby
81
78
  # Example config.ru
82
79
 
83
80
  require 'grape'
@@ -94,5 +91,5 @@ end
94
91
  ElasticAPM::Grape.start(Twitter::API, config)
95
92
 
96
93
  run Twitter::API
94
+ ```
97
95
 
98
- ----
@@ -0,0 +1,33 @@
1
+ ---
2
+ mapped_pages:
3
+ - https://www.elastic.co/guide/en/apm/agent/ruby/current/getting-started-rails.html
4
+ applies_to:
5
+ stack:
6
+ serverless:
7
+ observability:
8
+ product:
9
+ apm_agent_ruby: ga
10
+ ---
11
+
12
+ # Getting started with Rails [getting-started-rails]
13
+
14
+
15
+ ## Setup [_setup]
16
+
17
+ Add the gem to your `Gemfile`:
18
+
19
+ ```ruby
20
+ gem 'elastic-apm'
21
+ ```
22
+
23
+ Create a file `config/elastic_apm.yml`:
24
+
25
+ ```yaml
26
+ server_url: http://localhost:8200
27
+ secret_token: ''
28
+ ```
29
+
30
+ Or if you prefer environment variables, skip the file and set `ELASTIC_APM_SERVER_URL` and `ELASTIC_APM_SECRET_TOKEN` in your local or server environment.
31
+
32
+ This automatically sets up error logging and performance tracking but of course there are knobs to turn if you’d like to. See [*Configuration*](/reference/configuration.md).
33
+
@@ -0,0 +1,27 @@
1
+ ---
2
+ mapped_pages:
3
+ - https://www.elastic.co/guide/en/apm/agent/ruby/current/graphql.html
4
+ applies_to:
5
+ stack:
6
+ serverless:
7
+ observability:
8
+ product:
9
+ apm_agent_ruby: ga
10
+ ---
11
+
12
+ # GraphQL [graphql]
13
+
14
+ The agent comes with support for GraphQL based APIs.
15
+
16
+ This slightly alters how transactions are named when they relate to GraphQL queries, so they are easier to tell apart and debug.
17
+
18
+ To enable GraphQL support, add the included Tracer to your schema:
19
+
20
+ ```ruby
21
+ class MySchema < GraphQL::Schema
22
+ # ...
23
+
24
+ tracer ElasticAPM::GraphQL # <-- include this
25
+ end
26
+ ```
27
+
@@ -0,0 +1,33 @@
1
+ ---
2
+ mapped_pages:
3
+ - https://www.elastic.co/guide/en/apm/agent/ruby/current/introduction.html
4
+ - https://www.elastic.co/guide/en/apm/agent/ruby/current/index.html
5
+ applies_to:
6
+ stack:
7
+ serverless:
8
+ observability:
9
+ product:
10
+ apm_agent_ruby: ga
11
+ ---
12
+
13
+ # APM Ruby agent [introduction]
14
+
15
+ The Elastic APM Ruby Agent sends performance metrics and error logs to the APM Server. It has built-in support for [Ruby on Rails](/reference/getting-started-rails.md) and other [Rack-compatible](/reference/getting-started-rack.md) applications. It also offers an API which allows you to instrument any application.
16
+
17
+
18
+ ## How does the Agent work? [how-it-works]
19
+
20
+ The agent auto-instruments [supported technologies](/reference/supported-technologies.md) and records interesting events, like HTTP requests and database queries. To do this, it uses relevant public APIs when they are provided by the libraries. Otherwise, it carefully wraps the necessary internal methods. This means that for the supported technologies, there are no code changes required.
21
+
22
+ The Agent automatically keeps track of queries to your data stores to measure their duration and metadata (like the DB statement), as well as HTTP related information (like the URL, parameters, and headers).
23
+
24
+ These events, called Transactions and Spans, are sent to the APM Server. The APM Server converts them to a format suitable for Elasticsearch, and sends them to an Elasticsearch cluster. You can then use the APM app in Kibana to gain insight into latency issues and error culprits within your application.
25
+
26
+
27
+ ## Additional Components [additional-components]
28
+
29
+ APM Agents work in conjunction with the [APM Server](docs-content://solutions/observability/apps/application-performance-monitoring-apm.md), [Elasticsearch](docs-content://get-started/index.md), and [Kibana](docs-content://get-started/the-stack.md). The [APM Guide](docs-content://solutions/observability/apps/application-performance-monitoring-apm.md) provides details on how these components work together, and provides a matrix outlining [Agent and Server compatibility](docs-content://solutions/observability/apps/apm-agent-compatibility.md).
30
+
31
+ ## Troubleshooting
32
+
33
+ If you're experiencing issues with the APM Ruby agent, refer to [Troubleshoot APM Ruby Agent](docs-content://troubleshoot/observability/apm-agent-ruby/apm-ruby-agent.md).
@@ -1,40 +1,38 @@
1
- ifdef::env-github[]
2
- NOTE: For the best reading experience,
3
- please view this documentation at https://www.elastic.co/guide/en/apm/agent/ruby[elastic.co]
4
- endif::[]
5
-
6
- [[logs]]
7
- == Logs
1
+ ---
2
+ mapped_pages:
3
+ - https://www.elastic.co/guide/en/apm/agent/ruby/current/log-correlation.html
4
+ applies_to:
5
+ stack:
6
+ serverless:
7
+ observability:
8
+ product:
9
+ apm_agent_ruby: ga
10
+ ---
11
+
12
+ # Logs [logs]
8
13
 
9
14
  Elastic Ruby APM Agent provides the following log features:
10
15
 
11
- - <<log-correlation-ids>>: Automatically inject correlation IDs that allow navigation between logs, traces and services.
12
- - <<log-reformatting>>: Automatically reformat plaintext logs in {ecs-logging-ref}/intro.html[ECS logging] format.
16
+ * [Log correlation](#log-correlation-ids): Automatically inject correlation IDs that allow navigation between logs, traces and services.
17
+ * [Log reformatting (experimental)](#log-reformatting): Automatically reformat plaintext logs in [ECS logging](ecs-logging://reference/intro.md) format.
13
18
 
14
- Those features are part of {observability-guide}/application-logs.html[Application log ingestion strategies].
19
+ Those features are part of [Application log ingestion strategies](docs-content://solutions/observability/logs/stream-application-logs.md).
15
20
 
16
- The {ecs-logging-ruby-ref}/intro.html[`ecs-logging-ruby`] library can also be used to format logs in the {ecs-logging-ref}/intro.html[ECS logging] format without an APM agent.
17
- When deployed with the Ruby APM agent, the agent will provide <<log-correlation-ids,log correlation>> IDs.
21
+ The [`ecs-logging-ruby`](ecs-logging-ruby://reference/index.md) library can also be used to format logs in the [ECS logging](ecs-logging://reference/intro.md) format without an APM agent. When deployed with the Ruby APM agent, the agent will provide [log correlation](#log-correlation-ids) IDs.
18
22
 
19
- [float]
20
- [[log-correlation-ids]]
21
- === Log correlation
22
23
 
23
- {apm-guide-ref}/log-correlation.html[Log correlation] allows you to navigate to all logs belonging to a particular trace
24
- and vice-versa: for a specific log, see in which context it has been logged and which parameters the user provided.
24
+ ## Log correlation [log-correlation-ids]
25
25
 
26
+ [Log correlation](docs-content://solutions/observability/apps/logs.md) allows you to navigate to all logs belonging to a particular trace and vice-versa: for a specific log, see in which context it has been logged and which parameters the user provided.
26
27
 
27
28
  Trace/log correlation can be set up in three different ways.
28
29
 
29
- [float]
30
- [[rails-tagged-logging]]
31
- ==== Rails TaggedLogging
32
30
 
33
- Rails applications configured with an `ActiveSupport::TaggedLogging` logger can append the correlation IDs to log output.
34
- For example in your `config/environments/production.rb` file, add the following:
31
+ ### Rails TaggedLogging [rails-tagged-logging]
32
+
33
+ Rails applications configured with an `ActiveSupport::TaggedLogging` logger can append the correlation IDs to log output. For example in your `config/environments/production.rb` file, add the following:
35
34
 
36
- [source,ruby]
37
- ----
35
+ ```ruby
38
36
  config.log_tags = [ :request_id, proc { ElasticAPM.log_ids } ]
39
37
 
40
38
  # Logs will then include the correlation IDs:
@@ -44,19 +42,16 @@ config.log_tags = [ :request_id, proc { ElasticAPM.log_ids } ]
44
42
  # [transaction.id=c1ae84c8642891eb trace.id=b899fc7915e801b7558e336e4952bafe] Rendering text template
45
43
  # [transaction.id=c1ae84c8642891eb trace.id=b899fc7915e801b7558e336e4952bafe] Rendered text template (Duration: 0.1ms | Allocations: 17)
46
44
  # [transaction.id=c1ae84c8642891eb trace.id=b899fc7915e801b7558e336e4952bafe] Completed 200 OK in 1ms (Views: 0.4ms | Allocations: 171)
47
- ----
48
- **Note:** Because of the order in which Rails computes the tags for logs and executes the request, the span id might not be included.
49
- Consider using `Lograge` instead, as the timing of its hooks allow the span id to be captured in logs.
45
+ ```
46
+
47
+ **Note:** Because of the order in which Rails computes the tags for logs and executes the request, the span id might not be included. Consider using `Lograge` instead, as the timing of its hooks allow the span id to be captured in logs.
50
48
 
51
- [float]
52
- [[lograge]]
53
- ==== Lograge
54
49
 
55
- With `lograge` enabled and set up in your Rails application, modify the `custom_options` block in the Rails environment
56
- configuration file. The returned `Hash` will be included in the structured Lograge logs.
50
+ ### Lograge [lograge]
57
51
 
58
- [source,ruby]
59
- ----
52
+ With `lograge` enabled and set up in your Rails application, modify the `custom_options` block in the Rails environment configuration file. The returned `Hash` will be included in the structured Lograge logs.
53
+
54
+ ```ruby
60
55
  config.lograge.custom_options = lambda do |event|
61
56
  ElasticAPM.log_ids do |transaction_id, span_id, trace_id|
62
57
  { :'transaction.id' => transaction_id,
@@ -68,12 +63,11 @@ end
68
63
  # Logs will then include the correlation IDs:
69
64
  #
70
65
  # I, [2019-09-16T11:59:05.439602 #8674] INFO -- : method=GET path=/ format=html controller=ApplicationController action=index status=200 duration=0.36 view=0.20 transaction.id=56a9186a9257aa08 span.id=8e84a786ab0abbb2 trace.id=1bbab8ac4c7c9584f53eb882ff0dfdd8
71
- ----
66
+ ```
72
67
 
73
68
  You can also nest the ids in a separate document as in the following example:
74
69
 
75
- [source,ruby]
76
- ----
70
+ ```ruby
77
71
  config.lograge.custom_options = lambda do |event|
78
72
  ElasticAPM.log_ids do |transaction_id, span_id, trace_id|
79
73
  { elastic_apm: { :'transaction.id' => transaction_id,
@@ -85,16 +79,14 @@ end
85
79
  # Logs will then include the correlation IDs in a separate document:
86
80
  #
87
81
  # I, [2019-09-16T13:39:35.962603 #9327] INFO -- : method=GET path=/ format=html controller=ApplicationController action=index status=200 duration=0.37 view=0.20 elastic_apm={:transaction_id=>"2fb84f5d0c48a296", :span_id=>"2e5c5a7c85f83be7", :trace_id=>"43e1941c4a6fff343a4e018ff7b92000"}
88
- ----
82
+ ```
83
+
89
84
 
90
- [float]
91
- [[manually-formatting-logs]]
92
- ==== Manually formatting logs
85
+ ### Manually formatting logs [manually-formatting-logs]
93
86
 
94
87
  You can access the correlation ids directly and add them through the log formatter.
95
88
 
96
- [source,ruby]
97
- ----
89
+ ```ruby
98
90
  require 'elastic_apm'
99
91
  require 'logger'
100
92
 
@@ -111,16 +103,14 @@ end
111
103
  # [2019-09-16 11:54:59 +0200][RailsTestApp][INFO][transaction.id=3b92edcccc0a6d1e span.id=3bde4e9c85ab359c trace.id=1275686e35de91f776557637e799651e] Rendering text template
112
104
  # [2019-09-16 11:54:59 +0200][RailsTestApp][INFO][transaction.id=3b92edcccc0a6d1e span.id=f3d7e32f176d4c93 trace.id=1275686e35de91f776557637e799651e] Rendered text template (Duration: 0.1ms | Allocations: 17)
113
105
  # [2019-09-16 11:54:59 +0200][RailsTestApp][INFO][transaction.id=3b92edcccc0a6d1e span.id=3bde4e9c85ab359c trace.id=1275686e35de91f776557637e799651e] Completed 200 OK in 1ms (Views: 0.3ms | Allocations: 187)
114
- ----
106
+ ```
107
+
115
108
 
116
- [float]
117
- ==== Extracting trace IDs from the logs
109
+ ### Extracting trace IDs from the logs [_extracting_trace_ids_from_the_logs]
118
110
 
119
- For log correlation to work, the trace IDs must be extracted from the log message and stored in separate fields in the Elasticsearch document. There are many ways to achieve this, for example by using ingest node and defining a pipeline with a grok processor.
120
- You can extract the trace id from the Lograge output generated above like this:
111
+ For log correlation to work, the trace IDs must be extracted from the log message and stored in separate fields in the Elasticsearch document. There are many ways to achieve this, for example by using ingest node and defining a pipeline with a grok processor. You can extract the trace id from the Lograge output generated above like this:
121
112
 
122
- [source,json]
123
- ----
113
+ ```json
124
114
  PUT _ingest/pipeline/extract_trace_id
125
115
  {
126
116
  "description": "Extract trace id from Lograge logs",
@@ -134,15 +124,13 @@ PUT _ingest/pipeline/extract_trace_id
134
124
  }
135
125
  ]
136
126
  }
137
- ----
127
+ ```
138
128
 
139
- Please see {apm-guide-ref}/log-correlation.html[Observability integrations] for more information.
129
+ Please see [Observability integrations](docs-content://solutions/observability/apps/logs.md) for more information.
140
130
 
141
- [float]
142
- [[log-reformatting]]
143
- === Log reformatting (experimental)
144
131
 
145
- Log reformatting is controlled by the <<config-log-ecs-formatting, `log_ecs_reformatting`>> configuration option, and is disabled by default.
132
+ ## Log reformatting (experimental) [log-reformatting]
146
133
 
147
- The reformatted logs will include both the <<log-correlation-ids, trace and service correlation>> IDs.
134
+ Log reformatting is controlled by the [`log_ecs_reformatting`](/reference/configuration.md#config-log-ecs-formatting) configuration option, and is disabled by default.
148
135
 
136
+ The reformatted logs will include both the [trace and service correlation](#log-correlation-ids) IDs.