elastic-apm 3.3.0 → 3.4.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 +4 -4
- data/.ci/.jenkins_ruby.yml +1 -1
- data/.ci/Jenkinsfile +5 -3
- 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/prepare-git-context.sh +5 -2
- data/.github/ISSUE_TEMPLATE/Bug_report.md +38 -0
- data/.github/ISSUE_TEMPLATE/Feature_request.md +17 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +14 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +6 -0
- data/CHANGELOG.asciidoc +25 -1
- data/Gemfile +6 -2
- data/bench/sql.rb +49 -0
- data/bin/build_docs +1 -1
- data/codecov.yml +32 -0
- data/docs/api.asciidoc +37 -0
- data/docs/configuration.asciidoc +18 -1
- data/docs/supported-technologies.asciidoc +20 -1
- data/lib/elastic_apm.rb +29 -5
- data/lib/elastic_apm/agent.rb +6 -2
- data/lib/elastic_apm/child_durations.rb +9 -4
- data/lib/elastic_apm/config.rb +8 -1
- data/lib/elastic_apm/config/options.rb +3 -4
- data/lib/elastic_apm/context/response.rb +10 -2
- data/lib/elastic_apm/instrumenter.rb +20 -11
- data/lib/elastic_apm/normalizers/rails/active_record.rb +12 -5
- data/lib/elastic_apm/rails.rb +1 -10
- data/lib/elastic_apm/railtie.rb +1 -1
- data/lib/elastic_apm/span.rb +3 -2
- data/lib/elastic_apm/span/context.rb +26 -44
- data/lib/elastic_apm/span/context/db.rb +19 -0
- data/lib/elastic_apm/span/context/destination.rb +44 -0
- data/lib/elastic_apm/span/context/http.rb +26 -0
- data/lib/elastic_apm/spies/elasticsearch.rb +18 -5
- data/lib/elastic_apm/spies/faraday.rb +36 -18
- data/lib/elastic_apm/spies/http.rb +16 -2
- data/lib/elastic_apm/spies/mongo.rb +5 -0
- data/lib/elastic_apm/spies/net_http.rb +27 -7
- data/lib/elastic_apm/spies/sequel.rb +25 -15
- data/lib/elastic_apm/spies/shoryuken.rb +48 -0
- data/lib/elastic_apm/spies/sneakers.rb +57 -0
- data/lib/elastic_apm/sql.rb +19 -0
- data/lib/elastic_apm/sql/signature.rb +152 -0
- data/lib/elastic_apm/sql/tokenizer.rb +247 -0
- data/lib/elastic_apm/sql/tokens.rb +46 -0
- data/lib/elastic_apm/sql_summarizer.rb +1 -2
- data/lib/elastic_apm/transaction.rb +11 -11
- data/lib/elastic_apm/transport/connection/proxy_pipe.rb +2 -2
- data/lib/elastic_apm/transport/headers.rb +4 -0
- data/lib/elastic_apm/transport/serializers/span_serializer.rb +24 -7
- data/lib/elastic_apm/version.rb +1 -1
- metadata +16 -3
- data/.github/workflows/main.yml +0 -14
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ElasticAPM
|
4
|
+
module Sql
|
5
|
+
# @api private
|
6
|
+
module Tokens
|
7
|
+
OTHER = :OTHER
|
8
|
+
COMMENT = :COMMENT
|
9
|
+
IDENT = :IDENT
|
10
|
+
NUMBER = :NUMBER
|
11
|
+
STRING = :STRING
|
12
|
+
|
13
|
+
PERIOD = :PERIOD
|
14
|
+
COMMA = :COMMA
|
15
|
+
LPAREN = :LPAREN
|
16
|
+
RPAREN = :RPAREN
|
17
|
+
|
18
|
+
AS = :AS
|
19
|
+
CALL = :CALL
|
20
|
+
DELETE = :DELETE
|
21
|
+
FROM = :FROM
|
22
|
+
INSERT = :INSERT
|
23
|
+
INTO = :INTO
|
24
|
+
OR = :OR
|
25
|
+
REPLACE = :REPLACE
|
26
|
+
SELECT = :SELECT
|
27
|
+
SET = :SET
|
28
|
+
TABLE = :TABLE
|
29
|
+
TRUNCATE = :TRUNCATE
|
30
|
+
UPDATE = :UPDATE
|
31
|
+
|
32
|
+
KEYWORDS = {
|
33
|
+
2 => [AS, OR],
|
34
|
+
3 => [SET],
|
35
|
+
4 => [CALL, FROM, INTO],
|
36
|
+
5 => [TABLE],
|
37
|
+
6 => [DELETE, INSERT, SELECT, UPDATE],
|
38
|
+
7 => [REPLACE],
|
39
|
+
8 => [TRUNCATE]
|
40
|
+
}.freeze
|
41
|
+
|
42
|
+
KEYWORD_MIN_LENGTH = KEYWORDS.keys.first
|
43
|
+
KEYWORD_MAX_LENGTH = KEYWORDS.keys.last
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -18,14 +18,13 @@ module ElasticAPM
|
|
18
18
|
}.freeze
|
19
19
|
|
20
20
|
FORMAT = '%s%s'
|
21
|
-
UTF8 = 'UTF-8'
|
22
21
|
|
23
22
|
def self.cache
|
24
23
|
@cache ||= Util::LruCache.new
|
25
24
|
end
|
26
25
|
|
27
26
|
def summarize(sql)
|
28
|
-
sql = sql.encode(
|
27
|
+
sql = sql.encode('utf-8', invalid: :replace, undef: :replace)
|
29
28
|
self.class.cache[sql] ||=
|
30
29
|
REGEXES.find do |regex, sig|
|
31
30
|
if (match = sql[0...1000].match(regex))
|
@@ -10,6 +10,7 @@ module ElasticAPM
|
|
10
10
|
:trace_id, :parent_id, :id, :ensure_parent_id
|
11
11
|
|
12
12
|
DEFAULT_TYPE = 'custom'
|
13
|
+
MUTEX = Mutex.new
|
13
14
|
|
14
15
|
# rubocop:disable Metrics/ParameterLists
|
15
16
|
def initialize(
|
@@ -78,21 +79,20 @@ module ElasticAPM
|
|
78
79
|
# spans
|
79
80
|
|
80
81
|
def inc_started_spans!
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
started_spans > config.transaction_max_spans
|
82
|
+
MUTEX.synchronize do
|
83
|
+
@started_spans += 1
|
84
|
+
if @started_spans > config.transaction_max_spans
|
85
|
+
@dropped_spans += 1
|
86
|
+
return false
|
87
|
+
end
|
88
|
+
end
|
89
|
+
true
|
90
90
|
end
|
91
91
|
|
92
92
|
# context
|
93
93
|
|
94
|
-
def add_response(
|
95
|
-
context.response = Context::Response.new(
|
94
|
+
def add_response(status = nil, **args)
|
95
|
+
context.response = Context::Response.new(status, **args)
|
96
96
|
end
|
97
97
|
|
98
98
|
def set_user(user)
|
@@ -12,6 +12,7 @@ module ElasticAPM
|
|
12
12
|
end
|
13
13
|
|
14
14
|
attr_reader :context_serializer
|
15
|
+
|
15
16
|
def build(span)
|
16
17
|
{
|
17
18
|
span: {
|
@@ -31,20 +32,28 @@ module ElasticAPM
|
|
31
32
|
|
32
33
|
# @api private
|
33
34
|
class ContextSerializer < Serializer
|
35
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
34
36
|
def build(context)
|
35
37
|
return unless context
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
base = {}
|
40
|
+
|
41
|
+
base[:tags] = mixed_object(context.labels) if context.labels.any?
|
42
|
+
base[:sync] = context.sync unless context.sync.nil?
|
43
|
+
base[:db] = build_db(context.db) if context.db
|
44
|
+
base[:http] = build_http(context.http) if context.http
|
45
|
+
|
46
|
+
if context.destination
|
47
|
+
base[:destination] = build_destination(context.destination)
|
40
48
|
end
|
49
|
+
|
50
|
+
base
|
41
51
|
end
|
52
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
42
53
|
|
43
54
|
private
|
44
55
|
|
45
56
|
def build_db(db)
|
46
|
-
return unless db
|
47
|
-
|
48
57
|
{
|
49
58
|
instance: db.instance,
|
50
59
|
statement: Util.truncate(db.statement, max_length: 10_000),
|
@@ -54,14 +63,22 @@ module ElasticAPM
|
|
54
63
|
end
|
55
64
|
|
56
65
|
def build_http(http)
|
57
|
-
return unless http
|
58
|
-
|
59
66
|
{
|
60
67
|
url: http.url,
|
61
68
|
status_code: http.status_code.to_i,
|
62
69
|
method: keyword_field(http.method)
|
63
70
|
}
|
64
71
|
end
|
72
|
+
|
73
|
+
def build_destination(destination)
|
74
|
+
{
|
75
|
+
service: {
|
76
|
+
name: keyword_field(destination.name),
|
77
|
+
resource: keyword_field(destination.resource),
|
78
|
+
type: keyword_field(destination.type)
|
79
|
+
}
|
80
|
+
}
|
81
|
+
end
|
65
82
|
end
|
66
83
|
|
67
84
|
private
|
data/lib/elastic_apm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastic-apm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikkel Malmberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -59,7 +59,9 @@ files:
|
|
59
59
|
- ".ci/jobs/defaults.yml"
|
60
60
|
- ".ci/linting.groovy"
|
61
61
|
- ".ci/prepare-git-context.sh"
|
62
|
-
- ".github/
|
62
|
+
- ".github/ISSUE_TEMPLATE/Bug_report.md"
|
63
|
+
- ".github/ISSUE_TEMPLATE/Feature_request.md"
|
64
|
+
- ".github/PULL_REQUEST_TEMPLATE.md"
|
63
65
|
- ".gitignore"
|
64
66
|
- ".pre-commit-config.yaml"
|
65
67
|
- ".rspec"
|
@@ -78,6 +80,7 @@ files:
|
|
78
80
|
- bench/benchmark.rb
|
79
81
|
- bench/report.rb
|
80
82
|
- bench/rubyprof.rb
|
83
|
+
- bench/sql.rb
|
81
84
|
- bench/stackprof.rb
|
82
85
|
- bench/tmp/.gitkeep
|
83
86
|
- bin/build_docs
|
@@ -86,6 +89,7 @@ files:
|
|
86
89
|
- bin/run-tests
|
87
90
|
- bin/setup
|
88
91
|
- bin/with_framework
|
92
|
+
- codecov.yml
|
89
93
|
- docker-compose.yml
|
90
94
|
- docs/advanced.asciidoc
|
91
95
|
- docs/api.asciidoc
|
@@ -162,6 +166,9 @@ files:
|
|
162
166
|
- lib/elastic_apm/sinatra.rb
|
163
167
|
- lib/elastic_apm/span.rb
|
164
168
|
- lib/elastic_apm/span/context.rb
|
169
|
+
- lib/elastic_apm/span/context/db.rb
|
170
|
+
- lib/elastic_apm/span/context/destination.rb
|
171
|
+
- lib/elastic_apm/span/context/http.rb
|
165
172
|
- lib/elastic_apm/span_helpers.rb
|
166
173
|
- lib/elastic_apm/spies.rb
|
167
174
|
- lib/elastic_apm/spies/action_dispatch.rb
|
@@ -175,9 +182,15 @@ files:
|
|
175
182
|
- lib/elastic_apm/spies/rake.rb
|
176
183
|
- lib/elastic_apm/spies/redis.rb
|
177
184
|
- lib/elastic_apm/spies/sequel.rb
|
185
|
+
- lib/elastic_apm/spies/shoryuken.rb
|
178
186
|
- lib/elastic_apm/spies/sidekiq.rb
|
179
187
|
- lib/elastic_apm/spies/sinatra.rb
|
188
|
+
- lib/elastic_apm/spies/sneakers.rb
|
180
189
|
- lib/elastic_apm/spies/tilt.rb
|
190
|
+
- lib/elastic_apm/sql.rb
|
191
|
+
- lib/elastic_apm/sql/signature.rb
|
192
|
+
- lib/elastic_apm/sql/tokenizer.rb
|
193
|
+
- lib/elastic_apm/sql/tokens.rb
|
181
194
|
- lib/elastic_apm/sql_summarizer.rb
|
182
195
|
- lib/elastic_apm/stacktrace.rb
|
183
196
|
- lib/elastic_apm/stacktrace/frame.rb
|
data/.github/workflows/main.yml
DELETED