atatus 1.3.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/Gemfile +72 -22
- data/LICENSE +1 -1
- data/atatus.gemspec +2 -2
- data/lib/atatus/agent.rb +78 -29
- data/lib/atatus/central_config/cache_control.rb +18 -1
- data/lib/atatus/central_config.rb +72 -27
- data/lib/atatus/child_durations.rb +64 -0
- data/lib/atatus/collector/base.rb +102 -43
- data/lib/atatus/collector/builder.rb +134 -4
- data/lib/atatus/collector/hist.rb +54 -0
- data/lib/atatus/collector/layer.rb +1 -0
- data/lib/atatus/collector/transport.rb +41 -11
- 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/config.rb +129 -28
- data/lib/atatus/context/request/socket.rb +18 -1
- data/lib/atatus/context/request/url.rb +17 -0
- data/lib/atatus/context/request.rb +17 -0
- data/lib/atatus/context/response.rb +27 -2
- data/lib/atatus/context/user.rb +17 -0
- data/lib/atatus/context.rb +32 -1
- data/lib/atatus/context_builder.rb +19 -4
- data/lib/atatus/deprecations.rb +17 -0
- data/lib/atatus/error/exception.rb +24 -0
- data/lib/atatus/error/log.rb +17 -0
- data/lib/atatus/error.rb +27 -0
- data/lib/atatus/error_builder.rb +21 -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/process_info.rb +17 -0
- data/lib/atatus/metadata/service_info.rb +21 -6
- 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/metadata/system_info.rb +22 -3
- data/lib/atatus/metadata.rb +17 -0
- 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/metrics.rb +69 -27
- 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/grape/endpoint_run.rb +65 -0
- data/lib/atatus/normalizers/grape.rb +22 -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/normalizers/rails.rb +27 -0
- data/lib/atatus/normalizers.rb +23 -9
- 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/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/context.rb +43 -28
- data/lib/atatus/span.rb +44 -15
- data/lib/atatus/span_helpers.rb +18 -1
- 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/spies.rb +33 -15
- 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.rb +36 -0
- data/lib/atatus/sql_summarizer.rb +24 -6
- data/lib/atatus/stacktrace/frame.rb +17 -3
- data/lib/atatus/stacktrace.rb +17 -0
- data/lib/atatus/stacktrace_builder.rb +23 -3
- data/lib/atatus/subscriber.rb +23 -4
- data/lib/atatus/trace_context/traceparent.rb +111 -0
- data/lib/atatus/trace_context/tracestate.rb +148 -0
- data/lib/atatus/trace_context.rb +84 -51
- data/lib/atatus/transaction.rb +74 -18
- data/lib/atatus/transport/base.rb +44 -27
- data/lib/atatus/transport/connection/http.rb +58 -35
- data/lib/atatus/transport/connection/proxy_pipe.rb +24 -5
- data/lib/atatus/transport/connection.rb +28 -72
- data/lib/atatus/transport/filters/hash_sanitizer.rb +77 -0
- data/lib/atatus/transport/filters/secrets_filter.rb +30 -55
- data/lib/atatus/transport/filters.rb +18 -1
- data/lib/atatus/transport/headers.rb +83 -0
- 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/serializers.rb +17 -5
- data/lib/atatus/transport/user_agent.rb +48 -0
- data/lib/atatus/transport/worker.rb +31 -7
- 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/util.rb +18 -1
- data/lib/atatus/version.rb +19 -1
- data/lib/atatus.rb +84 -16
- 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
data/lib/atatus/metrics.rb
CHANGED
@@ -1,14 +1,27 @@
|
|
1
|
-
#
|
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.
|
2
17
|
|
3
|
-
|
18
|
+
# frozen_string_literal: true
|
4
19
|
|
5
20
|
module Atatus
|
6
21
|
# @api private
|
7
22
|
module Metrics
|
8
|
-
MUTEX = Mutex.new
|
9
|
-
|
10
23
|
def self.new(config, &block)
|
11
|
-
|
24
|
+
Registry.new(config, &block)
|
12
25
|
end
|
13
26
|
|
14
27
|
def self.platform
|
@@ -16,24 +29,17 @@ module Atatus
|
|
16
29
|
end
|
17
30
|
|
18
31
|
# @api private
|
19
|
-
class
|
32
|
+
class Registry
|
20
33
|
include Logging
|
21
34
|
|
22
35
|
TIMEOUT_INTERVAL = 5 # seconds
|
23
36
|
|
24
|
-
def initialize(config,
|
37
|
+
def initialize(config, &block)
|
25
38
|
@config = config
|
26
|
-
@labels = labels
|
27
|
-
@samplers = [CpuMem, VM].map do |kls|
|
28
|
-
debug "Adding metrics collector '#{kls}'"
|
29
|
-
kls.new(config)
|
30
|
-
end
|
31
39
|
@callback = block
|
32
40
|
end
|
33
41
|
|
34
|
-
attr_reader :config, :
|
35
|
-
|
36
|
-
# rubocop:disable Metrics/MethodLength
|
42
|
+
attr_reader :config, :sets, :callback
|
37
43
|
def start
|
38
44
|
unless config.collect_metrics?
|
39
45
|
debug 'Skipping metrics'
|
@@ -42,6 +48,18 @@ module Atatus
|
|
42
48
|
|
43
49
|
debug 'Starting metrics'
|
44
50
|
|
51
|
+
# Only set the @sets once, in case we stop
|
52
|
+
# and start again.
|
53
|
+
@sets ||= {
|
54
|
+
system: CpuMemSet,
|
55
|
+
# vm: VMSet,
|
56
|
+
breakdown: BreakdownSet,
|
57
|
+
transaction: TransactionSet
|
58
|
+
}.each_with_object({}) do |(key, kls), sets|
|
59
|
+
debug "Adding metrics collector '#{kls}'"
|
60
|
+
sets[key] = kls.new(config)
|
61
|
+
end
|
62
|
+
|
45
63
|
@timer_task = Concurrent::TimerTask.execute(
|
46
64
|
run_now: true,
|
47
65
|
execution_interval: config.metrics_interval,
|
@@ -60,7 +78,6 @@ module Atatus
|
|
60
78
|
|
61
79
|
@running = true
|
62
80
|
end
|
63
|
-
# rubocop:enable Metrics/MethodLength
|
64
81
|
|
65
82
|
def stop
|
66
83
|
return unless running?
|
@@ -75,24 +92,49 @@ module Atatus
|
|
75
92
|
!!@running
|
76
93
|
end
|
77
94
|
|
78
|
-
def
|
79
|
-
|
80
|
-
|
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
|
81
106
|
|
82
|
-
|
107
|
+
def get(key)
|
108
|
+
sets.fetch(key)
|
109
|
+
end
|
110
|
+
|
111
|
+
def collect_and_send
|
112
|
+
return unless @config.recording?
|
113
|
+
metricsets = collect
|
114
|
+
metricsets.compact!
|
115
|
+
metricsets.each do |m|
|
116
|
+
callback.call(m)
|
117
|
+
end
|
83
118
|
end
|
84
119
|
|
85
120
|
def collect
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
121
|
+
sets.each_value.each_with_object([]) do |set, arr|
|
122
|
+
samples = set.collect
|
123
|
+
next unless samples
|
124
|
+
arr.concat(samples)
|
91
125
|
end
|
92
126
|
end
|
93
127
|
end
|
94
128
|
end
|
95
129
|
end
|
96
130
|
|
97
|
-
require 'atatus/
|
98
|
-
|
131
|
+
require 'atatus/metricset'
|
132
|
+
|
133
|
+
require 'atatus/metrics/metric'
|
134
|
+
require 'atatus/metrics/set'
|
135
|
+
|
136
|
+
require 'atatus/metrics/cpu_mem_set'
|
137
|
+
require 'atatus/metrics/vm_set'
|
138
|
+
require 'atatus/metrics/span_scoped_set'
|
139
|
+
require 'atatus/metrics/transaction_set'
|
140
|
+
require 'atatus/metrics/breakdown_set'
|
data/lib/atatus/metricset.rb
CHANGED
@@ -1,19 +1,63 @@
|
|
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
|
4
21
|
# @api private
|
5
22
|
class Metricset
|
6
|
-
def initialize(
|
23
|
+
def initialize(
|
24
|
+
timestamp: Util.micros,
|
25
|
+
tags: nil,
|
26
|
+
transaction: nil,
|
27
|
+
span: nil,
|
28
|
+
**samples
|
29
|
+
)
|
7
30
|
@timestamp = timestamp
|
8
|
-
@
|
31
|
+
@tags = tags
|
32
|
+
@transaction = transaction
|
33
|
+
@span = span
|
9
34
|
@samples = samples
|
10
35
|
end
|
11
36
|
|
12
|
-
attr_accessor :timestamp
|
13
|
-
attr_reader :samples
|
37
|
+
attr_accessor :timestamp, :transaction, :span, :tags
|
38
|
+
attr_reader :samples
|
39
|
+
|
40
|
+
def merge_tags!(tags)
|
41
|
+
return unless tags
|
42
|
+
|
43
|
+
@tags ||= {}
|
44
|
+
@tags.merge! tags
|
45
|
+
end
|
46
|
+
|
47
|
+
def tags?
|
48
|
+
tags&.any?
|
49
|
+
end
|
14
50
|
|
15
51
|
def empty?
|
16
52
|
samples.empty?
|
17
53
|
end
|
54
|
+
|
55
|
+
def inspect
|
56
|
+
"<Atatus::Metricset timestamp:#{timestamp}" \
|
57
|
+
" transaction:#{transaction.inspect}" \
|
58
|
+
" span:#{span.inspect}" \
|
59
|
+
" tags:#{tags.inspect}" \
|
60
|
+
" samples:#{samples.inspect}>"
|
61
|
+
end
|
18
62
|
end
|
19
63
|
end
|
data/lib/atatus/middleware.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
|
#
|
2
19
|
# frozen_string_literal: true
|
3
20
|
|
@@ -10,7 +27,6 @@ module Atatus
|
|
10
27
|
@app = app
|
11
28
|
end
|
12
29
|
|
13
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
14
30
|
def call(env)
|
15
31
|
begin
|
16
32
|
if running? && !path_ignored?(env)
|
@@ -35,7 +51,6 @@ module Atatus
|
|
35
51
|
|
36
52
|
resp
|
37
53
|
end
|
38
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
39
54
|
|
40
55
|
private
|
41
56
|
|
@@ -44,9 +59,15 @@ module Atatus
|
|
44
59
|
end
|
45
60
|
|
46
61
|
def path_ignored?(env)
|
47
|
-
config.ignore_url_patterns.any? do |r|
|
48
|
-
env['PATH_INFO']
|
62
|
+
return true if config.ignore_url_patterns.any? do |r|
|
63
|
+
r.match(env['PATH_INFO'])
|
49
64
|
end
|
65
|
+
|
66
|
+
return true if config.transaction_ignore_urls.any? do |r|
|
67
|
+
r.match(env['PATH_INFO'])
|
68
|
+
end
|
69
|
+
|
70
|
+
false
|
50
71
|
end
|
51
72
|
|
52
73
|
def start_transaction(env)
|
@@ -58,10 +79,9 @@ module Atatus
|
|
58
79
|
end
|
59
80
|
|
60
81
|
def trace_context(env)
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
warn "Couldn't parse invalid traceparent header: #{header.inspect}"
|
82
|
+
TraceContext.parse(env: env)
|
83
|
+
rescue TraceContext::InvalidTraceparentHeader => e
|
84
|
+
warn e.message
|
65
85
|
nil
|
66
86
|
end
|
67
87
|
|
@@ -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
|
@@ -0,0 +1,65 @@
|
|
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
|
+
module Normalizers
|
22
|
+
module Grape
|
23
|
+
# @api private
|
24
|
+
class EndpointRun < Normalizer
|
25
|
+
register 'endpoint_run.grape'
|
26
|
+
|
27
|
+
TYPE = 'app'
|
28
|
+
SUBTYPE = 'resource'
|
29
|
+
|
30
|
+
FRAMEWORK_NAME = 'Grape'
|
31
|
+
|
32
|
+
def normalize(transaction, _name, payload)
|
33
|
+
transaction.name = endpoint(payload[:env])
|
34
|
+
|
35
|
+
if transaction_from_host_app?(transaction)
|
36
|
+
transaction.context.set_service(
|
37
|
+
framework_name: FRAMEWORK_NAME,
|
38
|
+
framework_version: ::Grape::VERSION
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
[transaction.name, TYPE, SUBTYPE, nil, nil]
|
43
|
+
end
|
44
|
+
|
45
|
+
def backtrace(payload)
|
46
|
+
source_location = payload[:endpoint].source.source_location
|
47
|
+
["#{source_location[0]}:#{source_location[1]}"]
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def transaction_from_host_app?(transaction)
|
53
|
+
transaction.framework_name != FRAMEWORK_NAME
|
54
|
+
end
|
55
|
+
|
56
|
+
def endpoint(env)
|
57
|
+
route_name =
|
58
|
+
env['api.endpoint']&.routes&.first&.pattern&.origin ||
|
59
|
+
env['REQUEST_PATH']
|
60
|
+
[env['REQUEST_METHOD'], route_name].join(' ')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +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
|
+
|
18
|
+
# frozen_string_literal: true
|
19
|
+
|
20
|
+
%w[endpoint_run].each do |lib|
|
21
|
+
require "atatus/normalizers/grape/#{lib}"
|
22
|
+
end
|
@@ -0,0 +1,44 @@
|
|
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
|
+
module Normalizers
|
22
|
+
module ActionController
|
23
|
+
# @api private
|
24
|
+
class ProcessActionNormalizer < Normalizer
|
25
|
+
register 'process_action.action_controller'
|
26
|
+
|
27
|
+
TYPE = 'app'
|
28
|
+
SUBTYPE = 'controller'
|
29
|
+
ACTION = 'action'
|
30
|
+
|
31
|
+
def normalize(transaction, _name, payload)
|
32
|
+
transaction.name = endpoint(payload)
|
33
|
+
[transaction.name, TYPE, SUBTYPE, ACTION, nil]
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def endpoint(payload)
|
39
|
+
"#{payload[:controller]}##{payload[:action]}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
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
|
+
module Normalizers
|
22
|
+
module ActionMailer
|
23
|
+
# @api private
|
24
|
+
class ProcessActionNormalizer < Normalizer
|
25
|
+
register 'process.action_mailer'
|
26
|
+
|
27
|
+
TYPE = 'app'
|
28
|
+
SUBTYPE = 'mailer'
|
29
|
+
ACTION = 'action'
|
30
|
+
|
31
|
+
def normalize(_transaction, _name, payload)
|
32
|
+
[endpoint(payload), TYPE, SUBTYPE, ACTION, nil]
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def endpoint(payload)
|
38
|
+
"#{payload[:mailer]}##{payload[:action]}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
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
|
@@ -0,0 +1,80 @@
|
|
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
|
+
require 'atatus/sql'
|
21
|
+
|
22
|
+
module Atatus
|
23
|
+
module Normalizers
|
24
|
+
module ActiveRecord
|
25
|
+
# @api private
|
26
|
+
class SqlNormalizer < Normalizer
|
27
|
+
register 'sql.active_record'
|
28
|
+
|
29
|
+
TYPE = 'db'
|
30
|
+
ACTION = 'sql'
|
31
|
+
SKIP_NAMES = %w[SCHEMA CACHE].freeze
|
32
|
+
UNKNOWN = 'unknown'
|
33
|
+
|
34
|
+
def initialize(*args)
|
35
|
+
super
|
36
|
+
|
37
|
+
@summarizer = Sql.summarizer
|
38
|
+
|
39
|
+
@adapters = {}
|
40
|
+
end
|
41
|
+
|
42
|
+
def normalize(_transaction, _name, payload)
|
43
|
+
return :skip if SKIP_NAMES.include?(payload[:name])
|
44
|
+
|
45
|
+
name = summarize(payload[:sql]) || payload[:name]
|
46
|
+
subtype = subtype_for(payload)
|
47
|
+
|
48
|
+
context =
|
49
|
+
Span::Context.new(
|
50
|
+
db: { statement: payload[:sql], type: 'sql' },
|
51
|
+
destination: { name: subtype, resource: subtype, type: TYPE }
|
52
|
+
)
|
53
|
+
|
54
|
+
[name, TYPE, subtype, ACTION, context]
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def subtype_for(payload)
|
60
|
+
cached_adapter_name(
|
61
|
+
payload[:connection]&.adapter_name ||
|
62
|
+
::ActiveRecord::Base.connection_config[:adapter]
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
def summarize(sql)
|
67
|
+
@summarizer.summarize(sql)
|
68
|
+
end
|
69
|
+
|
70
|
+
def cached_adapter_name(adapter_name)
|
71
|
+
return UNKNOWN if adapter_name.nil? || adapter_name.empty?
|
72
|
+
@adapters[adapter_name] ||
|
73
|
+
(@adapters[adapter_name] = adapter_name.downcase)
|
74
|
+
rescue StandardError
|
75
|
+
nil
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,27 @@
|
|
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
|
+
%w[
|
21
|
+
action_controller
|
22
|
+
action_mailer
|
23
|
+
action_view
|
24
|
+
active_record
|
25
|
+
].each do |lib|
|
26
|
+
require "atatus/normalizers/rails/#{lib}"
|
27
|
+
end
|
data/lib/atatus/normalizers.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 # :nodoc:
|
@@ -12,6 +29,8 @@ module Atatus # :nodoc:
|
|
12
29
|
def self.register(name)
|
13
30
|
Normalizers.register(name, self)
|
14
31
|
end
|
32
|
+
|
33
|
+
def backtrace(payload); end
|
15
34
|
end
|
16
35
|
|
17
36
|
def self.register(name, klass)
|
@@ -54,15 +73,10 @@ module Atatus # :nodoc:
|
|
54
73
|
def normalize(transaction, name, payload)
|
55
74
|
self.for(name).normalize(transaction, name, payload)
|
56
75
|
end
|
57
|
-
end
|
58
|
-
end
|
59
76
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
active_record
|
65
|
-
].each do |lib|
|
66
|
-
require "atatus/normalizers/#{lib}"
|
77
|
+
def backtrace(name, payload)
|
78
|
+
self.for(name).backtrace(payload)
|
79
|
+
end
|
80
|
+
end
|
67
81
|
end
|
68
82
|
end
|