atatus 1.3.0 → 1.4.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/CHANGELOG.md +6 -0
- data/Gemfile +72 -22
- data/LICENSE +1 -1
- data/atatus.gemspec +2 -2
- data/lib/atatus.rb +76 -16
- data/lib/atatus/agent.rb +78 -29
- data/lib/atatus/central_config.rb +72 -27
- data/lib/atatus/central_config/cache_control.rb +18 -1
- data/lib/atatus/child_durations.rb +64 -0
- data/lib/atatus/collector/base.rb +61 -29
- data/lib/atatus/collector/builder.rb +46 -2
- data/lib/atatus/collector/hist.rb +54 -0
- data/lib/atatus/collector/transport.rb +41 -11
- data/lib/atatus/config.rb +129 -28
- data/lib/atatus/config/bytes.rb +17 -0
- data/lib/atatus/config/duration.rb +17 -0
- data/lib/atatus/config/options.rb +29 -9
- data/lib/atatus/config/regexp_list.rb +17 -0
- data/lib/atatus/config/wildcard_pattern_list.rb +64 -0
- data/lib/atatus/context.rb +32 -1
- data/lib/atatus/context/request.rb +17 -0
- data/lib/atatus/context/request/socket.rb +18 -1
- data/lib/atatus/context/request/url.rb +17 -0
- data/lib/atatus/context/response.rb +27 -2
- data/lib/atatus/context/user.rb +17 -0
- data/lib/atatus/context_builder.rb +19 -4
- data/lib/atatus/deprecations.rb +17 -0
- data/lib/atatus/error.rb +27 -0
- data/lib/atatus/error/exception.rb +24 -0
- data/lib/atatus/error/log.rb +17 -0
- data/lib/atatus/error_builder.rb +17 -2
- data/lib/atatus/grape.rb +62 -0
- data/lib/atatus/graphql.rb +91 -0
- data/lib/atatus/grpc.rb +99 -0
- data/lib/atatus/instrumenter.rb +135 -30
- data/lib/atatus/internal_error.rb +17 -0
- data/lib/atatus/logging.rb +17 -2
- data/lib/atatus/metadata.rb +17 -0
- data/lib/atatus/metadata/process_info.rb +17 -0
- data/lib/atatus/metadata/service_info.rb +21 -6
- data/lib/atatus/metadata/system_info.rb +22 -3
- data/lib/atatus/metadata/system_info/container_info.rb +49 -10
- data/lib/atatus/metadata/system_info/hw_info.rb +1 -1
- data/lib/atatus/metrics.rb +69 -27
- data/lib/atatus/metrics/breakdown_set.rb +31 -0
- data/lib/atatus/metrics/{cpu_mem.rb → cpu_mem_set.rb} +110 -63
- data/lib/atatus/metrics/metric.rb +140 -0
- data/lib/atatus/metrics/set.rb +123 -0
- data/lib/atatus/metrics/span_scoped_set.rb +56 -0
- data/lib/atatus/metrics/transaction_set.rb +26 -0
- data/lib/atatus/metrics/vm_set.rb +58 -0
- data/lib/atatus/metricset.rb +48 -4
- data/lib/atatus/middleware.rb +28 -8
- data/lib/atatus/naively_hashable.rb +17 -0
- data/lib/atatus/normalizers.rb +23 -9
- data/lib/atatus/normalizers/grape.rb +22 -0
- data/lib/atatus/normalizers/grape/endpoint_run.rb +65 -0
- data/lib/atatus/normalizers/rails.rb +27 -0
- data/lib/atatus/normalizers/rails/action_controller.rb +44 -0
- data/lib/atatus/normalizers/rails/action_mailer.rb +43 -0
- data/lib/atatus/normalizers/{action_view.rb → rails/action_view.rb} +17 -0
- data/lib/atatus/normalizers/rails/active_record.rb +80 -0
- data/lib/atatus/opentracing.rb +75 -42
- data/lib/atatus/rails.rb +29 -13
- data/lib/atatus/railtie.rb +19 -6
- data/lib/atatus/resque.rb +29 -0
- data/lib/atatus/sinatra.rb +53 -0
- data/lib/atatus/span.rb +44 -15
- data/lib/atatus/span/context.rb +43 -28
- data/lib/atatus/span/context/db.rb +43 -0
- data/lib/atatus/span/context/destination.rb +77 -0
- data/lib/atatus/span/context/http.rb +43 -0
- data/lib/atatus/span_helpers.rb +18 -1
- data/lib/atatus/spies.rb +33 -15
- data/lib/atatus/spies/action_dispatch.rb +27 -6
- data/lib/atatus/spies/delayed_job.rb +26 -5
- data/lib/atatus/spies/dynamo_db.rb +62 -0
- data/lib/atatus/spies/elasticsearch.rb +53 -7
- data/lib/atatus/spies/faraday.rb +54 -20
- data/lib/atatus/spies/http.rb +36 -6
- data/lib/atatus/spies/json.rb +18 -0
- data/lib/atatus/spies/mongo.rb +41 -10
- data/lib/atatus/spies/net_http.rb +52 -11
- data/lib/atatus/spies/rake.rb +42 -23
- data/lib/atatus/spies/redis.rb +17 -0
- data/lib/atatus/spies/resque.rb +57 -0
- data/lib/atatus/spies/sequel.rb +54 -17
- data/lib/atatus/spies/shoryuken.rb +69 -0
- data/lib/atatus/spies/sidekiq.rb +46 -25
- data/lib/atatus/spies/sinatra.rb +20 -4
- data/lib/atatus/spies/sneakers.rb +74 -0
- data/lib/atatus/spies/sucker_punch.rb +58 -0
- data/lib/atatus/spies/tilt.rb +20 -1
- data/lib/atatus/sql.rb +36 -0
- data/lib/atatus/sql/signature.rb +169 -0
- data/lib/atatus/sql/tokenizer.rb +264 -0
- data/lib/atatus/sql/tokens.rb +63 -0
- data/lib/atatus/sql_summarizer.rb +24 -6
- data/lib/atatus/stacktrace.rb +17 -0
- data/lib/atatus/stacktrace/frame.rb +17 -3
- data/lib/atatus/stacktrace_builder.rb +23 -3
- data/lib/atatus/subscriber.rb +23 -4
- data/lib/atatus/trace_context.rb +84 -51
- data/lib/atatus/trace_context/traceparent.rb +111 -0
- data/lib/atatus/trace_context/tracestate.rb +148 -0
- data/lib/atatus/transaction.rb +74 -18
- data/lib/atatus/transport/base.rb +44 -27
- data/lib/atatus/transport/connection.rb +28 -72
- data/lib/atatus/transport/connection/http.rb +58 -35
- data/lib/atatus/transport/connection/proxy_pipe.rb +24 -5
- data/lib/atatus/transport/filters.rb +18 -1
- data/lib/atatus/transport/filters/hash_sanitizer.rb +77 -0
- data/lib/atatus/transport/filters/secrets_filter.rb +30 -55
- data/lib/atatus/transport/headers.rb +83 -0
- data/lib/atatus/transport/serializers.rb +17 -5
- data/lib/atatus/transport/serializers/context_serializer.rb +30 -3
- data/lib/atatus/transport/serializers/error_serializer.rb +17 -2
- data/lib/atatus/transport/serializers/metadata_serializer.rb +44 -22
- data/lib/atatus/transport/serializers/metricset_serializer.rb +34 -6
- data/lib/atatus/transport/serializers/span_serializer.rb +47 -12
- data/lib/atatus/transport/serializers/transaction_serializer.rb +18 -2
- data/lib/atatus/transport/user_agent.rb +48 -0
- data/lib/atatus/transport/worker.rb +31 -7
- data/lib/atatus/util.rb +18 -1
- data/lib/atatus/util/inflector.rb +17 -0
- data/lib/atatus/util/lru_cache.rb +17 -0
- data/lib/atatus/util/throttle.rb +17 -0
- data/lib/atatus/version.rb +19 -1
- metadata +46 -26
- data/Rakefile +0 -19
- data/bench/.gitignore +0 -2
- data/bench/app.rb +0 -53
- data/bench/benchmark.rb +0 -36
- data/bench/report.rb +0 -55
- data/bench/rubyprof.rb +0 -39
- data/bench/stackprof.rb +0 -23
- data/bin/build_docs +0 -5
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/bin/with_framework +0 -7
- data/lib/atatus/metrics/vm.rb +0 -60
- data/lib/atatus/normalizers/action_controller.rb +0 -27
- data/lib/atatus/normalizers/action_mailer.rb +0 -26
- data/lib/atatus/normalizers/active_record.rb +0 -45
- data/lib/atatus/util/prefixed_logger.rb +0 -18
- data/vendor/.gitkeep +0 -0
|
@@ -0,0 +1,77 @@
|
|
|
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 Atatus
|
|
21
|
+
class Span
|
|
22
|
+
class Context
|
|
23
|
+
# @api private
|
|
24
|
+
class Destination
|
|
25
|
+
def initialize(
|
|
26
|
+
name: nil,
|
|
27
|
+
resource: nil,
|
|
28
|
+
type: nil,
|
|
29
|
+
address: nil,
|
|
30
|
+
port: nil
|
|
31
|
+
)
|
|
32
|
+
@name = name
|
|
33
|
+
@resource = resource
|
|
34
|
+
@type = type
|
|
35
|
+
@address = address
|
|
36
|
+
@port = port
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
attr_reader(
|
|
40
|
+
:name,
|
|
41
|
+
:resource,
|
|
42
|
+
:type,
|
|
43
|
+
:address,
|
|
44
|
+
:port
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
def self.from_uri(uri_or_str, type: 'external', port: nil)
|
|
48
|
+
uri = normalize(uri_or_str)
|
|
49
|
+
|
|
50
|
+
new(
|
|
51
|
+
name: only_scheme_and_host(uri),
|
|
52
|
+
resource: "#{uri.host}:#{uri.port}",
|
|
53
|
+
type: type,
|
|
54
|
+
address: uri.hostname,
|
|
55
|
+
port: port || uri.port
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def self.only_scheme_and_host(uri_or_str)
|
|
60
|
+
uri = normalize(uri_or_str)
|
|
61
|
+
uri.path = ''
|
|
62
|
+
uri.password = uri.query = uri.fragment = nil
|
|
63
|
+
uri.to_s
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
class << self
|
|
67
|
+
private
|
|
68
|
+
|
|
69
|
+
def normalize(uri_or_str)
|
|
70
|
+
return uri_or_str.dup if uri_or_str.is_a?(URI)
|
|
71
|
+
URI(uri_or_str)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
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 Atatus
|
|
21
|
+
class Span
|
|
22
|
+
class Context
|
|
23
|
+
# @api private
|
|
24
|
+
class Http
|
|
25
|
+
def initialize(url: nil, status_code: nil, method: nil)
|
|
26
|
+
@url = sanitize_url(url)
|
|
27
|
+
@status_code = status_code
|
|
28
|
+
@method = method
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
attr_accessor :url, :status_code, :method
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def sanitize_url(uri_or_str)
|
|
36
|
+
uri = uri_or_str.is_a?(URI) ? uri_or_str.dup : URI(uri_or_str)
|
|
37
|
+
uri.password = nil
|
|
38
|
+
uri.to_s
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
data/lib/atatus/span_helpers.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 Atatus
|
|
@@ -50,4 +67,4 @@ module Atatus
|
|
|
50
67
|
end
|
|
51
68
|
end
|
|
52
69
|
end
|
|
53
|
-
end
|
|
70
|
+
end
|
data/lib/atatus/spies.rb
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
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
|
-
require 'forwardable'
|
|
4
20
|
require 'atatus/util/inflector'
|
|
5
21
|
|
|
6
22
|
module Atatus
|
|
@@ -64,23 +80,25 @@ module Atatus
|
|
|
64
80
|
end
|
|
65
81
|
end
|
|
66
82
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
83
|
+
unless ENV['ATATUS_SKIP_REQUIRE_PATCH'] == '1'
|
|
84
|
+
# @api private
|
|
85
|
+
module Kernel
|
|
86
|
+
private
|
|
70
87
|
|
|
71
|
-
|
|
88
|
+
alias require_without_apm require
|
|
72
89
|
|
|
73
|
-
|
|
74
|
-
|
|
90
|
+
def require(path)
|
|
91
|
+
res = require_without_apm(path)
|
|
75
92
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
93
|
+
begin
|
|
94
|
+
Atatus::Spies.hook_into(path)
|
|
95
|
+
rescue ::Exception => e
|
|
96
|
+
puts "Failed hooking into '#{path}'. Please report this at " \
|
|
97
|
+
'success@atatus.com'
|
|
98
|
+
puts e.backtrace.join("\n")
|
|
99
|
+
end
|
|
83
100
|
|
|
84
|
-
|
|
101
|
+
res
|
|
102
|
+
end
|
|
85
103
|
end
|
|
86
104
|
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
|
module Atatus
|
|
@@ -6,15 +23,19 @@ module Atatus
|
|
|
6
23
|
# @api private
|
|
7
24
|
class ActionDispatchSpy
|
|
8
25
|
def install
|
|
9
|
-
::ActionDispatch::ShowExceptions
|
|
10
|
-
|
|
26
|
+
if defined?(::ActionDispatch) && defined?(::ActionDispatch::ShowExceptions)
|
|
27
|
+
|
|
28
|
+
::ActionDispatch::ShowExceptions.class_eval do
|
|
29
|
+
alias render_exception_without_apm render_exception
|
|
11
30
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
31
|
+
def render_exception(env, exception)
|
|
32
|
+
context = Atatus.build_context(rack_env: env, for_type: :error)
|
|
33
|
+
Atatus.report(exception, context: context, handled: false)
|
|
15
34
|
|
|
16
|
-
|
|
35
|
+
render_exception_without_apm env, exception
|
|
36
|
+
end
|
|
17
37
|
end
|
|
38
|
+
|
|
18
39
|
end
|
|
19
40
|
end
|
|
20
41
|
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
|
module Atatus
|
|
@@ -10,13 +27,17 @@ module Atatus
|
|
|
10
27
|
TYPE = 'Delayed::Job'
|
|
11
28
|
|
|
12
29
|
def install
|
|
13
|
-
::Delayed::Backend::Base
|
|
14
|
-
|
|
30
|
+
if defined?(::Delayed) && defined?(::Delayed::Backend) && defined?(::Delayed::Backend::Base)
|
|
31
|
+
|
|
32
|
+
::Delayed::Backend::Base.class_eval do
|
|
33
|
+
alias invoke_job_without_apm invoke_job
|
|
15
34
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
35
|
+
def invoke_job(*args, &block)
|
|
36
|
+
::Atatus::Spies::DelayedJobSpy
|
|
37
|
+
.invoke_job(self, *args, &block)
|
|
38
|
+
end
|
|
19
39
|
end
|
|
40
|
+
|
|
20
41
|
end
|
|
21
42
|
end
|
|
22
43
|
|
|
@@ -0,0 +1,62 @@
|
|
|
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 Atatus
|
|
21
|
+
# @api private
|
|
22
|
+
module Spies
|
|
23
|
+
# @api private
|
|
24
|
+
class DynamoDBSpy
|
|
25
|
+
def self.without_net_http
|
|
26
|
+
return yield unless defined?(NetHTTPSpy)
|
|
27
|
+
|
|
28
|
+
Atatus::Spies::NetHTTPSpy.disable_in do
|
|
29
|
+
yield
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def install
|
|
34
|
+
if defined?(::Aws) && defined?(::Aws::DynamoDB) && defined?(::Aws::DynamoDB::Client)
|
|
35
|
+
|
|
36
|
+
::Aws::DynamoDB::Client.class_eval do
|
|
37
|
+
# Alias all available operations
|
|
38
|
+
api.operation_names.each do |operation_name|
|
|
39
|
+
alias :"#{operation_name}_without_apm" :"#{operation_name}"
|
|
40
|
+
|
|
41
|
+
define_method(operation_name) do |params = {}, options = {}|
|
|
42
|
+
Atatus.with_span(operation_name, 'db', subtype: 'dynamodb', action: operation_name) do
|
|
43
|
+
Atatus::Spies::DynamoDBSpy.without_net_http do
|
|
44
|
+
original_method = method("#{operation_name}_without_apm")
|
|
45
|
+
original_method.call(params, options)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
register(
|
|
57
|
+
'Aws::DynamoDB::Client',
|
|
58
|
+
'aws-sdk-dynamodb',
|
|
59
|
+
DynamoDBSpy.new
|
|
60
|
+
)
|
|
61
|
+
end
|
|
62
|
+
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
|
module Atatus
|
|
@@ -6,9 +23,13 @@ module Atatus
|
|
|
6
23
|
# @api private
|
|
7
24
|
class ElasticsearchSpy
|
|
8
25
|
NAME_FORMAT = '%s %s'
|
|
9
|
-
TYPE = 'db
|
|
26
|
+
TYPE = 'db'
|
|
27
|
+
SUBTYPE = 'elasticsearch'
|
|
28
|
+
|
|
29
|
+
def self.sanitizer
|
|
30
|
+
@sanitizer ||= Atatus::Transport::Filters::HashSanitizer.new
|
|
31
|
+
end
|
|
10
32
|
|
|
11
|
-
# rubocop:disable Metrics/MethodLength
|
|
12
33
|
def install
|
|
13
34
|
if defined?(::Elasticsearch) &&
|
|
14
35
|
defined?(::Elasticsearch::Transport) &&
|
|
@@ -18,18 +39,43 @@ module Atatus
|
|
|
18
39
|
alias perform_request_without_apm perform_request
|
|
19
40
|
|
|
20
41
|
def perform_request(method, path, *args, &block)
|
|
42
|
+
unless Atatus.current_transaction
|
|
43
|
+
return perform_request_without_apm(method, path, *args, &block)
|
|
44
|
+
end
|
|
45
|
+
|
|
21
46
|
name = format(NAME_FORMAT, method, path)
|
|
22
|
-
statement =
|
|
23
|
-
context = Span::Context.new(db: { statement: statement })
|
|
47
|
+
statement = []
|
|
24
48
|
|
|
25
|
-
|
|
26
|
-
|
|
49
|
+
statement << { params: args&.[](0) }
|
|
50
|
+
|
|
51
|
+
if Atatus.agent.config.capture_elasticsearch_queries
|
|
52
|
+
unless args[1].nil? || args[1].empty?
|
|
53
|
+
statement << {
|
|
54
|
+
body: Atatus::Spies::ElasticsearchSpy.sanitizer.strip_from!(args[1])
|
|
55
|
+
}
|
|
56
|
+
end
|
|
27
57
|
end
|
|
58
|
+
|
|
59
|
+
context = Span::Context.new(
|
|
60
|
+
db: { statement: statement.reduce({}, :merge).to_json },
|
|
61
|
+
destination: {
|
|
62
|
+
name: SUBTYPE,
|
|
63
|
+
resource: SUBTYPE,
|
|
64
|
+
type: TYPE
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
Atatus.with_span(
|
|
69
|
+
name,
|
|
70
|
+
TYPE,
|
|
71
|
+
subtype: SUBTYPE,
|
|
72
|
+
context: context
|
|
73
|
+
) { perform_request_without_apm(method, path, *args, &block) }
|
|
28
74
|
end
|
|
29
75
|
end
|
|
76
|
+
|
|
30
77
|
end
|
|
31
78
|
end
|
|
32
|
-
# rubocop:enable Metrics/MethodLength
|
|
33
79
|
end
|
|
34
80
|
|
|
35
81
|
register(
|