elastic-apm 3.4.0 → 3.9.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 +39 -20
- data/.ci/.jenkins_framework.yml +2 -2
- data/.ci/Jenkinsfile +286 -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/defaults.yml +1 -1
- data/.ci/packer_cache.sh +16 -0
- data/.github/ISSUE_TEMPLATE/Bug_report.md +13 -11
- data/.github/ISSUE_TEMPLATE/Feature_request.md +8 -8
- data/.github/PULL_REQUEST_TEMPLATE.md +51 -5
- data/.gitignore +5 -0
- data/.rspec +0 -1
- data/.rubocop.yml +13 -1
- data/CHANGELOG.asciidoc +94 -1
- data/CONTRIBUTING.md +6 -48
- data/Gemfile +34 -9
- data/README.md +62 -13
- data/Rakefile +37 -5
- data/bin/run-tests +4 -1
- data/docker-compose.yml +7 -0
- data/docs/api.asciidoc +15 -3
- data/docs/configuration.asciidoc +164 -32
- 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 +49 -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 +82 -7
- 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 +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 +18 -1
- 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 +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 +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 +17 -0
- data/lib/elastic_apm/opentracing.rb +66 -24
- 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 +17 -0
- data/lib/elastic_apm/span/context.rb +17 -0
- data/lib/elastic_apm/span/context/db.rb +26 -2
- 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 +18 -1
- data/lib/elastic_apm/spies/http.rb +19 -1
- 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 +25 -3
- 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 +31 -4
- 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 +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 +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 -53
- 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 +22 -2
- 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 +29 -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/lib/elastic_apm/sinatra.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/span.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/span/context'
|
@@ -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
|
@@ -5,14 +22,21 @@ module ElasticAPM
|
|
5
22
|
class Context
|
6
23
|
# @api private
|
7
24
|
class Db
|
8
|
-
def initialize(
|
25
|
+
def initialize(
|
26
|
+
instance: nil,
|
27
|
+
statement: nil,
|
28
|
+
type: nil,
|
29
|
+
user: nil,
|
30
|
+
rows_affected: nil
|
31
|
+
)
|
9
32
|
@instance = instance
|
10
33
|
@statement = statement
|
11
34
|
@type = type
|
12
35
|
@user = user
|
36
|
+
@rows_affected = rows_affected
|
13
37
|
end
|
14
38
|
|
15
|
-
attr_accessor :instance, :statement, :type, :user
|
39
|
+
attr_accessor :instance, :statement, :type, :user, :rows_affected
|
16
40
|
end
|
17
41
|
end
|
18
42
|
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 ElasticAPM
|
@@ -5,21 +22,37 @@ module ElasticAPM
|
|
5
22
|
class Context
|
6
23
|
# @api private
|
7
24
|
class Destination
|
8
|
-
def initialize(
|
25
|
+
def initialize(
|
26
|
+
name: nil,
|
27
|
+
resource: nil,
|
28
|
+
type: nil,
|
29
|
+
address: nil,
|
30
|
+
port: nil
|
31
|
+
)
|
9
32
|
@name = name
|
10
33
|
@resource = resource
|
11
34
|
@type = type
|
35
|
+
@address = address
|
36
|
+
@port = port
|
12
37
|
end
|
13
38
|
|
14
|
-
attr_reader
|
39
|
+
attr_reader(
|
40
|
+
:name,
|
41
|
+
:resource,
|
42
|
+
:type,
|
43
|
+
:address,
|
44
|
+
:port
|
45
|
+
)
|
15
46
|
|
16
|
-
def self.from_uri(uri_or_str, type: 'external')
|
47
|
+
def self.from_uri(uri_or_str, type: 'external', port: nil)
|
17
48
|
uri = normalize(uri_or_str)
|
18
49
|
|
19
50
|
new(
|
20
51
|
name: only_scheme_and_host(uri),
|
21
52
|
resource: "#{uri.host}:#{uri.port}",
|
22
|
-
type: type
|
53
|
+
type: type,
|
54
|
+
address: uri.hostname,
|
55
|
+
port: port || uri.port
|
23
56
|
)
|
24
57
|
end
|
25
58
|
|
@@ -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/spies.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/util/inflector'
|
@@ -63,23 +80,25 @@ module ElasticAPM
|
|
63
80
|
end
|
64
81
|
end
|
65
82
|
|
66
|
-
|
67
|
-
|
68
|
-
|
83
|
+
unless ENV['ELASTIC_APM_SKIP_REQUIRE_PATCH'] == '1'
|
84
|
+
# @api private
|
85
|
+
module Kernel
|
86
|
+
private
|
69
87
|
|
70
|
-
|
88
|
+
alias require_without_apm require
|
71
89
|
|
72
|
-
|
73
|
-
|
90
|
+
def require(path)
|
91
|
+
res = require_without_apm(path)
|
74
92
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
93
|
+
begin
|
94
|
+
ElasticAPM::Spies.hook_into(path)
|
95
|
+
rescue ::Exception => e
|
96
|
+
puts "Failed hooking into '#{path}'. Please report this at " \
|
97
|
+
'github.com/elastic/apm-agent-ruby'
|
98
|
+
puts e.backtrace.join("\n")
|
99
|
+
end
|
82
100
|
|
83
|
-
|
101
|
+
res
|
102
|
+
end
|
84
103
|
end
|
85
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 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
|
@@ -0,0 +1,58 @@
|
|
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
|
+
module Spies
|
23
|
+
# @api private
|
24
|
+
class DynamoDBSpy
|
25
|
+
def self.without_net_http
|
26
|
+
return yield unless defined?(NetHTTPSpy)
|
27
|
+
|
28
|
+
ElasticAPM::Spies::NetHTTPSpy.disable_in do
|
29
|
+
yield
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def install
|
34
|
+
::Aws::DynamoDB::Client.class_eval do
|
35
|
+
# Alias all available operations
|
36
|
+
api.operation_names.each do |operation_name|
|
37
|
+
alias :"#{operation_name}_without_apm" :"#{operation_name}"
|
38
|
+
|
39
|
+
define_method(operation_name) do |params = {}, options = {}|
|
40
|
+
ElasticAPM.with_span(operation_name, 'db', subtype: 'dynamodb', action: operation_name) do
|
41
|
+
ElasticAPM::Spies::DynamoDBSpy.without_net_http do
|
42
|
+
original_method = method("#{operation_name}_without_apm")
|
43
|
+
original_method.call(params, options)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
register(
|
53
|
+
'Aws::DynamoDB::Client',
|
54
|
+
'aws-sdk-dynamodb',
|
55
|
+
DynamoDBSpy.new
|
56
|
+
)
|
57
|
+
end
|
58
|
+
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 ElasticAPM
|
@@ -9,16 +26,34 @@ module ElasticAPM
|
|
9
26
|
TYPE = 'db'
|
10
27
|
SUBTYPE = 'elasticsearch'
|
11
28
|
|
29
|
+
def self.sanitizer
|
30
|
+
@sanitizer ||= ElasticAPM::Transport::Filters::HashSanitizer.new
|
31
|
+
end
|
32
|
+
|
12
33
|
def install
|
13
34
|
::Elasticsearch::Transport::Client.class_eval do
|
14
35
|
alias perform_request_without_apm perform_request
|
15
36
|
|
16
37
|
def perform_request(method, path, *args, &block)
|
38
|
+
unless ElasticAPM.current_transaction
|
39
|
+
return perform_request_without_apm(method, path, *args, &block)
|
40
|
+
end
|
41
|
+
|
17
42
|
name = format(NAME_FORMAT, method, path)
|
18
|
-
statement =
|
43
|
+
statement = []
|
44
|
+
|
45
|
+
statement << { params: args&.[](0) }
|
46
|
+
|
47
|
+
if ElasticAPM.agent.config.capture_elasticsearch_queries
|
48
|
+
unless args[1].nil? || args[1].empty?
|
49
|
+
statement << {
|
50
|
+
body: ElasticAPM::Spies::ElasticsearchSpy.sanitizer.strip_from!(args[1])
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
19
54
|
|
20
55
|
context = Span::Context.new(
|
21
|
-
db: { statement: statement },
|
56
|
+
db: { statement: statement.reduce({}, :merge).to_json },
|
22
57
|
destination: {
|
23
58
|
name: SUBTYPE,
|
24
59
|
resource: SUBTYPE,
|
@@ -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
|
@@ -63,7 +80,7 @@ module ElasticAPM
|
|
63
80
|
|
64
81
|
result =
|
65
82
|
run_request_without_apm(method, url, body, headers) do |req|
|
66
|
-
req[
|
83
|
+
trace_context.apply_headers { |k, v| req[k] = v }
|
67
84
|
|
68
85
|
yield req if block_given?
|
69
86
|
end
|