atatus 1.0.2 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -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 +115 -35
- data/lib/atatus/collector/builder.rb +104 -33
- data/lib/atatus/collector/hist.rb +54 -0
- data/lib/atatus/collector/layer.rb +3 -0
- data/lib/atatus/collector/transport.rb +44 -10
- data/lib/atatus/config.rb +130 -29
- 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 +48 -18
- 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 +32 -6
- 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 +34 -10
- 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 +75 -19
- 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 +22 -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
data/lib/atatus/rails.rb
CHANGED
@@ -1,14 +1,31 @@
|
|
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
|
|
20
|
+
require 'atatus/railtie'
|
3
21
|
require 'atatus/subscriber'
|
22
|
+
require 'atatus/normalizers/rails'
|
4
23
|
|
5
24
|
module Atatus
|
6
25
|
# Module for explicitly starting the Atatus agent and hooking into Rails.
|
7
26
|
# It is recommended to use the Railtie instead.
|
8
27
|
module Rails
|
9
28
|
extend self
|
10
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
11
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
12
29
|
# Start the Atatus agent and hook into Rails.
|
13
30
|
# Note that the agent won't be started if the Rails console is being used.
|
14
31
|
#
|
@@ -16,11 +33,13 @@ module Atatus
|
|
16
33
|
# @return [true, nil] true if the agent was started, nil otherwise.
|
17
34
|
def start(config)
|
18
35
|
config = Config.new(config) unless config.is_a?(Config)
|
36
|
+
|
19
37
|
if (reason = should_skip?(config))
|
20
38
|
unless config.disable_start_message?
|
21
39
|
config.logger.info "Skipping because: #{reason}. " \
|
22
40
|
"Start manually with `Atatus.start'"
|
23
41
|
end
|
42
|
+
|
24
43
|
return
|
25
44
|
end
|
26
45
|
|
@@ -28,24 +47,21 @@ module Atatus
|
|
28
47
|
attach_subscriber(agent)
|
29
48
|
end
|
30
49
|
|
31
|
-
if Atatus.running? &&
|
32
|
-
!Atatus.agent.config.disabled_instrumentations.include?(
|
33
|
-
'action_dispatch'
|
34
|
-
)
|
35
|
-
require 'atatus/spies/action_dispatch'
|
36
|
-
end
|
37
50
|
Atatus.running?
|
38
51
|
rescue StandardError => e
|
39
|
-
config.
|
40
|
-
|
52
|
+
if config.disable_start_message?
|
53
|
+
config.logger.error format('Failed to start: %s', e.message)
|
54
|
+
config.logger.error "Backtrace:\n" + e.backtrace.join("\n")
|
55
|
+
else
|
56
|
+
puts format('Failed to start: %s', e.message)
|
57
|
+
puts "Backtrace:\n" + e.backtrace.join("\n")
|
58
|
+
end
|
41
59
|
end
|
42
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
43
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
44
60
|
|
45
61
|
private
|
46
62
|
|
47
63
|
def should_skip?(_config)
|
48
|
-
if ::Rails.const_defined?
|
64
|
+
if ::Rails.const_defined?('Console', false)
|
49
65
|
return 'Rails console'
|
50
66
|
end
|
51
67
|
|
data/lib/atatus/railtie.rb
CHANGED
@@ -1,6 +1,21 @@
|
|
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
|
@@ -9,13 +24,11 @@ module Atatus
|
|
9
24
|
|
10
25
|
Config.schema.each do |key, args|
|
11
26
|
next unless args.length > 1
|
12
|
-
config.atatus[key] = args
|
27
|
+
config.atatus[key] = args[:default]
|
13
28
|
end
|
14
29
|
|
15
30
|
initializer 'atatus.initialize' do |app|
|
16
|
-
config = Config.new(app.config.atatus).tap do |c|
|
17
|
-
c.app = app
|
18
|
-
|
31
|
+
config = Config.new(app.config.atatus.merge(app: app)).tap do |c|
|
19
32
|
# Prepend Rails.root to log_path if present
|
20
33
|
if c.log_path && !c.log_path.start_with?('/')
|
21
34
|
c.log_path = ::Rails.root.join(c.log_path)
|
@@ -0,0 +1,29 @@
|
|
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
|
+
# Defines a before_first_fork hook for starting the Atatus agent
|
22
|
+
# with Resque.
|
23
|
+
module Resque
|
24
|
+
::Resque.before_first_fork do
|
25
|
+
::Resque.logger.debug('Starting Atatus agent')
|
26
|
+
Atatus.start
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,53 @@
|
|
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 for starting the Atatus agent and hooking into Sinatra.
|
22
|
+
module Sinatra
|
23
|
+
extend self
|
24
|
+
# Start the Atatus agent and hook into Sinatra.
|
25
|
+
#
|
26
|
+
# @param app [Sinatra::Base] A Sinatra app.
|
27
|
+
# @param config [Config, Hash] An instance of Config or a Hash config.
|
28
|
+
# @return [true, nil] true if the agent was started, nil otherwise.
|
29
|
+
def start(app, config = {})
|
30
|
+
config = Config.new(config) unless config.is_a?(Config)
|
31
|
+
configure_app(app, config)
|
32
|
+
|
33
|
+
Atatus.start(config)
|
34
|
+
Atatus.running?
|
35
|
+
rescue StandardError => e
|
36
|
+
config.logger.error format('Failed to start: %s', e.message)
|
37
|
+
config.logger.debug "Backtrace:\n" + e.backtrace.join("\n")
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def configure_app(app, config)
|
43
|
+
config.service_name ||= format_name(app.to_s)
|
44
|
+
config.framework_name ||= 'Sinatra'
|
45
|
+
config.framework_version ||= ::Sinatra::VERSION
|
46
|
+
config.__root_path ||= Dir.pwd
|
47
|
+
end
|
48
|
+
|
49
|
+
def format_name(str)
|
50
|
+
str&.gsub('::', '_')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/atatus/span.rb
CHANGED
@@ -1,7 +1,21 @@
|
|
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
|
-
|
4
|
-
require 'forwardable'
|
18
|
+
# frozen_string_literal: true
|
5
19
|
|
6
20
|
require 'atatus/span/context'
|
7
21
|
|
@@ -9,21 +23,24 @@ module Atatus
|
|
9
23
|
# @api private
|
10
24
|
class Span
|
11
25
|
extend Forwardable
|
26
|
+
include ChildDurations::Methods
|
12
27
|
|
13
|
-
|
28
|
+
DEFAULT_TYPE = 'Custom'
|
29
|
+
DEFAULT_SUBTYPE = 'Ruby'
|
14
30
|
|
15
|
-
|
16
|
-
|
17
|
-
# rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
|
31
|
+
# rubocop:disable Metrics/ParameterLists
|
18
32
|
def initialize(
|
19
33
|
name:,
|
20
|
-
|
34
|
+
transaction:,
|
21
35
|
trace_context:,
|
36
|
+
parent:,
|
22
37
|
type: nil,
|
23
38
|
subtype: nil,
|
24
39
|
action: nil,
|
25
40
|
context: nil,
|
26
|
-
stacktrace_builder: nil
|
41
|
+
stacktrace_builder: nil,
|
42
|
+
sync: nil,
|
43
|
+
sample_rate: nil
|
27
44
|
)
|
28
45
|
@name = name
|
29
46
|
|
@@ -31,17 +48,22 @@ module Atatus
|
|
31
48
|
@type, @subtype, @action = type.split('.')
|
32
49
|
else
|
33
50
|
@type = type || DEFAULT_TYPE
|
34
|
-
@subtype = subtype
|
51
|
+
@subtype = subtype || DEFAULT_SUBTYPE
|
35
52
|
@action = action
|
36
53
|
end
|
37
54
|
|
38
|
-
@
|
39
|
-
@
|
55
|
+
@transaction = transaction
|
56
|
+
@transaction_id = transaction.id
|
57
|
+
@parent = parent
|
58
|
+
@trace_context = trace_context || parent.trace_context.child
|
59
|
+
@sample_rate = transaction.sample_rate
|
40
60
|
|
41
|
-
@context = context || Span::Context.new
|
61
|
+
@context = context || Span::Context.new(sync: sync)
|
42
62
|
@stacktrace_builder = stacktrace_builder
|
43
63
|
end
|
44
|
-
# rubocop:enable Metrics/ParameterLists
|
64
|
+
# rubocop:enable Metrics/ParameterLists
|
65
|
+
|
66
|
+
def_delegators :@trace_context, :trace_id, :parent_id, :id
|
45
67
|
|
46
68
|
attr_accessor(
|
47
69
|
:action,
|
@@ -54,8 +76,12 @@ module Atatus
|
|
54
76
|
attr_reader(
|
55
77
|
:context,
|
56
78
|
:duration,
|
79
|
+
:parent,
|
80
|
+
:sample_rate,
|
81
|
+
:self_time,
|
57
82
|
:stacktrace,
|
58
83
|
:timestamp,
|
84
|
+
:transaction,
|
59
85
|
:transaction_id
|
60
86
|
)
|
61
87
|
|
@@ -64,21 +90,25 @@ module Atatus
|
|
64
90
|
def start(clock_start = Util.monotonic_micros)
|
65
91
|
@timestamp = Util.micros
|
66
92
|
@clock_start = clock_start
|
93
|
+
@parent.child_started
|
67
94
|
self
|
68
95
|
end
|
69
96
|
|
70
97
|
def stop(clock_end = Util.monotonic_micros)
|
71
98
|
@duration ||= (clock_end - @clock_start)
|
99
|
+
@parent.child_stopped
|
100
|
+
@self_time = @duration - child_durations.duration
|
72
101
|
self
|
73
102
|
end
|
74
103
|
|
75
104
|
def done(clock_end: Util.monotonic_micros)
|
76
105
|
stop clock_end
|
106
|
+
self
|
107
|
+
end
|
77
108
|
|
78
|
-
|
109
|
+
def prepare_for_serialization!
|
110
|
+
# build_stacktrace! if should_build_stacktrace?
|
79
111
|
self.original_backtrace = nil # release original
|
80
|
-
|
81
|
-
self
|
82
112
|
end
|
83
113
|
|
84
114
|
def stopped?
|
@@ -96,7 +126,7 @@ module Atatus
|
|
96
126
|
# relations
|
97
127
|
|
98
128
|
def inspect
|
99
|
-
"<Atatus::Span id:#{id}" \
|
129
|
+
"<Atatus::Span id:#{trace_context&.id}" \
|
100
130
|
" name:#{name.inspect}" \
|
101
131
|
" type:#{type.inspect}" \
|
102
132
|
'>'
|
data/lib/atatus/span/context.rb
CHANGED
@@ -1,40 +1,55 @@
|
|
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
|
class Span
|
5
22
|
# @api private
|
6
23
|
class Context
|
7
|
-
def initialize(
|
8
|
-
|
9
|
-
|
10
|
-
|
24
|
+
def initialize(
|
25
|
+
db: nil,
|
26
|
+
destination: nil,
|
27
|
+
http: nil,
|
28
|
+
labels: {},
|
29
|
+
sync: nil
|
30
|
+
)
|
31
|
+
@sync = sync
|
32
|
+
@db = db && Db.new(**db)
|
33
|
+
@http = http && Http.new(**http)
|
34
|
+
@destination =
|
35
|
+
case destination
|
36
|
+
when Destination then destination
|
37
|
+
when Hash then Destination.new(**destination)
|
38
|
+
end
|
11
39
|
@labels = labels
|
12
40
|
end
|
13
41
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
@type = type
|
22
|
-
@user = user
|
23
|
-
end
|
24
|
-
|
25
|
-
attr_accessor :instance, :statement, :type, :user
|
26
|
-
end
|
27
|
-
|
28
|
-
# @api private
|
29
|
-
class Http
|
30
|
-
def initialize(url: nil, status_code: nil, method: nil)
|
31
|
-
@url = url
|
32
|
-
@status_code = status_code
|
33
|
-
@method = method
|
34
|
-
end
|
35
|
-
|
36
|
-
attr_accessor :url, :status_code, :method
|
37
|
-
end
|
42
|
+
attr_reader(
|
43
|
+
:db,
|
44
|
+
:destination,
|
45
|
+
:http,
|
46
|
+
:labels,
|
47
|
+
:sync
|
48
|
+
)
|
38
49
|
end
|
39
50
|
end
|
40
51
|
end
|
52
|
+
|
53
|
+
require 'atatus/span/context/db'
|
54
|
+
require 'atatus/span/context/http'
|
55
|
+
require 'atatus/span/context/destination'
|
@@ -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 Db
|
25
|
+
def initialize(
|
26
|
+
instance: nil,
|
27
|
+
statement: nil,
|
28
|
+
type: nil,
|
29
|
+
user: nil,
|
30
|
+
rows_affected: nil
|
31
|
+
)
|
32
|
+
@instance = instance
|
33
|
+
@statement = statement
|
34
|
+
@type = type
|
35
|
+
@user = user
|
36
|
+
@rows_affected = rows_affected
|
37
|
+
end
|
38
|
+
|
39
|
+
attr_accessor :instance, :statement, :type, :user, :rows_affected
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|