elastic-apm 3.3.0 → 3.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/.ci/.jenkins_exclude.yml +43 -24
  3. data/.ci/.jenkins_framework.yml +2 -2
  4. data/.ci/.jenkins_ruby.yml +1 -1
  5. data/.ci/Jenkinsfile +288 -170
  6. data/.ci/docker/jruby/11-jdk/Dockerfile +40 -0
  7. data/.ci/docker/jruby/12-jdk/Dockerfile +40 -0
  8. data/.ci/docker/jruby/13-jdk/Dockerfile +40 -0
  9. data/.ci/docker/jruby/7-jdk/Dockerfile +40 -0
  10. data/.ci/docker/jruby/8-jdk/Dockerfile +40 -0
  11. data/.ci/docker/jruby/README.md +31 -0
  12. data/.ci/docker/jruby/run.sh +73 -0
  13. data/.ci/docker/jruby/test.sh +13 -0
  14. data/.ci/jobs/apm-agent-ruby-downstream.yml +1 -0
  15. data/.ci/jobs/apm-agent-ruby-linting-mbp.yml +1 -0
  16. data/.ci/jobs/apm-agent-ruby-mbp.yml +1 -0
  17. data/.ci/jobs/defaults.yml +1 -1
  18. data/.ci/packer_cache.sh +16 -0
  19. data/.github/ISSUE_TEMPLATE/Bug_report.md +40 -0
  20. data/.github/ISSUE_TEMPLATE/Feature_request.md +17 -0
  21. data/.github/PULL_REQUEST_TEMPLATE.md +60 -0
  22. data/.gitignore +8 -0
  23. data/.rspec +0 -1
  24. data/.rubocop.yml +18 -0
  25. data/CHANGELOG.asciidoc +104 -1
  26. data/CONTRIBUTING.md +6 -48
  27. data/Gemfile +38 -10
  28. data/README.md +62 -13
  29. data/Rakefile +37 -5
  30. data/bench/sql.rb +49 -0
  31. data/bin/build_docs +1 -1
  32. data/bin/run-tests +4 -1
  33. data/docker-compose.yml +7 -0
  34. data/docs/api.asciidoc +52 -3
  35. data/docs/configuration.asciidoc +171 -22
  36. data/docs/getting-started-rails.asciidoc +2 -0
  37. data/docs/graphql.asciidoc +23 -0
  38. data/docs/images/dynamic-config.svg +1 -0
  39. data/docs/index.asciidoc +6 -1
  40. data/docs/introduction.asciidoc +2 -1
  41. data/docs/performance-tuning.asciidoc +106 -0
  42. data/docs/set-up.asciidoc +5 -2
  43. data/docs/supported-technologies.asciidoc +86 -1
  44. data/docs/upgrading.asciidoc +45 -0
  45. data/elastic-apm.gemspec +17 -0
  46. data/lib/elastic-apm.rb +17 -0
  47. data/lib/elastic_apm.rb +58 -5
  48. data/lib/elastic_apm/agent.rb +55 -4
  49. data/lib/elastic_apm/central_config.rb +27 -8
  50. data/lib/elastic_apm/central_config/cache_control.rb +17 -0
  51. data/lib/elastic_apm/child_durations.rb +26 -4
  52. data/lib/elastic_apm/config.rb +86 -5
  53. data/lib/elastic_apm/config/bytes.rb +17 -0
  54. data/lib/elastic_apm/config/duration.rb +17 -0
  55. data/lib/elastic_apm/config/options.rb +21 -5
  56. data/lib/elastic_apm/config/regexp_list.rb +17 -0
  57. data/lib/elastic_apm/config/wildcard_pattern_list.rb +20 -1
  58. data/lib/elastic_apm/context.rb +17 -0
  59. data/lib/elastic_apm/context/request.rb +17 -0
  60. data/lib/elastic_apm/context/request/socket.rb +17 -0
  61. data/lib/elastic_apm/context/request/url.rb +17 -0
  62. data/lib/elastic_apm/context/response.rb +27 -2
  63. data/lib/elastic_apm/context/user.rb +17 -0
  64. data/lib/elastic_apm/context_builder.rb +17 -0
  65. data/lib/elastic_apm/deprecations.rb +17 -0
  66. data/lib/elastic_apm/error.rb +17 -0
  67. data/lib/elastic_apm/error/exception.rb +17 -0
  68. data/lib/elastic_apm/error/log.rb +17 -0
  69. data/lib/elastic_apm/error_builder.rb +17 -0
  70. data/lib/elastic_apm/grape.rb +17 -0
  71. data/lib/elastic_apm/graphql.rb +91 -0
  72. data/lib/elastic_apm/grpc.rb +99 -0
  73. data/lib/elastic_apm/instrumenter.rb +49 -15
  74. data/lib/elastic_apm/internal_error.rb +17 -0
  75. data/lib/elastic_apm/logging.rb +17 -0
  76. data/lib/elastic_apm/metadata.rb +17 -0
  77. data/lib/elastic_apm/metadata/process_info.rb +17 -0
  78. data/lib/elastic_apm/metadata/service_info.rb +22 -2
  79. data/lib/elastic_apm/metadata/system_info.rb +17 -0
  80. data/lib/elastic_apm/metadata/system_info/container_info.rb +17 -0
  81. data/lib/elastic_apm/metrics.rb +33 -1
  82. data/lib/elastic_apm/metrics/breakdown_set.rb +17 -0
  83. data/lib/elastic_apm/metrics/cpu_mem_set.rb +17 -0
  84. data/lib/elastic_apm/metrics/metric.rb +23 -4
  85. data/lib/elastic_apm/metrics/set.rb +17 -0
  86. data/lib/elastic_apm/metrics/span_scoped_set.rb +17 -0
  87. data/lib/elastic_apm/metrics/transaction_set.rb +17 -0
  88. data/lib/elastic_apm/metrics/vm_set.rb +17 -0
  89. data/lib/elastic_apm/metricset.rb +17 -0
  90. data/lib/elastic_apm/middleware.rb +20 -4
  91. data/lib/elastic_apm/naively_hashable.rb +17 -0
  92. data/lib/elastic_apm/normalizers.rb +17 -0
  93. data/lib/elastic_apm/normalizers/grape.rb +17 -0
  94. data/lib/elastic_apm/normalizers/grape/endpoint_run.rb +18 -1
  95. data/lib/elastic_apm/normalizers/rails.rb +17 -0
  96. data/lib/elastic_apm/normalizers/rails/action_controller.rb +17 -0
  97. data/lib/elastic_apm/normalizers/rails/action_mailer.rb +17 -0
  98. data/lib/elastic_apm/normalizers/rails/action_view.rb +17 -0
  99. data/lib/elastic_apm/normalizers/rails/active_record.rb +29 -5
  100. data/lib/elastic_apm/opentracing.rb +66 -24
  101. data/lib/elastic_apm/rails.rb +18 -10
  102. data/lib/elastic_apm/railtie.rb +18 -1
  103. data/lib/elastic_apm/resque.rb +29 -0
  104. data/lib/elastic_apm/sinatra.rb +17 -0
  105. data/lib/elastic_apm/span.rb +20 -2
  106. data/lib/elastic_apm/span/context.rb +43 -44
  107. data/lib/elastic_apm/span/context/db.rb +43 -0
  108. data/lib/elastic_apm/span/context/destination.rb +77 -0
  109. data/lib/elastic_apm/span/context/http.rb +43 -0
  110. data/lib/elastic_apm/span_helpers.rb +17 -0
  111. data/lib/elastic_apm/spies.rb +33 -14
  112. data/lib/elastic_apm/spies/action_dispatch.rb +17 -0
  113. data/lib/elastic_apm/spies/delayed_job.rb +17 -0
  114. data/lib/elastic_apm/spies/elasticsearch.rb +49 -5
  115. data/lib/elastic_apm/spies/faraday.rb +53 -18
  116. data/lib/elastic_apm/spies/http.rb +35 -3
  117. data/lib/elastic_apm/spies/json.rb +17 -0
  118. data/lib/elastic_apm/spies/mongo.rb +23 -1
  119. data/lib/elastic_apm/spies/net_http.rb +50 -8
  120. data/lib/elastic_apm/spies/rake.rb +17 -0
  121. data/lib/elastic_apm/spies/redis.rb +17 -0
  122. data/lib/elastic_apm/spies/resque.rb +53 -0
  123. data/lib/elastic_apm/spies/sequel.rb +52 -15
  124. data/lib/elastic_apm/spies/shoryuken.rb +65 -0
  125. data/lib/elastic_apm/spies/sidekiq.rb +17 -0
  126. data/lib/elastic_apm/spies/sinatra.rb +17 -0
  127. data/lib/elastic_apm/spies/sneakers.rb +74 -0
  128. data/lib/elastic_apm/spies/sucker_punch.rb +54 -0
  129. data/lib/elastic_apm/spies/tilt.rb +17 -0
  130. data/lib/elastic_apm/sql.rb +36 -0
  131. data/lib/elastic_apm/sql/signature.rb +169 -0
  132. data/lib/elastic_apm/sql/tokenizer.rb +264 -0
  133. data/lib/elastic_apm/sql/tokens.rb +63 -0
  134. data/lib/elastic_apm/sql_summarizer.rb +18 -2
  135. data/lib/elastic_apm/stacktrace.rb +17 -0
  136. data/lib/elastic_apm/stacktrace/frame.rb +17 -0
  137. data/lib/elastic_apm/stacktrace_builder.rb +23 -1
  138. data/lib/elastic_apm/subscriber.rb +17 -0
  139. data/lib/elastic_apm/trace_context.rb +85 -49
  140. data/lib/elastic_apm/trace_context/traceparent.rb +113 -0
  141. data/lib/elastic_apm/trace_context/tracestate.rb +43 -0
  142. data/lib/elastic_apm/transaction.rb +43 -15
  143. data/lib/elastic_apm/transport/base.rb +39 -23
  144. data/lib/elastic_apm/transport/connection.rb +17 -0
  145. data/lib/elastic_apm/transport/connection/http.rb +17 -0
  146. data/lib/elastic_apm/transport/connection/proxy_pipe.rb +24 -2
  147. data/lib/elastic_apm/transport/filters.rb +17 -0
  148. data/lib/elastic_apm/transport/filters/hash_sanitizer.rb +77 -0
  149. data/lib/elastic_apm/transport/filters/secrets_filter.rb +29 -53
  150. data/lib/elastic_apm/transport/headers.rb +21 -0
  151. data/lib/elastic_apm/transport/serializers.rb +17 -0
  152. data/lib/elastic_apm/transport/serializers/context_serializer.rb +17 -0
  153. data/lib/elastic_apm/transport/serializers/error_serializer.rb +17 -0
  154. data/lib/elastic_apm/transport/serializers/metadata_serializer.rb +44 -20
  155. data/lib/elastic_apm/transport/serializers/metricset_serializer.rb +17 -0
  156. data/lib/elastic_apm/transport/serializers/span_serializer.rb +45 -8
  157. data/lib/elastic_apm/transport/serializers/transaction_serializer.rb +17 -0
  158. data/lib/elastic_apm/transport/user_agent.rb +17 -0
  159. data/lib/elastic_apm/transport/worker.rb +17 -0
  160. data/lib/elastic_apm/util.rb +17 -0
  161. data/lib/elastic_apm/util/inflector.rb +17 -0
  162. data/lib/elastic_apm/util/lru_cache.rb +17 -0
  163. data/lib/elastic_apm/util/throttle.rb +17 -0
  164. data/lib/elastic_apm/version.rb +18 -1
  165. metadata +36 -7
  166. data/.ci/downstreamTests.groovy +0 -185
  167. data/.ci/prepare-git-context.sh +0 -24
  168. data/.github/workflows/main.yml +0 -14
  169. data/CHANGELOG.md +0 -1
@@ -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>
@@ -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::./release-notes.asciidoc[]
36
+ include::./upgrading.asciidoc[]
33
37
 
38
+ include::./release-notes.asciidoc[]
@@ -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
- Please view the {apm-overview-ref-v}/index.html[APM Overview] for details on how these components work together.
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.
@@ -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>>.
@@ -26,7 +26,7 @@ https://www.ruby-lang.org/en/downloads/branches/[Ruby Maintenance Branches].
26
26
  We have automatic support for Ruby on Rails and all Rack compatible web
27
27
  frameworks.
28
28
 
29
- We test against all supported minor versions of Rails and Sinatra.
29
+ We test against all supported minor versions of Rails, Sinatra, and Grape.
30
30
 
31
31
  [float]
32
32
  [[supported-technologies-rails]]
@@ -45,6 +45,14 @@ We currently support all versions of Sinatra since 1.0.
45
45
 
46
46
  See <<getting-started-rack>>.
47
47
 
48
+ [float]
49
+ [[supported-technologies-grape]]
50
+ ==== Grape
51
+
52
+ We currently support all versions of Grape since 1.2.
53
+
54
+ See <<getting-started-grape>>.
55
+
48
56
  [float]
49
57
  [[supported-technologies-databases]]
50
58
  === Databases
@@ -67,3 +75,80 @@ requests using these libraries:
67
75
  - `net/http`
68
76
  - Http.rb (v0.6+)
69
77
  - Faraday (v0.2.1+)
78
+
79
+ [float]
80
+ [[supported-technologies-backgroud-processing]]
81
+ === Background Processing
82
+
83
+ We automatically instrument background processing using:
84
+
85
+ - DelayedJob
86
+ - Sidekiq
87
+ - Shoryuken
88
+ - Sneakers (v2.12.0+) (Experimental, see https://github.com/elastic/apm-agent-ruby/pull/676[#676])
89
+ - Resque (v2.0.0+)
90
+ - SuckerPunch (v2.0.0+)
91
+
92
+ [float]
93
+ [[supported-technologies-resque]]
94
+ === Resque
95
+
96
+ To make the agent work with Resque, you need to require `elastic_apm/resque` before you boot your Resque worker process.
97
+
98
+ For example in your `Rakefile`:
99
+
100
+ [source,ruby]
101
+ ----
102
+ require 'resque'
103
+ require 'elastic_apm'
104
+ require 'elastic_apm/resque'
105
+ ----
106
+
107
+ When you start Resque, you should see a series of messages like the following in the Resque logs:
108
+
109
+ [source,ruby]
110
+ ----
111
+ I, [XXX #81227] INFO -- : Starting worker main
112
+ D, [XXX #81227] DEBUG -- : Registered signals
113
+ I, [XXX #81227] INFO -- : Running before_first_fork hooks
114
+ D, [XXX #81227] DEBUG -- : Starting ElasticAPM agent
115
+ ----
116
+
117
+ Also be sure to set the Resque environment variable `RUN_AT_EXIT_HOOKS` to `true`. Otherwise, the fork may be
118
+ terminated before the agent has a chance to send all the fork's events to the APM server.
119
+
120
+ [float]
121
+ [[supported-technologies-sucker-punch]]
122
+ === SuckerPunch
123
+
124
+ Asynchronously executed jobs in SuckerPunch are automatically instrumented.
125
+
126
+ Note that errors raised in the user-defined `JobClass#perform` method will be first handled by the SuckerPunch exception
127
+ handler before being handled by the agent. The handler is accessed/set via `SuckerPunch.exception_handler` in version
128
+ 2.0. The agent transaction will be marked as successful unless you re-raise the error in the exception handler.
129
+ You can also explicitly report the error via <<api-agent-report,`ElasticAPM.report`>> in a custom SuckerPunch exception
130
+ handler.
131
+
132
+ [float]
133
+ [[supported-technologies-grpc]]
134
+ === gRPC
135
+
136
+ We automatically instrument gRPC using the `grpc` gem. Note that this is experimental, as the `grpc` gem's
137
+ support for `Interceptors` is experimental as of version 1.27.0.
138
+
139
+ To instrument a client, add the `ElasticAPM::GRPC::ClientInterceptor` as an `interceptor` at Stub creation.
140
+
141
+ [source,ruby]
142
+ ----
143
+ Helloworld::Greeter::Stub.new(
144
+ 'localhost:50051',
145
+ interceptors: [ElasticAPM::GRPC::ClientInterceptor.new]
146
+ )
147
+ ----
148
+
149
+ To instrument a server, add the `ElasticAPM::GRPC::ServerInterceptor`.
150
+
151
+ [source,ruby]
152
+ ----
153
+ GRPC::RpcServer.new(interceptors: [ElasticAPM::GRPC::ServerInterceptor.new])
154
+ ----
@@ -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
+ |====
@@ -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'
@@ -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
@@ -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?
@@ -97,6 +126,8 @@ module ElasticAPM
97
126
  # @param type [String] The kind of the transaction, eg `app.request.get` or
98
127
  # `db.mysql2.query`
99
128
  # @param context [Context] An optional [Context]
129
+ # @param trace_context [TraceContext] An optional [TraceContext] object for
130
+ # Distributed Tracing.
100
131
  # @return [Transaction]
101
132
  def start_transaction(
102
133
  name = nil,
@@ -127,6 +158,8 @@ module ElasticAPM
127
158
  # @param type [String] The kind of the transaction, eg `app.request.get` or
128
159
  # `db.mysql2.query`
129
160
  # @param context [Context] An optional [Context]
161
+ # @param trace_context [TraceContext] An optional [TraceContext] object for
162
+ # Distributed Tracing.
130
163
  # @yield [Transaction]
131
164
  # @return result of block
132
165
  def with_transaction(
@@ -165,6 +198,11 @@ module ElasticAPM
165
198
  # @param action [String] The span action type, eq `connect` or `query`
166
199
  # @param context [Span::Context] Context information about the span
167
200
  # @param include_stacktrace [Boolean] Whether or not to capture a stacktrace
201
+ # @param trace_context [TraceContext] An optional [TraceContext] object for
202
+ # Distributed Tracing.
203
+ # @param parent [Transaction,Span] The parent transaction or span.
204
+ # Relevant when the span is created in another thread.
205
+ # @param sync [Boolean] Whether the span is created synchronously or not.
168
206
  # @return [Span]
169
207
  def start_span(
170
208
  name,
@@ -173,7 +211,9 @@ module ElasticAPM
173
211
  action: nil,
174
212
  context: nil,
175
213
  include_stacktrace: true,
176
- trace_context: nil
214
+ trace_context: nil,
215
+ parent: nil,
216
+ sync: nil
177
217
  )
178
218
  agent&.start_span(
179
219
  name,
@@ -181,7 +221,9 @@ module ElasticAPM
181
221
  subtype: subtype,
182
222
  action: action,
183
223
  context: context,
184
- trace_context: trace_context
224
+ trace_context: trace_context,
225
+ parent: parent,
226
+ sync: sync
185
227
  ).tap do |span|
186
228
  break unless span && include_stacktrace
187
229
  break unless agent.config.span_frames_min_duration?
@@ -202,9 +244,16 @@ module ElasticAPM
202
244
  # Wrap a block in a Span, ending it after the block
203
245
  #
204
246
  # @param name [String] A description of the span, eq `SELECT FROM "users"`
205
- # @param type [String] The kind of span, eq `db.mysql2.query`
247
+ # @param type [String] The kind of span, eq `db`
248
+ # @param subtype [String] The subtype of span eg. `postgresql`.
249
+ # @param action [String] The action type of span eg. `connect` or `query`.
206
250
  # @param context [Span::Context] Context information about the span
207
251
  # @param include_stacktrace [Boolean] Whether or not to capture a stacktrace
252
+ # @param trace_context [TraceContext] An optional [TraceContext] object for
253
+ # Distributed Tracing.
254
+ # @param parent [Transaction,Span] The parent transaction or span.
255
+ # Relevant when the span is created in another thread.
256
+ # @param sync [Boolean] Whether the span is created synchronously or not.
208
257
  # @yield [Span]
209
258
  # @return Result of block
210
259
  def with_span(
@@ -214,7 +263,9 @@ module ElasticAPM
214
263
  action: nil,
215
264
  context: nil,
216
265
  include_stacktrace: true,
217
- trace_context: nil
266
+ trace_context: nil,
267
+ parent: nil,
268
+ sync: nil
218
269
  )
219
270
  unless block_given?
220
271
  raise ArgumentError,
@@ -232,7 +283,9 @@ module ElasticAPM
232
283
  action: action,
233
284
  context: context,
234
285
  include_stacktrace: include_stacktrace,
235
- trace_context: trace_context
286
+ trace_context: trace_context,
287
+ parent: parent,
288
+ sync: sync
236
289
  )
237
290
  yield span
238
291
  ensure