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
@@ -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
|
@@ -9,7 +26,6 @@ module Atatus
|
|
9
26
|
@context_serializer ||= ContextSerializer.new(config)
|
10
27
|
end
|
11
28
|
|
12
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
13
29
|
def build(error)
|
14
30
|
base = {
|
15
31
|
id: error.id,
|
@@ -36,7 +52,6 @@ module Atatus
|
|
36
52
|
|
37
53
|
{ error: base }
|
38
54
|
end
|
39
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
40
55
|
|
41
56
|
private
|
42
57
|
|
@@ -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
|
@@ -18,31 +35,36 @@ module Atatus
|
|
18
35
|
|
19
36
|
private
|
20
37
|
|
21
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
22
38
|
def build_service(service)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
base =
|
40
|
+
{
|
41
|
+
name: keyword_field(service.name),
|
42
|
+
environment: keyword_field(service.environment),
|
43
|
+
version: keyword_field(service.version),
|
44
|
+
agent: {
|
45
|
+
name: keyword_field(service.agent.name),
|
46
|
+
version: keyword_field(service.agent.version)
|
47
|
+
},
|
48
|
+
framework: {
|
49
|
+
name: keyword_field(service.framework.name),
|
50
|
+
version: keyword_field(service.framework.version)
|
51
|
+
},
|
52
|
+
language: {
|
53
|
+
name: keyword_field(service.language.name),
|
54
|
+
version: keyword_field(service.language.version)
|
55
|
+
},
|
56
|
+
runtime: {
|
57
|
+
name: keyword_field(service.runtime.name),
|
58
|
+
version: keyword_field(service.runtime.version)
|
59
|
+
}
|
42
60
|
}
|
43
|
-
|
61
|
+
|
62
|
+
if node_name = service.node_name
|
63
|
+
base[:node] = { name: keyword_field(node_name) }
|
64
|
+
end
|
65
|
+
|
66
|
+
base
|
44
67
|
end
|
45
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
46
68
|
|
47
69
|
def build_process(process)
|
48
70
|
{
|
@@ -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
|
@@ -6,13 +23,24 @@ module Atatus
|
|
6
23
|
# @api private
|
7
24
|
class MetricsetSerializer < Serializer
|
8
25
|
def build(metricset)
|
9
|
-
{
|
10
|
-
|
11
|
-
|
12
|
-
tags: keyword_object(metricset.labels),
|
13
|
-
samples: build_samples(metricset.samples)
|
14
|
-
}
|
26
|
+
payload = {
|
27
|
+
timestamp: metricset.timestamp.to_i,
|
28
|
+
samples: build_samples(metricset.samples)
|
15
29
|
}
|
30
|
+
|
31
|
+
if metricset.tags?
|
32
|
+
payload[:tags] = mixed_object(metricset.tags)
|
33
|
+
end
|
34
|
+
|
35
|
+
if metricset.transaction
|
36
|
+
payload[:transaction] = metricset.transaction
|
37
|
+
end
|
38
|
+
|
39
|
+
if metricset.span
|
40
|
+
payload[:span] = metricset.span
|
41
|
+
end
|
42
|
+
|
43
|
+
{ metricset: payload }
|
16
44
|
end
|
17
45
|
|
18
46
|
private
|
@@ -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
|
@@ -13,12 +30,11 @@ module Atatus
|
|
13
30
|
|
14
31
|
attr_reader :context_serializer
|
15
32
|
|
16
|
-
# rubocop:disable Metrics/MethodLength
|
17
33
|
def build(span)
|
18
34
|
{
|
19
35
|
span: {
|
20
36
|
id: span.id,
|
21
|
-
transaction_id: span.
|
37
|
+
transaction_id: span.transaction.id,
|
22
38
|
parent_id: span.parent_id,
|
23
39
|
name: keyword_field(span.name),
|
24
40
|
type: join_type(span),
|
@@ -26,45 +42,64 @@ module Atatus
|
|
26
42
|
context: context_serializer.build(span.context),
|
27
43
|
stacktrace: span.stacktrace.to_a,
|
28
44
|
timestamp: span.timestamp,
|
29
|
-
trace_id: span.trace_id
|
45
|
+
trace_id: span.trace_id,
|
46
|
+
sample_rate: span.sample_rate
|
30
47
|
}
|
31
48
|
}
|
32
49
|
end
|
33
|
-
# rubocop:enable Metrics/MethodLength
|
34
50
|
|
35
51
|
# @api private
|
36
52
|
class ContextSerializer < Serializer
|
53
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
37
54
|
def build(context)
|
38
55
|
return unless context
|
39
56
|
|
40
|
-
|
41
|
-
|
42
|
-
|
57
|
+
base = {}
|
58
|
+
|
59
|
+
base[:tags] = mixed_object(context.labels) if context.labels.any?
|
60
|
+
base[:sync] = context.sync unless context.sync.nil?
|
61
|
+
base[:db] = build_db(context.db) if context.db
|
62
|
+
base[:http] = build_http(context.http) if context.http
|
63
|
+
|
64
|
+
if context.destination
|
65
|
+
base[:destination] = build_destination(context.destination)
|
43
66
|
end
|
67
|
+
|
68
|
+
base
|
44
69
|
end
|
70
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
45
71
|
|
46
72
|
private
|
47
73
|
|
48
74
|
def build_db(db)
|
49
|
-
return unless db
|
50
|
-
|
51
75
|
{
|
52
76
|
instance: db.instance,
|
53
77
|
statement: Util.truncate(db.statement, max_length: 10_000),
|
54
78
|
type: db.type,
|
55
|
-
user: db.user
|
79
|
+
user: db.user,
|
80
|
+
rows_affected: db.rows_affected
|
56
81
|
}
|
57
82
|
end
|
58
83
|
|
59
84
|
def build_http(http)
|
60
|
-
return unless http
|
61
|
-
|
62
85
|
{
|
63
86
|
url: http.url,
|
64
87
|
status_code: http.status_code.to_i,
|
65
88
|
method: keyword_field(http.method)
|
66
89
|
}
|
67
90
|
end
|
91
|
+
|
92
|
+
def build_destination(destination)
|
93
|
+
{
|
94
|
+
service: {
|
95
|
+
name: keyword_field(destination.name),
|
96
|
+
resource: keyword_field(destination.resource),
|
97
|
+
type: keyword_field(destination.type)
|
98
|
+
},
|
99
|
+
address: keyword_field(destination.address),
|
100
|
+
port: destination.port
|
101
|
+
}
|
102
|
+
end
|
68
103
|
end
|
69
104
|
|
70
105
|
private
|
@@ -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
|
@@ -9,7 +26,6 @@ module Atatus
|
|
9
26
|
@context_serializer ||= ContextSerializer.new(config)
|
10
27
|
end
|
11
28
|
|
12
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
13
29
|
def build(transaction)
|
14
30
|
{
|
15
31
|
transaction: {
|
@@ -22,6 +38,7 @@ module Atatus
|
|
22
38
|
duration: ms(transaction.duration),
|
23
39
|
timestamp: transaction.timestamp,
|
24
40
|
sampled: transaction.sampled?,
|
41
|
+
sample_rate: transaction.sample_rate,
|
25
42
|
context: context_serializer.build(transaction.context),
|
26
43
|
span_count: {
|
27
44
|
started: transaction.started_spans,
|
@@ -30,7 +47,6 @@ module Atatus
|
|
30
47
|
}
|
31
48
|
}
|
32
49
|
end
|
33
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
34
50
|
end
|
35
51
|
end
|
36
52
|
end
|
@@ -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
|
module Transport
|
@@ -57,8 +72,6 @@ module Atatus
|
|
57
72
|
end
|
58
73
|
|
59
74
|
attr_reader :transaction, :span, :error, :metadata, :metricset
|
60
|
-
|
61
|
-
# rubocop:disable Metrics/MethodLength
|
62
75
|
def serialize(resource)
|
63
76
|
case resource
|
64
77
|
when Transaction
|
@@ -75,7 +88,6 @@ module Atatus
|
|
75
88
|
raise UnrecognizedResource, resource.inspect
|
76
89
|
end
|
77
90
|
end
|
78
|
-
# rubocop:enable Metrics/MethodLength
|
79
91
|
end
|
80
92
|
|
81
93
|
def self.new(config)
|
@@ -0,0 +1,48 @@
|
|
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 Transport
|
22
|
+
# @api private
|
23
|
+
class UserAgent
|
24
|
+
def initialize(config)
|
25
|
+
@built = build(config)
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_s
|
29
|
+
@built
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def build(config)
|
35
|
+
metadata = Metadata.new(config)
|
36
|
+
|
37
|
+
[
|
38
|
+
"atatus-ruby/#{VERSION}",
|
39
|
+
HTTP::Request::USER_AGENT,
|
40
|
+
[
|
41
|
+
metadata.service.runtime.name,
|
42
|
+
metadata.service.runtime.version
|
43
|
+
].join('/')
|
44
|
+
].join(' ')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
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
|
@@ -6,6 +23,14 @@ module Atatus
|
|
6
23
|
class Worker
|
7
24
|
include Logging
|
8
25
|
|
26
|
+
class << self
|
27
|
+
def adapter
|
28
|
+
@adapter ||= Connection
|
29
|
+
end
|
30
|
+
|
31
|
+
attr_writer :adapter
|
32
|
+
end
|
33
|
+
|
9
34
|
# @api private
|
10
35
|
class StopMessage; end
|
11
36
|
|
@@ -16,8 +41,7 @@ module Atatus
|
|
16
41
|
config,
|
17
42
|
queue,
|
18
43
|
serializers:,
|
19
|
-
filters
|
20
|
-
conn_adapter: Connection
|
44
|
+
filters:
|
21
45
|
)
|
22
46
|
@config = config
|
23
47
|
@queue = queue
|
@@ -25,13 +49,10 @@ module Atatus
|
|
25
49
|
@serializers = serializers
|
26
50
|
@filters = filters
|
27
51
|
|
28
|
-
|
29
|
-
@connection = conn_adapter.new(config, metadata)
|
52
|
+
@connection = self.class.adapter.new(config)
|
30
53
|
end
|
31
54
|
|
32
55
|
attr_reader :queue, :filters, :name, :connection, :serializers
|
33
|
-
|
34
|
-
# rubocop:disable Metrics/MethodLength
|
35
56
|
def work_forever
|
36
57
|
while (msg = queue.pop)
|
37
58
|
case msg
|
@@ -47,7 +68,6 @@ module Atatus
|
|
47
68
|
warn 'Worker died with exception: %s', e.inspect
|
48
69
|
debug e.backtrace.join("\n")
|
49
70
|
end
|
50
|
-
# rubocop:enable Metrics/MethodLength
|
51
71
|
|
52
72
|
def process(resource)
|
53
73
|
return unless (json = serialize_and_filter(resource))
|
@@ -57,6 +77,10 @@ module Atatus
|
|
57
77
|
private
|
58
78
|
|
59
79
|
def serialize_and_filter(resource)
|
80
|
+
if resource.respond_to?(:prepare_for_serialization!)
|
81
|
+
resource.prepare_for_serialization!
|
82
|
+
end
|
83
|
+
|
60
84
|
serialized = serializers.serialize(resource)
|
61
85
|
|
62
86
|
# if a filter returns nil, it means skip the event
|
@@ -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
|
@@ -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/util/throttle.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
|
data/lib/atatus/util.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
|
@@ -23,7 +40,7 @@ module Atatus
|
|
23
40
|
|
24
41
|
def self.git_sha
|
25
42
|
sha = `git rev-parse --verify HEAD 2>&1`.chomp
|
26
|
-
|
43
|
+
$?&.success? ? sha : nil
|
27
44
|
end
|
28
45
|
|
29
46
|
def self.hex_to_bits(str)
|
data/lib/atatus/version.rb
CHANGED
@@ -1,5 +1,23 @@
|
|
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
|
+
AGENT_NAME = 'Ruby'
|
22
|
+
VERSION = '1.6.1'
|
5
23
|
end
|