elastic-apm 3.5.0 → 3.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ci/Jenkinsfile +286 -183
- data/.ci/docker/jruby/11-jdk/Dockerfile +40 -0
- data/.ci/docker/jruby/12-jdk/Dockerfile +40 -0
- data/.ci/docker/jruby/13-jdk/Dockerfile +40 -0
- data/.ci/docker/jruby/7-jdk/Dockerfile +40 -0
- data/.ci/docker/jruby/8-jdk/Dockerfile +40 -0
- data/.ci/docker/jruby/README.md +31 -0
- data/.ci/docker/jruby/run.sh +73 -0
- data/.ci/docker/jruby/test.sh +13 -0
- data/.ci/jobs/defaults.yml +1 -1
- data/.ci/packer_cache.sh +12 -10
- data/.gitignore +3 -1
- data/.rspec +0 -1
- data/.rubocop.yml +13 -1
- data/CHANGELOG.asciidoc +92 -0
- data/CONTRIBUTING.md +6 -4
- data/Gemfile +35 -9
- data/Rakefile +37 -5
- data/bin/run-tests +4 -1
- data/docker-compose.yml +7 -0
- data/docs/api.asciidoc +14 -2
- data/docs/configuration.asciidoc +122 -27
- data/docs/debugging.asciidoc +14 -0
- data/docs/getting-started-rails.asciidoc +2 -0
- data/docs/graphql.asciidoc +23 -0
- data/docs/images/dynamic-config.svg +1 -0
- data/docs/index.asciidoc +6 -1
- data/docs/introduction.asciidoc +2 -1
- data/docs/performance-tuning.asciidoc +106 -0
- data/docs/set-up.asciidoc +5 -2
- data/docs/supported-technologies.asciidoc +68 -1
- data/docs/upgrading.asciidoc +45 -0
- data/elastic-apm.gemspec +17 -0
- data/lib/elastic-apm.rb +17 -0
- data/lib/elastic_apm.rb +29 -0
- data/lib/elastic_apm/agent.rb +48 -2
- data/lib/elastic_apm/central_config.rb +27 -8
- data/lib/elastic_apm/central_config/cache_control.rb +17 -0
- data/lib/elastic_apm/child_durations.rb +17 -0
- data/lib/elastic_apm/config.rb +59 -3
- data/lib/elastic_apm/config/bytes.rb +17 -0
- data/lib/elastic_apm/config/duration.rb +17 -0
- data/lib/elastic_apm/config/options.rb +18 -1
- data/lib/elastic_apm/config/regexp_list.rb +17 -0
- data/lib/elastic_apm/config/wildcard_pattern_list.rb +28 -1
- data/lib/elastic_apm/context.rb +17 -0
- data/lib/elastic_apm/context/request.rb +17 -0
- data/lib/elastic_apm/context/request/socket.rb +17 -0
- data/lib/elastic_apm/context/request/url.rb +17 -0
- data/lib/elastic_apm/context/response.rb +17 -0
- data/lib/elastic_apm/context/user.rb +17 -0
- data/lib/elastic_apm/context_builder.rb +18 -1
- data/lib/elastic_apm/deprecations.rb +17 -0
- data/lib/elastic_apm/error.rb +17 -0
- data/lib/elastic_apm/error/exception.rb +17 -0
- data/lib/elastic_apm/error/log.rb +17 -0
- data/lib/elastic_apm/error_builder.rb +17 -0
- data/lib/elastic_apm/grape.rb +17 -0
- data/lib/elastic_apm/graphql.rb +91 -0
- data/lib/elastic_apm/grpc.rb +99 -0
- data/lib/elastic_apm/instrumenter.rb +29 -4
- data/lib/elastic_apm/internal_error.rb +17 -0
- data/lib/elastic_apm/logging.rb +17 -0
- data/lib/elastic_apm/metadata.rb +17 -0
- data/lib/elastic_apm/metadata/process_info.rb +17 -0
- data/lib/elastic_apm/metadata/service_info.rb +22 -2
- data/lib/elastic_apm/metadata/system_info.rb +22 -3
- data/lib/elastic_apm/metadata/system_info/container_info.rb +45 -4
- data/lib/elastic_apm/metrics.rb +33 -1
- data/lib/elastic_apm/metrics/breakdown_set.rb +17 -0
- data/lib/elastic_apm/metrics/cpu_mem_set.rb +17 -0
- data/lib/elastic_apm/metrics/metric.rb +17 -0
- data/lib/elastic_apm/metrics/set.rb +17 -0
- data/lib/elastic_apm/metrics/span_scoped_set.rb +17 -0
- data/lib/elastic_apm/metrics/transaction_set.rb +17 -0
- data/lib/elastic_apm/metrics/vm_set.rb +17 -0
- data/lib/elastic_apm/metricset.rb +17 -0
- data/lib/elastic_apm/middleware.rb +25 -2
- data/lib/elastic_apm/naively_hashable.rb +17 -0
- data/lib/elastic_apm/normalizers.rb +17 -0
- data/lib/elastic_apm/normalizers/grape.rb +17 -0
- data/lib/elastic_apm/normalizers/grape/endpoint_run.rb +18 -1
- data/lib/elastic_apm/normalizers/rails.rb +17 -0
- data/lib/elastic_apm/normalizers/rails/action_controller.rb +17 -0
- data/lib/elastic_apm/normalizers/rails/action_mailer.rb +17 -0
- data/lib/elastic_apm/normalizers/rails/action_view.rb +17 -0
- data/lib/elastic_apm/normalizers/rails/active_record.rb +17 -0
- data/lib/elastic_apm/opentracing.rb +64 -23
- data/lib/elastic_apm/rails.rb +17 -0
- data/lib/elastic_apm/railtie.rb +17 -0
- data/lib/elastic_apm/resque.rb +29 -0
- data/lib/elastic_apm/sinatra.rb +17 -0
- data/lib/elastic_apm/span.rb +20 -2
- data/lib/elastic_apm/span/context.rb +17 -0
- data/lib/elastic_apm/span/context/db.rb +17 -0
- data/lib/elastic_apm/span/context/destination.rb +37 -4
- data/lib/elastic_apm/span/context/http.rb +17 -0
- data/lib/elastic_apm/span_helpers.rb +17 -0
- data/lib/elastic_apm/spies.rb +33 -14
- data/lib/elastic_apm/spies/action_dispatch.rb +17 -0
- data/lib/elastic_apm/spies/delayed_job.rb +17 -0
- data/lib/elastic_apm/spies/dynamo_db.rb +58 -0
- data/lib/elastic_apm/spies/elasticsearch.rb +37 -2
- data/lib/elastic_apm/spies/faraday.rb +17 -0
- data/lib/elastic_apm/spies/http.rb +17 -0
- data/lib/elastic_apm/spies/json.rb +17 -0
- data/lib/elastic_apm/spies/mongo.rb +18 -1
- data/lib/elastic_apm/spies/net_http.rb +23 -2
- data/lib/elastic_apm/spies/rake.rb +17 -0
- data/lib/elastic_apm/spies/redis.rb +17 -0
- data/lib/elastic_apm/spies/resque.rb +53 -0
- data/lib/elastic_apm/spies/sequel.rb +18 -1
- data/lib/elastic_apm/spies/shoryuken.rb +17 -0
- data/lib/elastic_apm/spies/sidekiq.rb +17 -0
- data/lib/elastic_apm/spies/sinatra.rb +17 -0
- data/lib/elastic_apm/spies/sneakers.rb +17 -0
- data/lib/elastic_apm/spies/sucker_punch.rb +54 -0
- data/lib/elastic_apm/spies/tilt.rb +17 -0
- data/lib/elastic_apm/sql.rb +21 -4
- data/lib/elastic_apm/sql/signature.rb +17 -0
- data/lib/elastic_apm/sql/tokenizer.rb +17 -0
- data/lib/elastic_apm/sql/tokens.rb +17 -0
- data/lib/elastic_apm/sql_summarizer.rb +17 -0
- data/lib/elastic_apm/stacktrace.rb +17 -0
- data/lib/elastic_apm/stacktrace/frame.rb +17 -0
- data/lib/elastic_apm/stacktrace_builder.rb +23 -1
- data/lib/elastic_apm/subscriber.rb +17 -0
- data/lib/elastic_apm/trace_context.rb +51 -11
- data/lib/elastic_apm/trace_context/traceparent.rb +17 -0
- data/lib/elastic_apm/trace_context/tracestate.rb +17 -0
- data/lib/elastic_apm/transaction.rb +33 -5
- data/lib/elastic_apm/transport/base.rb +39 -23
- data/lib/elastic_apm/transport/connection.rb +17 -0
- data/lib/elastic_apm/transport/connection/http.rb +17 -0
- data/lib/elastic_apm/transport/connection/proxy_pipe.rb +22 -0
- data/lib/elastic_apm/transport/filters.rb +17 -0
- data/lib/elastic_apm/transport/filters/hash_sanitizer.rb +77 -0
- data/lib/elastic_apm/transport/filters/secrets_filter.rb +29 -56
- data/lib/elastic_apm/transport/headers.rb +17 -0
- data/lib/elastic_apm/transport/serializers.rb +17 -0
- data/lib/elastic_apm/transport/serializers/context_serializer.rb +17 -0
- data/lib/elastic_apm/transport/serializers/error_serializer.rb +17 -0
- data/lib/elastic_apm/transport/serializers/metadata_serializer.rb +44 -20
- data/lib/elastic_apm/transport/serializers/metricset_serializer.rb +17 -0
- data/lib/elastic_apm/transport/serializers/span_serializer.rb +20 -1
- data/lib/elastic_apm/transport/serializers/transaction_serializer.rb +17 -0
- data/lib/elastic_apm/transport/user_agent.rb +17 -0
- data/lib/elastic_apm/transport/worker.rb +21 -0
- data/lib/elastic_apm/util.rb +17 -0
- data/lib/elastic_apm/util/inflector.rb +17 -0
- data/lib/elastic_apm/util/lru_cache.rb +17 -0
- data/lib/elastic_apm/util/throttle.rb +17 -0
- data/lib/elastic_apm/version.rb +18 -1
- metadata +26 -12
- data/.ci/downstreamTests.groovy +0 -185
- data/.ci/prepare-git-context.sh +0 -27
- data/CHANGELOG.md +0 -1
- data/codecov.yml +0 -32
data/docs/debugging.asciidoc
CHANGED
@@ -28,3 +28,17 @@ Things to consider:
|
|
28
28
|
- Experiencing high load? The agent can spawn multiple instances of its Workers that pick off the queue by changing the option `pool_size` (default is `1`).
|
29
29
|
- If you have high load you may also consider setting `transaction_sample_rate` to something smaller than `1.0`. This determines whether to include _spans_ for every _transaction_. If you have enough traffic, skipping some (probably) identical spans won't have a noticeable effect on your data.
|
30
30
|
|
31
|
+
[float]
|
32
|
+
[[disable-agent]]
|
33
|
+
=== Disable the Agent
|
34
|
+
|
35
|
+
In the unlikely event the agent causes disruptions to a production application,
|
36
|
+
you can disable the agent while you troubleshoot.
|
37
|
+
|
38
|
+
If you have access to <<dynamic-configuration,dynamic configuration>>,
|
39
|
+
you can disable the recording of events by setting <<config-recording,`recording`>> to `false`.
|
40
|
+
When changed at runtime from a supported source, there's no need to restart your application.
|
41
|
+
|
42
|
+
If that doesn't work, or you don't have access to dynamic configuration, you can disable the agent by setting
|
43
|
+
<<config-enabled,`enabled`>> to `false`.
|
44
|
+
You'll need to restart your application for the changes to apply.
|
@@ -25,4 +25,6 @@ server_url: http://localhost:8200
|
|
25
25
|
secret_token: ''
|
26
26
|
----
|
27
27
|
|
28
|
+
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.
|
29
|
+
|
28
30
|
This automatically sets up error logging and performance tracking but of course there are knobs to turn if you'd like to. See <<configuration>>.
|
@@ -0,0 +1,23 @@
|
|
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
|
+
[[graphql]]
|
7
|
+
== GraphQL (experimental)
|
8
|
+
|
9
|
+
The agent comes with support for GraphQL based APIs.
|
10
|
+
|
11
|
+
This slightly alters how transactions are named when they relate to GraphQL
|
12
|
+
queries, so they are easier to tell apart and debug.
|
13
|
+
|
14
|
+
To enable GraphQL support, add the included Tracer to your schema:
|
15
|
+
|
16
|
+
[source,ruby]
|
17
|
+
----
|
18
|
+
class MySchema < GraphQL::Schema
|
19
|
+
# ...
|
20
|
+
|
21
|
+
tracer ElasticAPM::GraphQL # <-- include this
|
22
|
+
end
|
23
|
+
----
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="59" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="59" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#9f9f9f" d="M0 0h0v20H0z"/><path fill="#9f9f9f" d="M0 0h59v20H0z"/><path fill="url(#b)" d="M0 0h59v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"> <text x="295" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="490">Dynamic</text><text x="295" y="140" transform="scale(.1)" textLength="490">Dynamic</text></g> </svg>
|
data/docs/index.asciidoc
CHANGED
@@ -25,9 +25,14 @@ include::./metrics.asciidoc[]
|
|
25
25
|
|
26
26
|
include::./opentracing.asciidoc[]
|
27
27
|
|
28
|
+
include::./graphql.asciidoc[]
|
29
|
+
|
28
30
|
include::./log-correlation.asciidoc[]
|
29
31
|
|
32
|
+
include::./performance-tuning.asciidoc[]
|
33
|
+
|
30
34
|
include::./debugging.asciidoc[]
|
31
35
|
|
32
|
-
include::./
|
36
|
+
include::./upgrading.asciidoc[]
|
33
37
|
|
38
|
+
include::./release-notes.asciidoc[]
|
data/docs/introduction.asciidoc
CHANGED
@@ -32,4 +32,5 @@ You can then use the APM app in Kibana to gain insight into latency issues and e
|
|
32
32
|
=== Additional Components
|
33
33
|
|
34
34
|
APM Agents work in conjunction with the {apm-server-ref-v}/index.html[APM Server], {ref}/index.html[Elasticsearch], and {kibana-ref}/index.html[Kibana].
|
35
|
-
|
35
|
+
The {apm-overview-ref-v}/index.html[APM Overview] provides details on how these components work together,
|
36
|
+
and provides a matrix outlining {apm-overview-ref-v}/agent-server-compatibility.html[Agent and Server compatibility].
|
@@ -0,0 +1,106 @@
|
|
1
|
+
[[tuning-and-overhead]]
|
2
|
+
== Performance tuning
|
3
|
+
|
4
|
+
Using any APM solution comes with trade-offs, and the Elastic APM Ruby Agent is no different.
|
5
|
+
Instrumenting your code, using timers, recording context data, etc., uses resources—for example:
|
6
|
+
|
7
|
+
* CPU time
|
8
|
+
* Memory
|
9
|
+
* Bandwidth
|
10
|
+
* Elasticsearch storage
|
11
|
+
|
12
|
+
We invest a lot of effort to ensure that the Ruby Agent is suitable for production code
|
13
|
+
and that its overhead remains as low as possible.
|
14
|
+
However, because every application is different, there are some knobs you can turn and tweak to adapt the Agent to your specific needs.
|
15
|
+
|
16
|
+
[float]
|
17
|
+
[[tuning-sample-rate]]
|
18
|
+
=== Transaction sample rate
|
19
|
+
|
20
|
+
By default, the Agent samples every transaction.
|
21
|
+
The easiest way to reduce both the overhead of the agent and storage requirements,
|
22
|
+
is to tell it to do less, i.e., sample fewer transactions.
|
23
|
+
To do this, set the <<config-transaction-sample-rate,`transaction_sample_rate`>>
|
24
|
+
to a value between `0.0` and `1.0`—the percentage of transactions you'd like to randomly sample.
|
25
|
+
The Agent will still record the overall time and result of unsampled transactions,
|
26
|
+
but not context information, tags, or spans.
|
27
|
+
|
28
|
+
[float]
|
29
|
+
[[tuning-frame-context]]
|
30
|
+
=== Collecting frame context
|
31
|
+
|
32
|
+
The Agent automatically captures several lines of source code around each frame location in the stack trace.
|
33
|
+
This enables the APM app to provide greater insight into exactly where an error or span is occurring in your code.
|
34
|
+
This insight does come at a cost—in terms of performance, stack trace collection is the most expensive thing the Agent does.
|
35
|
+
|
36
|
+
There are settings you can modify to control this behavior:
|
37
|
+
|
38
|
+
1. Disable stack trace frame collection for short-duration spans by setting
|
39
|
+
<<config-span-frames-min-duration-ms,`span_frames_min_duration`>> to `0`.
|
40
|
+
|
41
|
+
2. Modify the number of source code lines collected.
|
42
|
+
These settings are divided between app frames, which represent your application code,
|
43
|
+
and library frames, which represent the code of your dependencies.
|
44
|
+
Each of these categories are further split into separate error and span settings.
|
45
|
+
+
|
46
|
+
* <<config-source-lines-error-app-frames, `source_lines_error_app_frames`>>
|
47
|
+
* <<config-source-lines-error-library-frames,`source_lines_error_library_frames`>>
|
48
|
+
* <<config-source-lines-span-app-frames,`source_lines_span_app_frames`>>
|
49
|
+
* <<config-source-lines-span-library-frames,`source_lines_span_library_frames`>>
|
50
|
+
|
51
|
+
3. If you're using the API to create a custom span, you can disable stack trace collection with the
|
52
|
+
<<api-agent-start_span,`include_stacktrace` argument>>.
|
53
|
+
|
54
|
+
Reading source files inside a running application can cause a lot of disk I/O,
|
55
|
+
and sending up source lines for each frame will have a network and storage cost that is quite high.
|
56
|
+
Turning these limits down will prevent storing excessive amounts of data in Elasticsearch.
|
57
|
+
|
58
|
+
[float]
|
59
|
+
[[tuning-queue]]
|
60
|
+
=== Transaction queue
|
61
|
+
|
62
|
+
The Agent does not send every transaction as it happens.
|
63
|
+
Instead, to reduce load on the APM Server, the Agent uses a queue.
|
64
|
+
The queue is flushed periodically, or when it reaches a maximum size.
|
65
|
+
|
66
|
+
While this reduces the load on the APM Server, holding on to transaction data in a queue uses memory.
|
67
|
+
If you notice a large increase in memory use, try adjusting these settings:
|
68
|
+
|
69
|
+
* <<config-api-request-time,`api_request_time`>> to reduce the duration of a single streaming request.
|
70
|
+
This setting is helpful if you have a sustained high number of transactions.
|
71
|
+
* <<config-api-request-size,`api_request_size`>> to reduce the maximum size of one request.
|
72
|
+
This setting can help if you experience transaction peaks (a large number in a short period of time).
|
73
|
+
|
74
|
+
Keep in mind that reducing the value of either setting will cause the agent to send more HTTP requests to the APM Server,
|
75
|
+
potentially causing a higher load.
|
76
|
+
|
77
|
+
[float]
|
78
|
+
[[tuning-max-spans]]
|
79
|
+
=== Spans per transaction
|
80
|
+
|
81
|
+
The number of spans per transaction will influence both how much time the agent spends in each transaction collecting contextual data,
|
82
|
+
and how much storage space is needed in Elasticsearch.
|
83
|
+
In our experience, most _usual_ transactions should have well below 100 spans.
|
84
|
+
In some cases, however, the number of spans can explode—for example:
|
85
|
+
|
86
|
+
* Long-running transactions
|
87
|
+
* Unoptimized code, e.g., doing hundreds of SQL queries in a loop
|
88
|
+
|
89
|
+
To avoid these edge cases which overload both the Agent and the APM Server,
|
90
|
+
the Agent will stop recording spans when a specified limit is reached.
|
91
|
+
This limit is configurable with <<config-transaction-max-spans,`transaction_max_spans`>>.
|
92
|
+
|
93
|
+
[float]
|
94
|
+
[[tuning-body-headers]]
|
95
|
+
=== Capturing headers and request body
|
96
|
+
|
97
|
+
You can configure the Agent to capture headers and request bodies with
|
98
|
+
<<config-capture-headers,`capture_headers`>> and <<config-capture-body,`capture_body`>>.
|
99
|
+
By default, headers are captured and request bodies are not.
|
100
|
+
|
101
|
+
Depending on the nature of your POST requests, capturing request bodies for transactions may introduce noticeable overhead,
|
102
|
+
as well as increased storage use.
|
103
|
+
In most scenarios, we advise against enabling request body capturing for transactions, and only enabling it if necessary for errors.
|
104
|
+
|
105
|
+
Capturing request/response headers has less overhead on the agent than capturing request bodies,
|
106
|
+
but can have an impact on storage use.
|
data/docs/set-up.asciidoc
CHANGED
@@ -9,8 +9,11 @@ endif::[]
|
|
9
9
|
|
10
10
|
To get you off the ground, we’ve prepared guides for setting up the Agent with different frameworks:
|
11
11
|
|
12
|
+
* <<getting-started-rails,Rails>>
|
13
|
+
* <<getting-started-rack,Rack>>
|
14
|
+
|
15
|
+
For custom instrumentation, see the <<api>>.
|
16
|
+
|
12
17
|
include::./getting-started-rails.asciidoc[]
|
13
18
|
|
14
19
|
include::./getting-started-rack.asciidoc[]
|
15
|
-
|
16
|
-
For custom instrumentation, see the <<api>>.
|
@@ -60,6 +60,7 @@ See <<getting-started-grape>>.
|
|
60
60
|
We automatically instrument database actions using:
|
61
61
|
|
62
62
|
- ActiveRecord (v4.2+)
|
63
|
+
- DynamoDB (v1.0+)
|
63
64
|
- Elasticsearch (v0.9+)
|
64
65
|
- Mongo (v2.1+)
|
65
66
|
- Redis (v3.1+)
|
@@ -85,4 +86,70 @@ We automatically instrument background processing using:
|
|
85
86
|
- DelayedJob
|
86
87
|
- Sidekiq
|
87
88
|
- Shoryuken
|
88
|
-
- Sneakers (v2.12.0+) (Experimental, see
|
89
|
+
- Sneakers (v2.12.0+) (Experimental, see https://github.com/elastic/apm-agent-ruby/pull/676[#676])
|
90
|
+
- Resque (v2.0.0+)
|
91
|
+
- SuckerPunch (v2.0.0+)
|
92
|
+
|
93
|
+
[float]
|
94
|
+
[[supported-technologies-resque]]
|
95
|
+
=== Resque
|
96
|
+
|
97
|
+
To make the agent work with Resque, you need to require `elastic_apm/resque` before you boot your Resque worker process.
|
98
|
+
|
99
|
+
For example in your `Rakefile`:
|
100
|
+
|
101
|
+
[source,ruby]
|
102
|
+
----
|
103
|
+
require 'resque'
|
104
|
+
require 'elastic_apm'
|
105
|
+
require 'elastic_apm/resque'
|
106
|
+
----
|
107
|
+
|
108
|
+
When you start Resque, you should see a series of messages like the following in the Resque logs:
|
109
|
+
|
110
|
+
[source,ruby]
|
111
|
+
----
|
112
|
+
I, [XXX #81227] INFO -- : Starting worker main
|
113
|
+
D, [XXX #81227] DEBUG -- : Registered signals
|
114
|
+
I, [XXX #81227] INFO -- : Running before_first_fork hooks
|
115
|
+
D, [XXX #81227] DEBUG -- : Starting ElasticAPM agent
|
116
|
+
----
|
117
|
+
|
118
|
+
Also be sure to set the Resque environment variable `RUN_AT_EXIT_HOOKS` to `true`. Otherwise, the fork may be
|
119
|
+
terminated before the agent has a chance to send all the fork's events to the APM server.
|
120
|
+
|
121
|
+
[float]
|
122
|
+
[[supported-technologies-sucker-punch]]
|
123
|
+
=== SuckerPunch
|
124
|
+
|
125
|
+
Asynchronously executed jobs in SuckerPunch are automatically instrumented.
|
126
|
+
|
127
|
+
Note that errors raised in the user-defined `JobClass#perform` method will be first handled by the SuckerPunch exception
|
128
|
+
handler before being handled by the agent. The handler is accessed/set via `SuckerPunch.exception_handler` in version
|
129
|
+
2.0. The agent transaction will be marked as successful unless you re-raise the error in the exception handler.
|
130
|
+
You can also explicitly report the error via <<api-agent-report,`ElasticAPM.report`>> in a custom SuckerPunch exception
|
131
|
+
handler.
|
132
|
+
|
133
|
+
[float]
|
134
|
+
[[supported-technologies-grpc]]
|
135
|
+
=== gRPC
|
136
|
+
|
137
|
+
We automatically instrument gRPC using the `grpc` gem. Note that this is experimental, as the `grpc` gem's
|
138
|
+
support for `Interceptors` is experimental as of version 1.27.0.
|
139
|
+
|
140
|
+
To instrument a client, add the `ElasticAPM::GRPC::ClientInterceptor` as an `interceptor` at Stub creation.
|
141
|
+
|
142
|
+
[source,ruby]
|
143
|
+
----
|
144
|
+
Helloworld::Greeter::Stub.new(
|
145
|
+
'localhost:50051',
|
146
|
+
interceptors: [ElasticAPM::GRPC::ClientInterceptor.new]
|
147
|
+
)
|
148
|
+
----
|
149
|
+
|
150
|
+
To instrument a server, add the `ElasticAPM::GRPC::ServerInterceptor`.
|
151
|
+
|
152
|
+
[source,ruby]
|
153
|
+
----
|
154
|
+
GRPC::RpcServer.new(interceptors: [ElasticAPM::GRPC::ServerInterceptor.new])
|
155
|
+
----
|
@@ -0,0 +1,45 @@
|
|
1
|
+
[[upgrading]]
|
2
|
+
== Upgrading
|
3
|
+
Upgrades between minor versions of the agent, like from 2.1 to 2.2 are always backwards compatible.
|
4
|
+
Upgrades that involve a major version bump often come with some backwards incompatible changes.
|
5
|
+
|
6
|
+
Before upgrading the agent, be sure to review the:
|
7
|
+
|
8
|
+
* <<release-notes,Agent release notes>>
|
9
|
+
* {apm-overview-ref-v}/agent-server-compatibility.html[Agent and Server compatibility chart]
|
10
|
+
|
11
|
+
[float]
|
12
|
+
[[end-of-life-dates]]
|
13
|
+
=== End of life dates
|
14
|
+
|
15
|
+
We love all our products, but sometimes we must say goodbye to a release so that we can continue moving
|
16
|
+
forward on future development and innovation.
|
17
|
+
Our https://www.elastic.co/support/eol[End of life policy] defines how long a given release is considered supported,
|
18
|
+
as well as how long a release is considered still in active development or maintenance.
|
19
|
+
The table below is a simplified description of this policy.
|
20
|
+
|
21
|
+
[options="header"]
|
22
|
+
|====
|
23
|
+
|Agent version |EOL Date |Maintained until
|
24
|
+
|3.5.x |2021-07-17 | 3.6
|
25
|
+
|3.4.x |2021-07-10 | 3.5
|
26
|
+
|3.3.x |2021-06-04 | 3.4
|
27
|
+
|3.2.x |2021-05-19 | 3.3
|
28
|
+
|3.1.x |2021-04-21 | 3.2
|
29
|
+
|3.0.x |2021-04-08 | 3.1
|
30
|
+
|2.12.x |2021-04-01 |4.0
|
31
|
+
|2.11.x |2021-03-23 |2.12
|
32
|
+
|2.10.x |2021-03-03 |2.11
|
33
|
+
|2.9.x |2020-12-25 |2.10
|
34
|
+
|2.8.x |2020-11-20 |2.9
|
35
|
+
|2.7.x |2020-11-07 |2.8
|
36
|
+
|2.6.x |2020-09-19 |2.7
|
37
|
+
|2.5.x |2020-09-01 |2.6
|
38
|
+
|2.4.x |2020-08-27 |2.5
|
39
|
+
|2.3.x |2020-07-29 |2.4
|
40
|
+
|2.2.x |2020-07-22 |2.3
|
41
|
+
|2.1.x |2020-06-04 |2.2
|
42
|
+
|2.0.x |2020-05-14 |2.1
|
43
|
+
|1.1.x |2020-03-07 |3.0
|
44
|
+
|1.0.x |2019-12-29 |1.1
|
45
|
+
|====
|
data/elastic-apm.gemspec
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
lib = File.expand_path('../lib', __FILE__)
|
2
19
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
20
|
require 'elastic_apm/version'
|
data/lib/elastic-apm.rb
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
# frozen_string_literal: true
|
2
19
|
|
3
20
|
# Make bundler auto-require work
|
data/lib/elastic_apm.rb
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
# frozen_string_literal: true
|
2
19
|
|
3
20
|
require 'erb'
|
@@ -22,10 +39,12 @@ require 'elastic_apm/instrumenter'
|
|
22
39
|
require 'elastic_apm/util'
|
23
40
|
|
24
41
|
require 'elastic_apm/middleware'
|
42
|
+
require 'elastic_apm/graphql'
|
25
43
|
|
26
44
|
require 'elastic_apm/rails' if defined?(::Rails::Railtie)
|
27
45
|
require 'elastic_apm/sinatra' if defined?(::Sinatra)
|
28
46
|
require 'elastic_apm/grape' if defined?(::Grape)
|
47
|
+
require 'elastic_apm/grpc' if defined?(::GRPC)
|
29
48
|
|
30
49
|
# ElasticAPM
|
31
50
|
module ElasticAPM
|
@@ -45,6 +64,16 @@ module ElasticAPM
|
|
45
64
|
Agent.stop
|
46
65
|
end
|
47
66
|
|
67
|
+
# Restarts the ElasticAPM Agent using the same config or a new
|
68
|
+
# one, if it is provided.
|
69
|
+
# Starts the agent if it is not running.
|
70
|
+
# Stops and starts the agent if it is running.
|
71
|
+
def restart(config = nil)
|
72
|
+
config ||= agent&.config
|
73
|
+
stop if running?
|
74
|
+
start(config)
|
75
|
+
end
|
76
|
+
|
48
77
|
# @return [Boolean] Whether there's an [Agent] running
|
49
78
|
def running?
|
50
79
|
Agent.running?
|
data/lib/elastic_apm/agent.rb
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
# frozen_string_literal: true
|
2
19
|
|
3
20
|
require 'elastic_apm/error'
|
@@ -34,9 +51,9 @@ module ElasticAPM
|
|
34
51
|
LOCK.synchronize do
|
35
52
|
return @instance if @instance
|
36
53
|
|
37
|
-
unless config.
|
54
|
+
unless config.enabled?
|
38
55
|
config.logger.debug format(
|
39
|
-
"%sAgent disabled with `
|
56
|
+
"%sAgent disabled with `enabled: false'",
|
40
57
|
Logging::PREFIX
|
41
58
|
)
|
42
59
|
return
|
@@ -72,6 +89,7 @@ module ElasticAPM
|
|
72
89
|
metrics: metrics,
|
73
90
|
stacktrace_builder: stacktrace_builder
|
74
91
|
) { |event| enqueue event }
|
92
|
+
@pid = Process.pid
|
75
93
|
end
|
76
94
|
|
77
95
|
attr_reader(
|
@@ -145,6 +163,9 @@ module ElasticAPM
|
|
145
163
|
context: nil,
|
146
164
|
trace_context: nil
|
147
165
|
)
|
166
|
+
return unless config.recording?
|
167
|
+
detect_forking!
|
168
|
+
|
148
169
|
instrumenter.start_transaction(
|
149
170
|
name,
|
150
171
|
type,
|
@@ -170,6 +191,12 @@ module ElasticAPM
|
|
170
191
|
parent: nil,
|
171
192
|
sync: nil
|
172
193
|
)
|
194
|
+
detect_forking!
|
195
|
+
|
196
|
+
# We don't check config.recording? because the span
|
197
|
+
# will not be created if there's no transaction.
|
198
|
+
# We want to use the recording value from the config
|
199
|
+
# that existed when start_transaction was called. ~estolfo
|
173
200
|
instrumenter.start_span(
|
174
201
|
name,
|
175
202
|
type,
|
@@ -207,6 +234,8 @@ module ElasticAPM
|
|
207
234
|
# errors
|
208
235
|
|
209
236
|
def report(exception, context: nil, handled: true)
|
237
|
+
return unless config.recording?
|
238
|
+
detect_forking!
|
210
239
|
return if config.filter_exception_types.include?(exception.class.to_s)
|
211
240
|
|
212
241
|
error = @error_builder.build_exception(
|
@@ -219,6 +248,9 @@ module ElasticAPM
|
|
219
248
|
end
|
220
249
|
|
221
250
|
def report_message(message, context: nil, backtrace: nil, **attrs)
|
251
|
+
return unless config.recording?
|
252
|
+
detect_forking!
|
253
|
+
|
222
254
|
error = @error_builder.build_log(
|
223
255
|
message,
|
224
256
|
context: context,
|
@@ -240,5 +272,19 @@ module ElasticAPM
|
|
240
272
|
def inspect
|
241
273
|
super.split.first + '>'
|
242
274
|
end
|
275
|
+
|
276
|
+
def detect_forking!
|
277
|
+
return if @pid == Process.pid
|
278
|
+
|
279
|
+
config.logger.debug "Detected forking,
|
280
|
+
restarting threads in process [PID:#{Process.pid}]"
|
281
|
+
|
282
|
+
central_config.handle_forking!
|
283
|
+
transport.handle_forking!
|
284
|
+
instrumenter.handle_forking!
|
285
|
+
metrics.handle_forking!
|
286
|
+
|
287
|
+
@pid = Process.pid
|
288
|
+
end
|
243
289
|
end
|
244
290
|
end
|