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.
- checksums.yaml +4 -4
- data/.ci/.jenkins_exclude.yml +43 -24
- data/.ci/.jenkins_framework.yml +2 -2
- data/.ci/.jenkins_ruby.yml +1 -1
- data/.ci/Jenkinsfile +288 -170
- 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/apm-agent-ruby-downstream.yml +1 -0
- data/.ci/jobs/apm-agent-ruby-linting-mbp.yml +1 -0
- data/.ci/jobs/apm-agent-ruby-mbp.yml +1 -0
- data/.ci/jobs/defaults.yml +1 -1
- data/.ci/packer_cache.sh +16 -0
- data/.github/ISSUE_TEMPLATE/Bug_report.md +40 -0
- data/.github/ISSUE_TEMPLATE/Feature_request.md +17 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +60 -0
- data/.gitignore +8 -0
- data/.rspec +0 -1
- data/.rubocop.yml +18 -0
- data/CHANGELOG.asciidoc +104 -1
- data/CONTRIBUTING.md +6 -48
- data/Gemfile +38 -10
- data/README.md +62 -13
- data/Rakefile +37 -5
- data/bench/sql.rb +49 -0
- data/bin/build_docs +1 -1
- data/bin/run-tests +4 -1
- data/docker-compose.yml +7 -0
- data/docs/api.asciidoc +52 -3
- data/docs/configuration.asciidoc +171 -22
- 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 +86 -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 +58 -5
- data/lib/elastic_apm/agent.rb +55 -4
- 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 +26 -4
- data/lib/elastic_apm/config.rb +86 -5
- 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 +21 -5
- data/lib/elastic_apm/config/regexp_list.rb +17 -0
- data/lib/elastic_apm/config/wildcard_pattern_list.rb +20 -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 +27 -2
- data/lib/elastic_apm/context/user.rb +17 -0
- data/lib/elastic_apm/context_builder.rb +17 -0
- 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 +49 -15
- 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 +17 -0
- data/lib/elastic_apm/metadata/system_info/container_info.rb +17 -0
- 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 +23 -4
- 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 +20 -4
- 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 +29 -5
- data/lib/elastic_apm/opentracing.rb +66 -24
- data/lib/elastic_apm/rails.rb +18 -10
- data/lib/elastic_apm/railtie.rb +18 -1
- 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 +43 -44
- data/lib/elastic_apm/span/context/db.rb +43 -0
- data/lib/elastic_apm/span/context/destination.rb +77 -0
- data/lib/elastic_apm/span/context/http.rb +43 -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/elasticsearch.rb +49 -5
- data/lib/elastic_apm/spies/faraday.rb +53 -18
- data/lib/elastic_apm/spies/http.rb +35 -3
- data/lib/elastic_apm/spies/json.rb +17 -0
- data/lib/elastic_apm/spies/mongo.rb +23 -1
- data/lib/elastic_apm/spies/net_http.rb +50 -8
- 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 +52 -15
- data/lib/elastic_apm/spies/shoryuken.rb +65 -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 +74 -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 +36 -0
- data/lib/elastic_apm/sql/signature.rb +169 -0
- data/lib/elastic_apm/sql/tokenizer.rb +264 -0
- data/lib/elastic_apm/sql/tokens.rb +63 -0
- data/lib/elastic_apm/sql_summarizer.rb +18 -2
- 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 +85 -49
- data/lib/elastic_apm/trace_context/traceparent.rb +113 -0
- data/lib/elastic_apm/trace_context/tracestate.rb +43 -0
- data/lib/elastic_apm/transaction.rb +43 -15
- 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 +24 -2
- 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 -53
- data/lib/elastic_apm/transport/headers.rb +21 -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 +45 -8
- 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 +17 -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 +36 -7
- data/.ci/downstreamTests.groovy +0 -185
- data/.ci/prepare-git-context.sh +0 -24
- data/.github/workflows/main.yml +0 -14
- data/CHANGELOG.md +0 -1
@@ -0,0 +1,99 @@
|
|
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
|
+
|
18
|
+
# frozen_string_literal: true
|
19
|
+
|
20
|
+
module ElasticAPM
|
21
|
+
# @api private
|
22
|
+
class GRPC
|
23
|
+
# @api private
|
24
|
+
class ClientInterceptor < ::GRPC::ClientInterceptor
|
25
|
+
TYPE = 'external'
|
26
|
+
SUBTYPE = 'grpc'
|
27
|
+
|
28
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
29
|
+
def request_response(request:, call:, method:, metadata:)
|
30
|
+
return yield unless (transaction = ElasticAPM.current_transaction)
|
31
|
+
if (trace_context = transaction.trace_context)
|
32
|
+
trace_context.apply_headers { |k, v| metadata[k.downcase] = v }
|
33
|
+
end
|
34
|
+
|
35
|
+
ElasticAPM.with_span(
|
36
|
+
method, TYPE,
|
37
|
+
subtype: SUBTYPE,
|
38
|
+
context: span_context(call)
|
39
|
+
) do
|
40
|
+
yield
|
41
|
+
end
|
42
|
+
end
|
43
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def span_context(call)
|
48
|
+
peer = call.instance_variable_get(:@wrapped)&.peer
|
49
|
+
return unless peer
|
50
|
+
|
51
|
+
split_peer = URI.split(peer)
|
52
|
+
destination = ElasticAPM::Span::Context::Destination.new(
|
53
|
+
type: TYPE,
|
54
|
+
name: SUBTYPE,
|
55
|
+
resource: peer,
|
56
|
+
address: split_peer[0],
|
57
|
+
port: split_peer[6]
|
58
|
+
)
|
59
|
+
ElasticAPM::Span::Context.new(destination: destination)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# @api private
|
64
|
+
class ServerInterceptor < ::GRPC::ClientInterceptor
|
65
|
+
TYPE = 'request'
|
66
|
+
|
67
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
68
|
+
def request_response(request:, call:, method:)
|
69
|
+
transaction = start_transaction(call)
|
70
|
+
yield
|
71
|
+
transaction.done 'success'
|
72
|
+
rescue ::Exception => e
|
73
|
+
ElasticAPM.report(e, handled: false)
|
74
|
+
transaction.done 'error' if transaction
|
75
|
+
raise
|
76
|
+
ensure
|
77
|
+
ElasticAPM.end_transaction
|
78
|
+
end
|
79
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def start_transaction(call)
|
84
|
+
ElasticAPM.start_transaction(
|
85
|
+
'grpc',
|
86
|
+
'request',
|
87
|
+
trace_context: trace_context(call)
|
88
|
+
)
|
89
|
+
end
|
90
|
+
|
91
|
+
def trace_context(call)
|
92
|
+
TraceContext.parse(metadata: call.metadata)
|
93
|
+
rescue TraceContext::InvalidTraceparentHeader
|
94
|
+
warn "Couldn't parse invalid trace context header: #{call.metadata}"
|
95
|
+
nil
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -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/trace_context'
|
@@ -52,6 +69,9 @@ module ElasticAPM
|
|
52
69
|
|
53
70
|
def start
|
54
71
|
debug 'Starting instrumenter'
|
72
|
+
# We call register! on @subscriber in case the
|
73
|
+
# instrumenter was stopped and started again
|
74
|
+
@subscriber&.register!
|
55
75
|
end
|
56
76
|
|
57
77
|
def stop
|
@@ -63,6 +83,11 @@ module ElasticAPM
|
|
63
83
|
@subscriber&.unregister!
|
64
84
|
end
|
65
85
|
|
86
|
+
def handle_forking!
|
87
|
+
stop
|
88
|
+
start
|
89
|
+
end
|
90
|
+
|
66
91
|
def subscriber=(subscriber)
|
67
92
|
debug 'Registering subscriber'
|
68
93
|
@subscriber = subscriber
|
@@ -136,6 +161,7 @@ module ElasticAPM
|
|
136
161
|
end
|
137
162
|
|
138
163
|
# rubocop:disable Metrics/CyclomaticComplexity
|
164
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
139
165
|
# rubocop:disable Metrics/ParameterLists
|
140
166
|
def start_span(
|
141
167
|
name,
|
@@ -144,19 +170,25 @@ module ElasticAPM
|
|
144
170
|
action: nil,
|
145
171
|
backtrace: nil,
|
146
172
|
context: nil,
|
147
|
-
trace_context: nil
|
173
|
+
trace_context: nil,
|
174
|
+
parent: nil,
|
175
|
+
sync: nil
|
148
176
|
)
|
149
|
-
return unless (transaction = current_transaction)
|
150
|
-
return unless transaction.sampled?
|
151
177
|
|
152
|
-
transaction
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
178
|
+
transaction =
|
179
|
+
case parent
|
180
|
+
when Span
|
181
|
+
parent.transaction
|
182
|
+
when Transaction
|
183
|
+
parent
|
184
|
+
else
|
185
|
+
current_transaction
|
186
|
+
end
|
187
|
+
return unless transaction
|
188
|
+
return unless transaction.sampled?
|
189
|
+
return unless transaction.inc_started_spans!
|
158
190
|
|
159
|
-
parent
|
191
|
+
parent ||= (current_span || current_transaction)
|
160
192
|
|
161
193
|
span = Span.new(
|
162
194
|
name: name,
|
@@ -167,10 +199,11 @@ module ElasticAPM
|
|
167
199
|
trace_context: trace_context,
|
168
200
|
type: type,
|
169
201
|
context: context,
|
170
|
-
stacktrace_builder: stacktrace_builder
|
202
|
+
stacktrace_builder: stacktrace_builder,
|
203
|
+
sync: sync
|
171
204
|
)
|
172
205
|
|
173
|
-
if backtrace && transaction.
|
206
|
+
if backtrace && transaction.span_frames_min_duration
|
174
207
|
span.original_backtrace = backtrace
|
175
208
|
end
|
176
209
|
|
@@ -180,6 +213,7 @@ module ElasticAPM
|
|
180
213
|
end
|
181
214
|
# rubocop:enable Metrics/ParameterLists
|
182
215
|
# rubocop:enable Metrics/CyclomaticComplexity
|
216
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
183
217
|
|
184
218
|
def end_span
|
185
219
|
return unless (span = current_spans.pop)
|
@@ -225,7 +259,7 @@ module ElasticAPM
|
|
225
259
|
end
|
226
260
|
|
227
261
|
def update_transaction_metrics(transaction)
|
228
|
-
return unless transaction.
|
262
|
+
return unless transaction.collect_metrics
|
229
263
|
|
230
264
|
tags = {
|
231
265
|
'transaction.name': transaction.name,
|
@@ -243,7 +277,7 @@ module ElasticAPM
|
|
243
277
|
).inc!
|
244
278
|
|
245
279
|
return unless transaction.sampled?
|
246
|
-
return unless transaction.
|
280
|
+
return unless transaction.breakdown_metrics
|
247
281
|
|
248
282
|
@metrics.get(:breakdown).counter(
|
249
283
|
:'transaction.breakdown.count',
|
@@ -264,7 +298,7 @@ module ElasticAPM
|
|
264
298
|
end
|
265
299
|
|
266
300
|
def update_span_metrics(span)
|
267
|
-
return unless span.transaction.
|
301
|
+
return unless span.transaction.breakdown_metrics
|
268
302
|
|
269
303
|
tags = {
|
270
304
|
'span.type': span.type,
|
@@ -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
|
module ElasticAPM
|
data/lib/elastic_apm/logging.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
|
module ElasticAPM
|
data/lib/elastic_apm/metadata.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
|
module ElasticAPM
|
@@ -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
|
module ElasticAPM
|
@@ -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
|
module ElasticAPM
|
@@ -13,14 +30,17 @@ module ElasticAPM
|
|
13
30
|
|
14
31
|
attr_reader :name, :version
|
15
32
|
end
|
33
|
+
|
16
34
|
class Agent < Versioned; end
|
17
35
|
class Framework < Versioned; end
|
18
36
|
class Language < Versioned; end
|
19
37
|
class Runtime < Versioned; end
|
38
|
+
|
20
39
|
def initialize(config)
|
21
40
|
@config = config
|
22
41
|
|
23
42
|
@name = @config.service_name
|
43
|
+
@node_name = @config.service_node_name
|
24
44
|
@environment = @config.environment
|
25
45
|
@agent = Agent.new(name: 'ruby', version: VERSION)
|
26
46
|
@framework = Framework.new(
|
@@ -32,8 +52,8 @@ module ElasticAPM
|
|
32
52
|
@version = @config.service_version || Util.git_sha
|
33
53
|
end
|
34
54
|
|
35
|
-
attr_reader :name, :environment, :agent, :framework, :language,
|
36
|
-
:version
|
55
|
+
attr_reader :name, :node_name, :environment, :agent, :framework, :language,
|
56
|
+
:runtime, :version
|
37
57
|
|
38
58
|
private
|
39
59
|
|
@@ -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
|
module ElasticAPM
|
@@ -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
|
module ElasticAPM
|
data/lib/elastic_apm/metrics.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
|
module ElasticAPM
|
@@ -31,7 +48,9 @@ module ElasticAPM
|
|
31
48
|
|
32
49
|
debug 'Starting metrics'
|
33
50
|
|
34
|
-
@sets
|
51
|
+
# Only set the @sets once, in case we stop
|
52
|
+
# and start again.
|
53
|
+
@sets ||= {
|
35
54
|
system: CpuMemSet,
|
36
55
|
vm: VMSet,
|
37
56
|
breakdown: BreakdownSet,
|
@@ -73,11 +92,24 @@ module ElasticAPM
|
|
73
92
|
!!@running
|
74
93
|
end
|
75
94
|
|
95
|
+
def handle_forking!
|
96
|
+
# Note that ideally we would be able to check if the @timer_task died
|
97
|
+
# and restart it. You can't simply check @timer_task.running? because
|
98
|
+
# it will only return the state of the TimerTask, not whether the
|
99
|
+
# internal thread used to manage the execution interval has died.
|
100
|
+
# This is a limitation of the Concurrent::TimerTask object.
|
101
|
+
# Therefore, our only option when forked is to stop and start.
|
102
|
+
# ~estolfo
|
103
|
+
stop
|
104
|
+
start
|
105
|
+
end
|
106
|
+
|
76
107
|
def get(key)
|
77
108
|
sets.fetch(key)
|
78
109
|
end
|
79
110
|
|
80
111
|
def collect_and_send
|
112
|
+
return unless @config.recording?
|
81
113
|
metricsets = collect
|
82
114
|
metricsets.compact!
|
83
115
|
metricsets.each do |m|
|