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,56 @@
|
|
|
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 Metrics
|
|
22
|
+
# @api private
|
|
23
|
+
class SpanScopedSet < Set
|
|
24
|
+
def collect
|
|
25
|
+
super.tap do |sets|
|
|
26
|
+
next unless sets
|
|
27
|
+
|
|
28
|
+
sets.each do |set|
|
|
29
|
+
move_transaction(set)
|
|
30
|
+
move_span(set)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def move_transaction(set)
|
|
38
|
+
name = set.tags&.delete(:'transaction.name')
|
|
39
|
+
type = set.tags&.delete(:'transaction.type')
|
|
40
|
+
return unless name || type
|
|
41
|
+
|
|
42
|
+
set.transaction = { name: name, type: type }
|
|
43
|
+
set.tags = nil if set.tags.empty?
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def move_span(set)
|
|
47
|
+
type = set.tags&.delete(:'span.type')
|
|
48
|
+
subtype = set.tags&.delete(:'span.subtype')
|
|
49
|
+
return unless type
|
|
50
|
+
|
|
51
|
+
set.span = { type: type, subtype: subtype }
|
|
52
|
+
set.tags = nil if set.tags.empty?
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
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 Metrics
|
|
22
|
+
# @api private
|
|
23
|
+
class TransactionSet < SpanScopedSet
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -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 Atatus
|
|
21
|
+
module Metrics
|
|
22
|
+
# @api private
|
|
23
|
+
class VMSet < Set
|
|
24
|
+
include Logging
|
|
25
|
+
|
|
26
|
+
def collect
|
|
27
|
+
read!
|
|
28
|
+
super
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def read!
|
|
32
|
+
return if disabled?
|
|
33
|
+
|
|
34
|
+
stat = GC.stat
|
|
35
|
+
|
|
36
|
+
gauge(:'ruby.gc.count').value = stat[:count]
|
|
37
|
+
gauge(:'ruby.threads').value = Thread.list.count
|
|
38
|
+
gauge(:'ruby.heap.slots.live').value = stat[:heap_live_slots]
|
|
39
|
+
|
|
40
|
+
gauge(:'ruby.heap.slots.free').value = stat[:heap_free_slots]
|
|
41
|
+
gauge(:'ruby.heap.allocations.total').value =
|
|
42
|
+
stat[:total_allocated_objects]
|
|
43
|
+
|
|
44
|
+
return unless GC::Profiler.enabled?
|
|
45
|
+
|
|
46
|
+
@total_time ||= 0
|
|
47
|
+
@total_time += GC::Profiler.total_time
|
|
48
|
+
GC::Profiler.clear
|
|
49
|
+
gauge(:'ruby.gc.time').value = @total_time
|
|
50
|
+
rescue TypeError => e
|
|
51
|
+
error 'VM metrics encountered error: %s', e
|
|
52
|
+
debug('Backtrace:') { e.backtrace.join("\n") }
|
|
53
|
+
|
|
54
|
+
disable!
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
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
|
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
|
|
@@ -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,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,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
|