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.
- checksums.yaml +4 -4
- data/.ci/.exclude.yml +21 -82
- data/.ci/.framework.yml +1 -4
- data/.ci/.ruby.yml +1 -1
- data/.ci/updatecli/values.d/apm-data-spec.yml +1 -0
- data/.ci/updatecli/values.d/apm-gherkin.yml +1 -0
- data/.ci/updatecli/values.d/apm-json-specs.yml +1 -0
- data/.ci/updatecli/values.d/scm.yml +10 -0
- data/.ci/updatecli/values.d/update-compose.yml +3 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +2 -2
- data/.github/dependabot.yml +24 -19
- data/.github/workflows/README.md +1 -2
- data/.github/workflows/addToProject.yml +16 -2
- data/.github/workflows/ci.yml +6 -6
- data/.github/workflows/docs-build.yml +19 -0
- data/.github/workflows/docs-cleanup.yml +14 -0
- data/.github/workflows/github-commands-comment.yml +38 -0
- data/.github/workflows/microbenchmark.yml +7 -24
- data/.github/workflows/release.yml +39 -24
- data/.github/workflows/run-matrix.yml +21 -12
- data/.github/workflows/test-reporter.yml +4 -3
- data/.github/workflows/updatecli.yml +45 -13
- data/Gemfile +13 -0
- data/bin/dev +2 -2
- data/docs/docset.yml +9 -0
- data/docs/reference/advanced-topics.md +12 -0
- data/docs/reference/api-reference.md +422 -0
- data/docs/reference/configuration.md +734 -0
- data/docs/{context.asciidoc → reference/context.md} +21 -21
- data/docs/reference/custom-instrumentation.md +72 -0
- data/docs/{getting-started-rack.asciidoc → reference/getting-started-rack.md} +20 -29
- data/docs/reference/getting-started-rails.md +27 -0
- data/docs/reference/graphql.md +21 -0
- data/docs/reference/index.md +24 -0
- data/docs/{logs.asciidoc → reference/logs.md} +38 -56
- data/docs/reference/metrics.md +199 -0
- data/docs/reference/opentracing-api.md +70 -0
- data/docs/reference/performance-tuning.md +71 -0
- data/docs/reference/set-up-apm-ruby-agent.md +16 -0
- data/docs/reference/supported-technologies.md +128 -0
- data/docs/reference/toc.yml +22 -0
- data/docs/reference/upgrading.md +19 -0
- data/docs/release-notes/index.md +166 -0
- data/docs/release-notes/known-issues.md +24 -0
- data/docs/release-notes/toc.yml +3 -0
- data/lib/elastic_apm/context_builder.rb +5 -2
- data/lib/elastic_apm/spies/sidekiq.rb +2 -1
- data/lib/elastic_apm/stacktrace_builder.rb +3 -3
- data/lib/elastic_apm/version.rb +1 -1
- data/updatecli-compose.yaml +23 -0
- metadata +37 -36
- data/.ci/snapshoty.yml +0 -33
- data/.ci/updatecli/updatecli.d/update-gherkin-specs.yml +0 -84
- data/.ci/updatecli/updatecli.d/update-json-specs.yml +0 -84
- data/.ci/updatecli/updatecli.d/update-specs.yml +0 -86
- data/.ci/updatecli/values.yml +0 -14
- data/.github/workflows/coverage-reporter.yml +0 -34
- data/.github/workflows/opentelemetry.yml +0 -22
- data/.github/workflows/snapshoty.yml +0 -35
- data/CHANGELOG.asciidoc +0 -990
- data/docs/advanced.asciidoc +0 -14
- data/docs/api.asciidoc +0 -487
- data/docs/configuration.asciidoc +0 -889
- data/docs/custom-instrumentation.asciidoc +0 -80
- data/docs/debugging.asciidoc +0 -44
- data/docs/getting-started-rails.asciidoc +0 -30
- data/docs/graphql.asciidoc +0 -23
- data/docs/index.asciidoc +0 -38
- data/docs/introduction.asciidoc +0 -36
- data/docs/metrics.asciidoc +0 -235
- data/docs/opentracing.asciidoc +0 -94
- data/docs/performance-tuning.asciidoc +0 -106
- data/docs/redirects.asciidoc +0 -9
- data/docs/release-notes.asciidoc +0 -15
- data/docs/set-up.asciidoc +0 -19
- data/docs/supported-technologies.asciidoc +0 -157
- data/docs/upgrading.asciidoc +0 -18
- /data/docs/{images → reference/images}/dynamic-config.svg +0 -0
@@ -1,14 +1,16 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
---
|
2
|
+
mapped_pages:
|
3
|
+
- https://www.elastic.co/guide/en/apm/agent/ruby/current/context.html
|
4
|
+
---
|
3
5
|
|
4
|
-
[
|
5
|
-
==== Adding custom context
|
6
|
+
# Adding additional context [context]
|
6
7
|
|
7
|
-
You can add your own custom, nested JSON-compatible data to the current
|
8
|
-
transaction using `ElasticAPM.set_custom_context(hash)` eg.:
|
9
8
|
|
10
|
-
[
|
11
|
-
|
9
|
+
## Adding custom context [_adding_custom_context]
|
10
|
+
|
11
|
+
You can add your own custom, nested JSON-compatible data to the current transaction using `ElasticAPM.set_custom_context(hash)` eg.:
|
12
|
+
|
13
|
+
```ruby
|
12
14
|
class ThingsController < ApplicationController
|
13
15
|
before_action do
|
14
16
|
ElasticAPM.set_custom_context(company: current_user.company)
|
@@ -16,31 +18,29 @@ class ThingsController < ApplicationController
|
|
16
18
|
|
17
19
|
# ...
|
18
20
|
end
|
19
|
-
|
21
|
+
```
|
22
|
+
|
20
23
|
|
21
|
-
[
|
22
|
-
==== Adding labels
|
24
|
+
## Adding labels [_adding_labels]
|
23
25
|
|
24
|
-
Labels are special in that they are indexed in your Elasticsearch database and
|
25
|
-
therefore queryable.
|
26
|
+
Labels are special in that they are indexed in your Elasticsearch database and therefore queryable.
|
26
27
|
|
27
|
-
|
28
|
-
----
|
28
|
+
```ruby
|
29
29
|
ElasticAPM.set_label(:company_name, 'Acme, Inc.')
|
30
|
-
|
30
|
+
```
|
31
31
|
|
32
32
|
Note that `.`, `*` and `"` in keys are converted to `_`.
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
|
35
|
+
## Providing info about the user [_providing_info_about_the_user]
|
36
36
|
|
37
37
|
You can provide ElasticAPM with info about the current user.
|
38
38
|
|
39
|
-
|
40
|
-
----
|
39
|
+
```ruby
|
41
40
|
class ApplicationController < ActionController::Base
|
42
41
|
before_action do
|
43
42
|
current_user && ElasticAPM.set_user(current_user)
|
44
43
|
end
|
45
44
|
end
|
46
|
-
|
45
|
+
```
|
46
|
+
|
@@ -0,0 +1,72 @@
|
|
1
|
+
---
|
2
|
+
mapped_pages:
|
3
|
+
- https://www.elastic.co/guide/en/apm/agent/ruby/current/custom-instrumentation.html
|
4
|
+
---
|
5
|
+
|
6
|
+
# Custom instrumentation [custom-instrumentation]
|
7
|
+
|
8
|
+
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.
|
9
|
+
|
10
|
+
But it is also possible to create your own transactions as well as provide spans for any automatic or custom transaction.
|
11
|
+
|
12
|
+
See [`ElasticAPM.start_transaction`](/reference/api-reference.md#api-agent-start_transaction) and [`ElasticAPM.start_span`](/reference/api-reference.md#api-agent-start_span).
|
13
|
+
|
14
|
+
|
15
|
+
## Helpers [_helpers]
|
16
|
+
|
17
|
+
ElasticAPM includes some nifty helpers if you just want to instrument a regular method.
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
class Thing
|
21
|
+
include ElasticAPM::SpanHelpers
|
22
|
+
|
23
|
+
def do_the_work
|
24
|
+
# ...
|
25
|
+
end
|
26
|
+
span_method :do_hard_work # takes optional `name` and `type`
|
27
|
+
|
28
|
+
def self.do_all_the_work
|
29
|
+
# ...
|
30
|
+
end
|
31
|
+
span_class_method :do_hard_work, 'Custom name', 'custom.work_thing'
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
|
36
|
+
## Custom span example [_custom_span_example]
|
37
|
+
|
38
|
+
If you are already inside a Transaction (most likely) and you want to instrument some work inside it, add a custom span:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
class ThingsController < ApplicationController
|
42
|
+
def index
|
43
|
+
@result_of_work = ElasticAPM.with_span "Heavy work" do
|
44
|
+
do_the_heavy_work
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
|
51
|
+
## Custom transaction example [_custom_transaction_example]
|
52
|
+
|
53
|
+
If you are **not** inside a Transaction already (eg. outside of your common web application) start and manage your own transactions like so:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
class Something
|
57
|
+
def do_work
|
58
|
+
transaction = ElasticAPM.start_transaction 'Something#do_work'
|
59
|
+
|
60
|
+
begin
|
61
|
+
Sequel[:users] # many third party libs will be automatically instrumented
|
62
|
+
rescue Exception => e
|
63
|
+
ElasticAPM.report(e)
|
64
|
+
raise
|
65
|
+
ensure
|
66
|
+
ElasticAPM.end_transaction('result')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
```
|
71
|
+
|
72
|
+
**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,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
endif::[]
|
1
|
+
---
|
2
|
+
mapped_pages:
|
3
|
+
- https://www.elastic.co/guide/en/apm/agent/ruby/current/getting-started-rack.html
|
4
|
+
---
|
6
5
|
|
7
|
-
[
|
8
|
-
=== Getting started with Rack
|
6
|
+
# Getting started with Rack [getting-started-rack]
|
9
7
|
|
10
8
|
Add the gem to your `Gemfile`:
|
11
9
|
|
12
|
-
|
13
|
-
----
|
10
|
+
```ruby
|
14
11
|
gem 'elastic-apm'
|
15
|
-
|
12
|
+
```
|
16
13
|
|
17
14
|
Create a file `config/elastic_apm.yml`:
|
18
15
|
|
19
|
-
|
20
|
-
----
|
16
|
+
```yaml
|
21
17
|
server_url: http://localhost:8200
|
22
18
|
secret_token: ''
|
23
|
-
|
19
|
+
```
|
24
20
|
|
25
21
|
Include the middleware, start (and stop) Elastic APM when booting your app:
|
26
22
|
|
27
|
-
|
28
|
-
----
|
23
|
+
```ruby
|
29
24
|
# config.ru
|
30
25
|
|
31
26
|
app = lambda do |env|
|
@@ -43,21 +38,19 @@ run app
|
|
43
38
|
# Gracefully stop the agent when process exits.
|
44
39
|
# Makes sure any pending transactions are sent.
|
45
40
|
at_exit { ElasticAPM.stop }
|
46
|
-
|
41
|
+
```
|
47
42
|
|
48
|
-
[float]
|
49
|
-
[[getting-started-sinatra]]
|
50
|
-
==== Sinatra example
|
51
43
|
|
52
|
-
[
|
53
|
-
|
44
|
+
## Sinatra example [getting-started-sinatra]
|
45
|
+
|
46
|
+
```ruby
|
54
47
|
# Example config.ru
|
55
48
|
|
56
49
|
require 'sinatra/base'
|
57
50
|
|
58
51
|
class MySinatraApp < Sinatra::Base
|
59
52
|
use ElasticAPM::Middleware
|
60
|
-
|
53
|
+
|
61
54
|
# ...
|
62
55
|
end
|
63
56
|
|
@@ -70,14 +63,12 @@ ElasticAPM.start(app: MySinatraApp, ...)
|
|
70
63
|
run MySinatraApp
|
71
64
|
|
72
65
|
at_exit { ElasticAPM.stop }
|
73
|
-
|
66
|
+
```
|
67
|
+
|
74
68
|
|
75
|
-
[
|
76
|
-
[[getting-started-grape]]
|
77
|
-
==== Grape example
|
69
|
+
## Grape example [getting-started-grape]
|
78
70
|
|
79
|
-
|
80
|
-
----
|
71
|
+
```ruby
|
81
72
|
# Example config.ru
|
82
73
|
|
83
74
|
require 'grape'
|
@@ -94,5 +85,5 @@ end
|
|
94
85
|
ElasticAPM::Grape.start(Twitter::API, config)
|
95
86
|
|
96
87
|
run Twitter::API
|
88
|
+
```
|
97
89
|
|
98
|
-
----
|
@@ -0,0 +1,27 @@
|
|
1
|
+
---
|
2
|
+
mapped_pages:
|
3
|
+
- https://www.elastic.co/guide/en/apm/agent/ruby/current/getting-started-rails.html
|
4
|
+
---
|
5
|
+
|
6
|
+
# Getting started with Rails [getting-started-rails]
|
7
|
+
|
8
|
+
|
9
|
+
## Setup [_setup]
|
10
|
+
|
11
|
+
Add the gem to your `Gemfile`:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'elastic-apm'
|
15
|
+
```
|
16
|
+
|
17
|
+
Create a file `config/elastic_apm.yml`:
|
18
|
+
|
19
|
+
```yaml
|
20
|
+
server_url: http://localhost:8200
|
21
|
+
secret_token: ''
|
22
|
+
```
|
23
|
+
|
24
|
+
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.
|
25
|
+
|
26
|
+
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).
|
27
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
mapped_pages:
|
3
|
+
- https://www.elastic.co/guide/en/apm/agent/ruby/current/graphql.html
|
4
|
+
---
|
5
|
+
|
6
|
+
# GraphQL [graphql]
|
7
|
+
|
8
|
+
The agent comes with support for GraphQL based APIs.
|
9
|
+
|
10
|
+
This slightly alters how transactions are named when they relate to GraphQL queries, so they are easier to tell apart and debug.
|
11
|
+
|
12
|
+
To enable GraphQL support, add the included Tracer to your schema:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
class MySchema < GraphQL::Schema
|
16
|
+
# ...
|
17
|
+
|
18
|
+
tracer ElasticAPM::GraphQL # <-- include this
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
@@ -0,0 +1,24 @@
|
|
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
|
+
---
|
6
|
+
|
7
|
+
# APM Ruby agent [introduction]
|
8
|
+
|
9
|
+
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.
|
10
|
+
|
11
|
+
|
12
|
+
## How does the Agent work? [how-it-works]
|
13
|
+
|
14
|
+
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.
|
15
|
+
|
16
|
+
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).
|
17
|
+
|
18
|
+
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.
|
19
|
+
|
20
|
+
|
21
|
+
## Additional Components [additional-components]
|
22
|
+
|
23
|
+
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).
|
24
|
+
|
@@ -1,40 +1,32 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
---
|
2
|
+
mapped_pages:
|
3
|
+
- https://www.elastic.co/guide/en/apm/agent/ruby/current/log-correlation.html
|
4
|
+
---
|
5
5
|
|
6
|
-
[
|
7
|
-
== Logs
|
6
|
+
# Logs [logs]
|
8
7
|
|
9
8
|
Elastic Ruby APM Agent provides the following log features:
|
10
9
|
|
11
|
-
|
12
|
-
|
10
|
+
* [Log correlation](#log-correlation-ids): Automatically inject correlation IDs that allow navigation between logs, traces and services.
|
11
|
+
* [Log reformatting (experimental)](#log-reformatting): Automatically reformat plaintext logs in [ECS logging](ecs-logging://reference/intro.md) format.
|
13
12
|
|
14
|
-
Those features are part of
|
13
|
+
Those features are part of [Application log ingestion strategies](docs-content://solutions/observability/logs/stream-application-logs.md).
|
15
14
|
|
16
|
-
The
|
17
|
-
When deployed with the Ruby APM agent, the agent will provide <<log-correlation-ids,log correlation>> IDs.
|
15
|
+
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
16
|
|
19
|
-
[float]
|
20
|
-
[[log-correlation-ids]]
|
21
|
-
=== Log correlation
|
22
17
|
|
23
|
-
|
24
|
-
and vice-versa: for a specific log, see in which context it has been logged and which parameters the user provided.
|
18
|
+
## Log correlation [log-correlation-ids]
|
25
19
|
|
20
|
+
[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
21
|
|
27
22
|
Trace/log correlation can be set up in three different ways.
|
28
23
|
|
29
|
-
[float]
|
30
|
-
[[rails-tagged-logging]]
|
31
|
-
==== Rails TaggedLogging
|
32
24
|
|
33
|
-
Rails
|
34
|
-
For example in your `config/environments/production.rb` file, add the following:
|
25
|
+
### Rails TaggedLogging [rails-tagged-logging]
|
35
26
|
|
36
|
-
|
37
|
-
|
27
|
+
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:
|
28
|
+
|
29
|
+
```ruby
|
38
30
|
config.log_tags = [ :request_id, proc { ElasticAPM.log_ids } ]
|
39
31
|
|
40
32
|
# Logs will then include the correlation IDs:
|
@@ -44,19 +36,16 @@ config.log_tags = [ :request_id, proc { ElasticAPM.log_ids } ]
|
|
44
36
|
# [transaction.id=c1ae84c8642891eb trace.id=b899fc7915e801b7558e336e4952bafe] Rendering text template
|
45
37
|
# [transaction.id=c1ae84c8642891eb trace.id=b899fc7915e801b7558e336e4952bafe] Rendered text template (Duration: 0.1ms | Allocations: 17)
|
46
38
|
# [transaction.id=c1ae84c8642891eb trace.id=b899fc7915e801b7558e336e4952bafe] Completed 200 OK in 1ms (Views: 0.4ms | Allocations: 171)
|
47
|
-
|
48
|
-
|
49
|
-
Consider using `Lograge` instead, as the timing of its hooks allow the span id to be captured in logs.
|
39
|
+
```
|
40
|
+
|
41
|
+
**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.
|
42
|
+
|
50
43
|
|
51
|
-
[
|
52
|
-
[[lograge]]
|
53
|
-
==== Lograge
|
44
|
+
### Lograge [lograge]
|
54
45
|
|
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.
|
46
|
+
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.
|
57
47
|
|
58
|
-
|
59
|
-
----
|
48
|
+
```ruby
|
60
49
|
config.lograge.custom_options = lambda do |event|
|
61
50
|
ElasticAPM.log_ids do |transaction_id, span_id, trace_id|
|
62
51
|
{ :'transaction.id' => transaction_id,
|
@@ -68,12 +57,11 @@ end
|
|
68
57
|
# Logs will then include the correlation IDs:
|
69
58
|
#
|
70
59
|
# 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
|
-
|
60
|
+
```
|
72
61
|
|
73
62
|
You can also nest the ids in a separate document as in the following example:
|
74
63
|
|
75
|
-
|
76
|
-
----
|
64
|
+
```ruby
|
77
65
|
config.lograge.custom_options = lambda do |event|
|
78
66
|
ElasticAPM.log_ids do |transaction_id, span_id, trace_id|
|
79
67
|
{ elastic_apm: { :'transaction.id' => transaction_id,
|
@@ -85,16 +73,14 @@ end
|
|
85
73
|
# Logs will then include the correlation IDs in a separate document:
|
86
74
|
#
|
87
75
|
# 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
|
-
|
76
|
+
```
|
89
77
|
|
90
|
-
|
91
|
-
[
|
92
|
-
==== Manually formatting logs
|
78
|
+
|
79
|
+
### Manually formatting logs [manually-formatting-logs]
|
93
80
|
|
94
81
|
You can access the correlation ids directly and add them through the log formatter.
|
95
82
|
|
96
|
-
|
97
|
-
----
|
83
|
+
```ruby
|
98
84
|
require 'elastic_apm'
|
99
85
|
require 'logger'
|
100
86
|
|
@@ -111,16 +97,14 @@ end
|
|
111
97
|
# [2019-09-16 11:54:59 +0200][RailsTestApp][INFO][transaction.id=3b92edcccc0a6d1e span.id=3bde4e9c85ab359c trace.id=1275686e35de91f776557637e799651e] Rendering text template
|
112
98
|
# [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
99
|
# [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
|
-
|
100
|
+
```
|
101
|
+
|
115
102
|
|
116
|
-
[
|
117
|
-
==== Extracting trace IDs from the logs
|
103
|
+
### Extracting trace IDs from the logs [_extracting_trace_ids_from_the_logs]
|
118
104
|
|
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:
|
105
|
+
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
106
|
|
122
|
-
|
123
|
-
----
|
107
|
+
```json
|
124
108
|
PUT _ingest/pipeline/extract_trace_id
|
125
109
|
{
|
126
110
|
"description": "Extract trace id from Lograge logs",
|
@@ -134,15 +118,13 @@ PUT _ingest/pipeline/extract_trace_id
|
|
134
118
|
}
|
135
119
|
]
|
136
120
|
}
|
137
|
-
|
121
|
+
```
|
138
122
|
|
139
|
-
Please see
|
123
|
+
Please see [Observability integrations](docs-content://solutions/observability/apps/logs.md) for more information.
|
140
124
|
|
141
|
-
[float]
|
142
|
-
[[log-reformatting]]
|
143
|
-
=== Log reformatting (experimental)
|
144
125
|
|
145
|
-
Log reformatting
|
126
|
+
## Log reformatting (experimental) [log-reformatting]
|
146
127
|
|
147
|
-
|
128
|
+
Log reformatting is controlled by the [`log_ecs_reformatting`](/reference/configuration.md#config-log-ecs-formatting) configuration option, and is disabled by default.
|
148
129
|
|
130
|
+
The reformatted logs will include both the [trace and service correlation](#log-correlation-ids) IDs.
|
@@ -0,0 +1,199 @@
|
|
1
|
+
---
|
2
|
+
mapped_pages:
|
3
|
+
- https://www.elastic.co/guide/en/apm/agent/ruby/current/metrics.html
|
4
|
+
---
|
5
|
+
|
6
|
+
# Metrics [metrics]
|
7
|
+
|
8
|
+
The Ruby agent tracks various system and application metrics. These metrics will be sent regularly to the APM Server and from there to Elasticsearch. You can adjust the interval by setting [`metrics_interval`](/reference/configuration.md#config-metrics-interval).
|
9
|
+
|
10
|
+
The metrics will be stored in the `apm-*` index and have the `processor.event` property set to `metric`.
|
11
|
+
|
12
|
+
|
13
|
+
## System metrics [metrics-system]
|
14
|
+
|
15
|
+
**Note:** Metrics from the Ruby agent are Linux only for now.
|
16
|
+
|
17
|
+
|
18
|
+
### `system.cpu.total.norm.pct` [metric-system.cpu.total.norm.pct]
|
19
|
+
|
20
|
+
* **Type:** Float
|
21
|
+
* **Format:** Percent
|
22
|
+
|
23
|
+
The percentage of CPU time in states other than Idle and IOWait, normalised by the number of cores.
|
24
|
+
|
25
|
+
|
26
|
+
### `system.memory.total` [metric-system.memory.total]
|
27
|
+
|
28
|
+
* **Type:** Long
|
29
|
+
* **Format:** Bytes
|
30
|
+
|
31
|
+
The total memory of the system in bytes.
|
32
|
+
|
33
|
+
|
34
|
+
### `system.memory.actual.free` [metric-system.memory.actual.free]
|
35
|
+
|
36
|
+
* **Type:** Long
|
37
|
+
* **Format:** Bytes
|
38
|
+
|
39
|
+
Free memory of the system in bytes.
|
40
|
+
|
41
|
+
|
42
|
+
### `system.process.cpu.total.norm.pct` [metric-system.process.cpu.total.norm.pct]
|
43
|
+
|
44
|
+
* **Type:** Float
|
45
|
+
* **Format:** Percent
|
46
|
+
|
47
|
+
The percentage of CPU time spent by the process since the last event. This value is normalized by the number of CPU cores and it ranges from 0 to 100%.
|
48
|
+
|
49
|
+
|
50
|
+
### `system.process.memory.size` [metric-system.process.memory.size]
|
51
|
+
|
52
|
+
* **Type:** Long
|
53
|
+
* **Format:** Bytes
|
54
|
+
|
55
|
+
The total virtual memory the process has.
|
56
|
+
|
57
|
+
|
58
|
+
### `system.process.memory.rss.bytes` [metric-system.process.memory.rss.bytes]
|
59
|
+
|
60
|
+
* **Type:** Long
|
61
|
+
* **Format:** Bytes
|
62
|
+
|
63
|
+
The Resident Set Size, the amount of memory the process occupies in main memory (RAM).
|
64
|
+
|
65
|
+
|
66
|
+
## Ruby Metrics [metrics-ruby]
|
67
|
+
|
68
|
+
|
69
|
+
### `ruby.gc.count` [metric-ruby.gc.counts]
|
70
|
+
|
71
|
+
* **Type:** Integer
|
72
|
+
* **Format:** Count
|
73
|
+
|
74
|
+
The number of Garbage Collection runs since the process started.
|
75
|
+
|
76
|
+
|
77
|
+
### `ruby.threads` [metric-ruby.threads]
|
78
|
+
|
79
|
+
* **Type:** Integer
|
80
|
+
* **Format:** Count
|
81
|
+
|
82
|
+
The number of threads belonging to the current process.
|
83
|
+
|
84
|
+
|
85
|
+
### `ruby.heap.slots.live` [metric-ruby.heap.slots.live]
|
86
|
+
|
87
|
+
* **Type:** Integer
|
88
|
+
* **Format:** Slots
|
89
|
+
|
90
|
+
Current amount of heap slots that are live.
|
91
|
+
|
92
|
+
**NB:** Not currently supported on JRuby.
|
93
|
+
|
94
|
+
|
95
|
+
### `ruby.heap.slots.free` [metric-ruby.heap.slots.free]
|
96
|
+
|
97
|
+
* **Type:** Integer
|
98
|
+
* **Format:** Slots
|
99
|
+
|
100
|
+
Current amount of heap slots that are free.
|
101
|
+
|
102
|
+
**NB:** Not currently supported on JRuby.
|
103
|
+
|
104
|
+
|
105
|
+
### `ruby.heap.allocations.total` [metrics-ruby.heap.allocations.total]
|
106
|
+
|
107
|
+
* **Type:** Integer
|
108
|
+
* **Format:** Objects
|
109
|
+
|
110
|
+
Current amount of allocated objects on the heap.
|
111
|
+
|
112
|
+
**NB:** Not currently supported on JRuby.
|
113
|
+
|
114
|
+
|
115
|
+
### `ruby.gc.time` [metrics-ruby.gc.time]
|
116
|
+
|
117
|
+
* **Type:** Float
|
118
|
+
* **Format:** Seconds
|
119
|
+
|
120
|
+
The total time spent in garbage collection.
|
121
|
+
|
122
|
+
**NB:** You need to enable Ruby’s GC Profiler for this to get reported. You can do this at any time when your application boots by calling `GC::Profiler.enable`.
|
123
|
+
|
124
|
+
|
125
|
+
## JVM Metrics [metrics-jvm-metrics]
|
126
|
+
|
127
|
+
The following metrics are available when using JRuby. They use the ruby java API to gather metrics via MXBean.
|
128
|
+
|
129
|
+
|
130
|
+
### `jvm.memory.heap.used` [metric-jvm.memory.heap.used]
|
131
|
+
|
132
|
+
* **Type:** Long
|
133
|
+
* **Format:** Bytes
|
134
|
+
|
135
|
+
The amount of used heap memory in bytes.
|
136
|
+
|
137
|
+
|
138
|
+
### `jvm.memory.heap.committed` [metric-jvm.memory.heap.committed]
|
139
|
+
|
140
|
+
* **Type:** Long
|
141
|
+
* **Format:** Bytes
|
142
|
+
|
143
|
+
The amount of heap memory in bytes that is committed for the Java virtual machine to use. This amount of memory is guaranteed for the Java virtual machine to use.
|
144
|
+
|
145
|
+
|
146
|
+
### `jvm.memory.heap.max` [metric-jvm.memory.heap.max]
|
147
|
+
|
148
|
+
* **Type:** Long
|
149
|
+
* **Format:** Bytes
|
150
|
+
|
151
|
+
The amount of heap memory in bytes that is committed for the Java virtual machine to use. This amount of memory is guaranteed for the Java virtual machine to use.
|
152
|
+
|
153
|
+
|
154
|
+
### `jvm.memory.non_heap.used` [metric-jvm.memory.non_heap.used]
|
155
|
+
|
156
|
+
* **Type:** Long
|
157
|
+
* **Format:** Bytes
|
158
|
+
|
159
|
+
The amount of used non-heap memory in bytes.
|
160
|
+
|
161
|
+
|
162
|
+
### `jvm.memory.non_heap.committed` [metric-jvm.memory.non_heap.committed]
|
163
|
+
|
164
|
+
* **Type:** Long
|
165
|
+
* **Format:** Bytes
|
166
|
+
|
167
|
+
The amount of non-heap memory in bytes that is committed for the Java virtual machine to use. This amount of memory is guaranteed for the Java virtual machine to use.
|
168
|
+
|
169
|
+
|
170
|
+
### `jvm.memory.non_heap.max` [metric-jvm.memory.non_heap.max]
|
171
|
+
|
172
|
+
* **Type:** Long
|
173
|
+
* **Format:** Bytes
|
174
|
+
|
175
|
+
The maximum amount of non-heap memory in bytes that can be used for memory management. If the maximum memory size is undefined, the value is -1.
|
176
|
+
|
177
|
+
|
178
|
+
### `jvm.memory.heap.pool.used` [metric-jvm.memory.heap.pool.used]
|
179
|
+
|
180
|
+
* **Type:** Long
|
181
|
+
* **Format:** Bytes
|
182
|
+
|
183
|
+
The amount of used memory in bytes of the memory pool.
|
184
|
+
|
185
|
+
|
186
|
+
### `jvm.memory.heap.pool.committed` [metric-jvm.memory.heap.pool.committed]
|
187
|
+
|
188
|
+
* **Type:** Long
|
189
|
+
* **Format:** Bytes
|
190
|
+
|
191
|
+
The amount of memory in bytes that is committed for the memory pool. This amount of memory is guaranteed for this specific pool.
|
192
|
+
|
193
|
+
|
194
|
+
### `jvm.memory.heap.pool.max` [metric-jvm.memory.heap.pool.max]
|
195
|
+
|
196
|
+
* **Type:** Long
|
197
|
+
* **Format:** Bytes
|
198
|
+
|
199
|
+
The maximum amount of memory in bytes that can be used for the memory pool.
|