scout_apm_logging 0.0.13 → 1.0.1
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/.gitignore +0 -4
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +6 -0
- data/NOTICE +4 -0
- data/lib/scout_apm/logging/config.rb +5 -131
- data/lib/scout_apm/logging/loggers/capture.rb +3 -2
- data/lib/scout_apm/logging/loggers/formatter.rb +21 -2
- data/lib/scout_apm/logging/loggers/opentelemetry/LICENSE +201 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/NOTICE +9 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/api/logs/log_record.rb +18 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/api/logs/logger.rb +64 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/api/logs/logger_provider.rb +31 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/api/logs/severity_number.rb +43 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/api/logs/version.rb +18 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/api/logs.rb +28 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/exporter/exporter/otlp/logs_exporter.rb +389 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/exporter/exporter/otlp/version.rb +20 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/exporter/proto/collector/logs/v1/logs_service_pb.rb +43 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/exporter/proto/common/v1/common_pb.rb +58 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/exporter/proto/logs/v1/logs_pb.rb +91 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/exporter/proto/resource/v1/resource_pb.rb +33 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/opentelemetry.rb +62 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/export/batch_log_record_processor.rb +225 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/export/log_record_exporter.rb +64 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/export.rb +34 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/log_record.rb +115 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/log_record_data.rb +31 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/log_record_processor.rb +53 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/logger.rb +94 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/logger_provider.rb +158 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/version.rb +20 -0
- data/lib/scout_apm/logging/loggers/opentelemetry/sdk/logs.rb +28 -0
- data/lib/scout_apm/logging/utils.rb +0 -69
- data/lib/scout_apm/logging/version.rb +1 -1
- data/lib/scout_apm_logging.rb +2 -11
- data/scout_apm_logging.gemspec +7 -0
- data/spec/data/config_test_1.yml +0 -1
- data/spec/data/mock_config.yml +0 -3
- data/spec/integration/rails/lifecycle_spec.rb +57 -23
- data/spec/spec_helper.rb +0 -12
- data/spec/unit/config_spec.rb +0 -12
- data/spec/unit/loggers/capture_spec.rb +0 -6
- metadata +126 -39
- data/bin/scout_apm_logging_monitor +0 -6
- data/lib/scout_apm/logging/monitor/_rails.rb +0 -22
- data/lib/scout_apm/logging/monitor/collector/checksum.rb +0 -51
- data/lib/scout_apm/logging/monitor/collector/configuration.rb +0 -150
- data/lib/scout_apm/logging/monitor/collector/downloader.rb +0 -78
- data/lib/scout_apm/logging/monitor/collector/extractor.rb +0 -37
- data/lib/scout_apm/logging/monitor/collector/manager.rb +0 -57
- data/lib/scout_apm/logging/monitor/monitor.rb +0 -216
- data/lib/scout_apm/logging/monitor_manager/manager.rb +0 -162
- data/lib/scout_apm/logging/state.rb +0 -69
- data/spec/data/empty_logs_config.yml +0 -0
- data/spec/data/logs_config.yml +0 -3
- data/spec/data/state_file.json +0 -3
- data/spec/integration/loggers/capture_spec.rb +0 -68
- data/spec/integration/monitor/collector/downloader/will_verify_checksum.rb +0 -49
- data/spec/integration/monitor/collector_healthcheck_spec.rb +0 -29
- data/spec/integration/monitor/continuous_state_collector_spec.rb +0 -31
- data/spec/integration/monitor/previous_collector_setup_spec.rb +0 -45
- data/spec/integration/monitor_manager/disable_agent_spec.rb +0 -30
- data/spec/integration/monitor_manager/monitor_pid_file_spec.rb +0 -38
- data/spec/integration/monitor_manager/single_monitor_spec.rb +0 -53
- data/spec/unit/monitor/collector/configuration_spec.rb +0 -64
- data/spec/unit/state_spec.rb +0 -20
- data/tooling/checksums.rb +0 -106
metadata
CHANGED
@@ -1,15 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scout_apm_logging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scout APM
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09
|
11
|
+
date: 2024-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: googleapis-common-protos-types
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: google-protobuf
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: opentelemetry-api
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: opentelemetry-common
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: opentelemetry-instrumentation-base
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: opentelemetry-sdk
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.2'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.2'
|
13
97
|
- !ruby/object:Gem::Dependency
|
14
98
|
name: scout_apm
|
15
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +150,20 @@ dependencies:
|
|
66
150
|
- - '='
|
67
151
|
- !ruby/object:Gem::Version
|
68
152
|
version: 1.30.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: webmock
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
69
167
|
description: Sets up log monitoring for Scout APM Ruby clients.
|
70
168
|
email:
|
71
169
|
- support@scoutapp.com
|
@@ -79,9 +177,9 @@ files:
|
|
79
177
|
- CHANGELOG.md
|
80
178
|
- Dockerfile
|
81
179
|
- Gemfile
|
180
|
+
- NOTICE
|
82
181
|
- README.md
|
83
182
|
- Rakefile
|
84
|
-
- bin/scout_apm_logging_monitor
|
85
183
|
- gems/rails.gemfile
|
86
184
|
- lib/scout_apm/logging/config.rb
|
87
185
|
- lib/scout_apm/logging/context.rb
|
@@ -89,46 +187,48 @@ files:
|
|
89
187
|
- lib/scout_apm/logging/loggers/capture.rb
|
90
188
|
- lib/scout_apm/logging/loggers/formatter.rb
|
91
189
|
- lib/scout_apm/logging/loggers/logger.rb
|
190
|
+
- lib/scout_apm/logging/loggers/opentelemetry/LICENSE
|
191
|
+
- lib/scout_apm/logging/loggers/opentelemetry/NOTICE
|
192
|
+
- lib/scout_apm/logging/loggers/opentelemetry/api/logs.rb
|
193
|
+
- lib/scout_apm/logging/loggers/opentelemetry/api/logs/log_record.rb
|
194
|
+
- lib/scout_apm/logging/loggers/opentelemetry/api/logs/logger.rb
|
195
|
+
- lib/scout_apm/logging/loggers/opentelemetry/api/logs/logger_provider.rb
|
196
|
+
- lib/scout_apm/logging/loggers/opentelemetry/api/logs/severity_number.rb
|
197
|
+
- lib/scout_apm/logging/loggers/opentelemetry/api/logs/version.rb
|
198
|
+
- lib/scout_apm/logging/loggers/opentelemetry/exporter/exporter/otlp/logs_exporter.rb
|
199
|
+
- lib/scout_apm/logging/loggers/opentelemetry/exporter/exporter/otlp/version.rb
|
200
|
+
- lib/scout_apm/logging/loggers/opentelemetry/exporter/proto/collector/logs/v1/logs_service_pb.rb
|
201
|
+
- lib/scout_apm/logging/loggers/opentelemetry/exporter/proto/common/v1/common_pb.rb
|
202
|
+
- lib/scout_apm/logging/loggers/opentelemetry/exporter/proto/logs/v1/logs_pb.rb
|
203
|
+
- lib/scout_apm/logging/loggers/opentelemetry/exporter/proto/resource/v1/resource_pb.rb
|
204
|
+
- lib/scout_apm/logging/loggers/opentelemetry/opentelemetry.rb
|
205
|
+
- lib/scout_apm/logging/loggers/opentelemetry/sdk/logs.rb
|
206
|
+
- lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/export.rb
|
207
|
+
- lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/export/batch_log_record_processor.rb
|
208
|
+
- lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/export/log_record_exporter.rb
|
209
|
+
- lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/log_record.rb
|
210
|
+
- lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/log_record_data.rb
|
211
|
+
- lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/log_record_processor.rb
|
212
|
+
- lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/logger.rb
|
213
|
+
- lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/logger_provider.rb
|
214
|
+
- lib/scout_apm/logging/loggers/opentelemetry/sdk/logs/version.rb
|
92
215
|
- lib/scout_apm/logging/loggers/patches/rails_logger.rb
|
93
216
|
- lib/scout_apm/logging/loggers/patches/tagged_logging.rb
|
94
217
|
- lib/scout_apm/logging/loggers/proxy.rb
|
95
218
|
- lib/scout_apm/logging/loggers/swaps/rails.rb
|
96
219
|
- lib/scout_apm/logging/loggers/swaps/scout.rb
|
97
220
|
- lib/scout_apm/logging/loggers/swaps/sidekiq.rb
|
98
|
-
- lib/scout_apm/logging/monitor/_rails.rb
|
99
|
-
- lib/scout_apm/logging/monitor/collector/checksum.rb
|
100
|
-
- lib/scout_apm/logging/monitor/collector/configuration.rb
|
101
|
-
- lib/scout_apm/logging/monitor/collector/downloader.rb
|
102
|
-
- lib/scout_apm/logging/monitor/collector/extractor.rb
|
103
|
-
- lib/scout_apm/logging/monitor/collector/manager.rb
|
104
|
-
- lib/scout_apm/logging/monitor/monitor.rb
|
105
|
-
- lib/scout_apm/logging/monitor_manager/manager.rb
|
106
|
-
- lib/scout_apm/logging/state.rb
|
107
221
|
- lib/scout_apm/logging/utils.rb
|
108
222
|
- lib/scout_apm/logging/version.rb
|
109
223
|
- lib/scout_apm_logging.rb
|
110
224
|
- scout_apm_logging.gemspec
|
111
225
|
- spec/data/config_test_1.yml
|
112
|
-
- spec/data/empty_logs_config.yml
|
113
|
-
- spec/data/logs_config.yml
|
114
226
|
- spec/data/mock_config.yml
|
115
|
-
- spec/data/state_file.json
|
116
|
-
- spec/integration/loggers/capture_spec.rb
|
117
|
-
- spec/integration/monitor/collector/downloader/will_verify_checksum.rb
|
118
|
-
- spec/integration/monitor/collector_healthcheck_spec.rb
|
119
|
-
- spec/integration/monitor/continuous_state_collector_spec.rb
|
120
|
-
- spec/integration/monitor/previous_collector_setup_spec.rb
|
121
|
-
- spec/integration/monitor_manager/disable_agent_spec.rb
|
122
|
-
- spec/integration/monitor_manager/monitor_pid_file_spec.rb
|
123
|
-
- spec/integration/monitor_manager/single_monitor_spec.rb
|
124
227
|
- spec/integration/rails/lifecycle_spec.rb
|
125
228
|
- spec/rails/app.rb
|
126
229
|
- spec/spec_helper.rb
|
127
230
|
- spec/unit/config_spec.rb
|
128
231
|
- spec/unit/loggers/capture_spec.rb
|
129
|
-
- spec/unit/monitor/collector/configuration_spec.rb
|
130
|
-
- spec/unit/state_spec.rb
|
131
|
-
- tooling/checksums.rb
|
132
232
|
homepage: https://github.com/scoutapp/scout_apm_ruby_logging
|
133
233
|
licenses:
|
134
234
|
- MIT
|
@@ -154,22 +254,9 @@ specification_version: 4
|
|
154
254
|
summary: Ruby Logging Support
|
155
255
|
test_files:
|
156
256
|
- spec/data/config_test_1.yml
|
157
|
-
- spec/data/empty_logs_config.yml
|
158
|
-
- spec/data/logs_config.yml
|
159
257
|
- spec/data/mock_config.yml
|
160
|
-
- spec/data/state_file.json
|
161
|
-
- spec/integration/loggers/capture_spec.rb
|
162
|
-
- spec/integration/monitor/collector/downloader/will_verify_checksum.rb
|
163
|
-
- spec/integration/monitor/collector_healthcheck_spec.rb
|
164
|
-
- spec/integration/monitor/continuous_state_collector_spec.rb
|
165
|
-
- spec/integration/monitor/previous_collector_setup_spec.rb
|
166
|
-
- spec/integration/monitor_manager/disable_agent_spec.rb
|
167
|
-
- spec/integration/monitor_manager/monitor_pid_file_spec.rb
|
168
|
-
- spec/integration/monitor_manager/single_monitor_spec.rb
|
169
258
|
- spec/integration/rails/lifecycle_spec.rb
|
170
259
|
- spec/rails/app.rb
|
171
260
|
- spec/spec_helper.rb
|
172
261
|
- spec/unit/config_spec.rb
|
173
262
|
- spec/unit/loggers/capture_spec.rb
|
174
|
-
- spec/unit/monitor/collector/configuration_spec.rb
|
175
|
-
- spec/unit/state_spec.rb
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# We start the monitor process outside the context of Rails, and ultimately don't use
|
4
|
-
# it for anything related to starting the collector. However, when we load the config/scout_apm.yml file,
|
5
|
-
# we support ERB, and users may be using Rails.env methods for naming the app, or configuring whether
|
6
|
-
# monitor should be enabled for a specific environment.
|
7
|
-
|
8
|
-
require 'active_support'
|
9
|
-
|
10
|
-
# https://github.com/rails/rails/blob/v7.2.1/railties/lib/rails.rb#L76
|
11
|
-
module Rails
|
12
|
-
class << self
|
13
|
-
def env
|
14
|
-
# EnvironmentInquirer was added in Rails 6.1
|
15
|
-
@env ||= if const_defined?('::ActiveSupport::EnvironmentInquirer')
|
16
|
-
::ActiveSupport::EnvironmentInquirer.new(ENV['RAILS_ENV'].presence || ENV['RACK_ENV'].presence || 'development')
|
17
|
-
else
|
18
|
-
::ActiveSupport::StringInquirer.new(ENV['RAILS_ENV'].presence || ENV['RACK_ENV'].presence || 'development')
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ScoutApm
|
4
|
-
module Logging
|
5
|
-
module Collector
|
6
|
-
# Contains logic around verifying the checksum of the otelcol-contrib binary.
|
7
|
-
class Checksum
|
8
|
-
attr_reader :context
|
9
|
-
|
10
|
-
KNOWN_CHECKSUMS = {
|
11
|
-
'darwin_amd64' => '5456734e124221e7ff775c52bd3693d05b3fac43ebe06b22aa5f220f1962ed8c',
|
12
|
-
'darwin_arm64' => 'f9564560798ac5c099885903f303fcda97b7ea649ec299e075b72f3805873879',
|
13
|
-
'linux_amd64' => '326772622016f7ff7e966a7ae8a0f439dc49a3d80b6d79a82b62608af447e851',
|
14
|
-
'linux_arm64' => '73d797817540363a37f27e32270f98053ed17b1df36df2d30db1715ce40f4cff'
|
15
|
-
}.freeze
|
16
|
-
|
17
|
-
def initialize(context)
|
18
|
-
@context = context
|
19
|
-
end
|
20
|
-
|
21
|
-
def verified_checksum?(should_log_failures: false)
|
22
|
-
return false unless File.exist?(collector_tar_path)
|
23
|
-
|
24
|
-
checksum = `sha256sum #{collector_tar_path}`.split(' ').first
|
25
|
-
same_checksum_result = checksum == KNOWN_CHECKSUMS[double]
|
26
|
-
|
27
|
-
log_failed_checksum if !same_checksum_result && should_log_failures
|
28
|
-
same_checksum_result
|
29
|
-
end
|
30
|
-
|
31
|
-
def log_failed_checksum
|
32
|
-
if KNOWN_CHECKSUMS.key?(double)
|
33
|
-
context.logger.error('Checksum verification failed for otelcol.tar.gz.')
|
34
|
-
else
|
35
|
-
context.logger.error("Checksum verification failed for otelcol.tar.gz. Unknown architecture: #{double}")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def double
|
42
|
-
"#{Utils.get_host_os}_#{Utils.get_architecture}"
|
43
|
-
end
|
44
|
-
|
45
|
-
def collector_tar_path
|
46
|
-
"#{context.config.value('collector_download_dir')}/otelcol.tar.gz"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,150 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ScoutApm
|
4
|
-
module Logging
|
5
|
-
module Collector
|
6
|
-
# Adds a method to Hash similar to that of the Rails deep_merge.
|
7
|
-
module HashDeepMerge
|
8
|
-
refine Hash do
|
9
|
-
def deep_merge(second)
|
10
|
-
merger = proc { |_, v1, v2|
|
11
|
-
if v1.is_a?(Hash) && v2.is_a?(Hash)
|
12
|
-
v1.merge(v2, &merger)
|
13
|
-
elsif v1.is_a?(Array) && v2.is_a?(Array)
|
14
|
-
v1 | v2
|
15
|
-
else
|
16
|
-
[:undefined, nil, :nil].include?(v2) ? v1 : v2
|
17
|
-
end
|
18
|
-
}
|
19
|
-
merge(second.to_h, &merger)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# Creates the configuration to be used when launching the collector.
|
25
|
-
class Configuration
|
26
|
-
using HashDeepMerge
|
27
|
-
|
28
|
-
attr_reader :context
|
29
|
-
|
30
|
-
def initialize(context)
|
31
|
-
@context = context
|
32
|
-
end
|
33
|
-
|
34
|
-
def setup!
|
35
|
-
create_storage_directories
|
36
|
-
|
37
|
-
create_config_file
|
38
|
-
end
|
39
|
-
|
40
|
-
def create_config_file
|
41
|
-
contents = YAML.dump(combined_contents)
|
42
|
-
File.write(config_file, contents)
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
def create_storage_directories
|
48
|
-
# Sending queue storage directory
|
49
|
-
Utils.ensure_directory_exists(context.config.value('collector_sending_queue_storage_dir'))
|
50
|
-
# Offset storage directory
|
51
|
-
Utils.ensure_directory_exists(context.config.value('collector_offset_storage_dir'))
|
52
|
-
end
|
53
|
-
|
54
|
-
def combined_contents
|
55
|
-
default_contents = YAML.safe_load(config_contents)
|
56
|
-
|
57
|
-
default_contents.deep_merge(loaded_config_contents)
|
58
|
-
end
|
59
|
-
|
60
|
-
def loaded_config_contents
|
61
|
-
config_path = context.config.value('logs_config')
|
62
|
-
|
63
|
-
if config_path && File.exist?(config_path)
|
64
|
-
YAML.load_file(config_path) || {}
|
65
|
-
elsif File.exist?(assumed_config_file_path)
|
66
|
-
YAML.load_file(assumed_config_file_path) || {}
|
67
|
-
else
|
68
|
-
{}
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def config_file
|
73
|
-
context.config.value('collector_config_file')
|
74
|
-
end
|
75
|
-
|
76
|
-
def config_contents # rubocop:disable Metrics/AbcSize
|
77
|
-
<<~CONFIG
|
78
|
-
receivers:
|
79
|
-
filelog:
|
80
|
-
include: [#{context.config.value('logs_monitored').join(',')}]
|
81
|
-
storage: file_storage/filelogreceiver
|
82
|
-
operators:
|
83
|
-
- type: json_parser
|
84
|
-
severity:
|
85
|
-
parse_from: attributes.severity
|
86
|
-
timestamp:
|
87
|
-
parse_from: attributes.time
|
88
|
-
layout: "%Y-%m-%dT%H:%M:%S.%LZ"
|
89
|
-
processors:
|
90
|
-
transform:
|
91
|
-
log_statements:
|
92
|
-
- context: log
|
93
|
-
statements:
|
94
|
-
# Copy original body to raw_bytes attribute.
|
95
|
-
- 'set(attributes["raw_bytes"], body)'
|
96
|
-
# Replace the body with the log message.
|
97
|
-
- 'set(body, attributes["msg"])'
|
98
|
-
# Remove the msg attribute.
|
99
|
-
- 'delete_key(attributes, "msg")'
|
100
|
-
# Move service.name attribute to resource attribute.
|
101
|
-
- 'set(resource.attributes["service.name"], attributes["service.name"])'
|
102
|
-
batch:
|
103
|
-
exporters:
|
104
|
-
otlp:
|
105
|
-
endpoint: #{context.config.value('logs_reporting_endpoint')}
|
106
|
-
headers:
|
107
|
-
x-telemetryhub-key: #{context.config.value('logs_ingest_key')}
|
108
|
-
sending_queue:
|
109
|
-
storage: file_storage/otc
|
110
|
-
extensions:
|
111
|
-
health_check:
|
112
|
-
endpoint: #{health_check_endpoint}
|
113
|
-
file_storage/filelogreceiver:
|
114
|
-
directory: #{context.config.value('collector_offset_storage_dir')}
|
115
|
-
file_storage/otc:
|
116
|
-
directory: #{context.config.value('collector_sending_queue_storage_dir')}
|
117
|
-
timeout: 10s
|
118
|
-
service:
|
119
|
-
extensions:
|
120
|
-
- health_check
|
121
|
-
- file_storage/filelogreceiver
|
122
|
-
- file_storage/otc
|
123
|
-
pipelines:
|
124
|
-
logs:
|
125
|
-
receivers:
|
126
|
-
- filelog
|
127
|
-
processors:
|
128
|
-
- transform
|
129
|
-
- batch
|
130
|
-
exporters:
|
131
|
-
- otlp
|
132
|
-
telemetry:
|
133
|
-
metrics:
|
134
|
-
level: none
|
135
|
-
logs:
|
136
|
-
level: #{context.config.value('collector_log_level')}
|
137
|
-
CONFIG
|
138
|
-
end
|
139
|
-
|
140
|
-
def health_check_endpoint
|
141
|
-
"localhost:#{context.config.value('health_check_port')}"
|
142
|
-
end
|
143
|
-
|
144
|
-
def assumed_config_file_path
|
145
|
-
"#{context.application_root}/config/scout_logs_config.yml"
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ScoutApm
|
4
|
-
module Logging
|
5
|
-
module Collector
|
6
|
-
# Downloads the collector-contrib binary from the OpenTelemetry project.
|
7
|
-
class Downloader
|
8
|
-
attr_accessor :failed_count
|
9
|
-
attr_reader :context, :checksum
|
10
|
-
|
11
|
-
def initialize(context)
|
12
|
-
@context = context
|
13
|
-
@checksum = Checksum.new(context)
|
14
|
-
end
|
15
|
-
|
16
|
-
def download!
|
17
|
-
# Already downloaded the collector. Noop.
|
18
|
-
return if checksum.verified_checksum?
|
19
|
-
|
20
|
-
# Account for issues such as failed extractions or download corruptions.
|
21
|
-
download_collector
|
22
|
-
verify_checksum
|
23
|
-
rescue StandardError => e
|
24
|
-
# Bypass Rubcop useless asignment rule.
|
25
|
-
failed_count ||= 0
|
26
|
-
|
27
|
-
if failed_count < 3
|
28
|
-
context.logger.error("Failed to download or extract otelcol-contrib: #{e}. Retrying...")
|
29
|
-
failed_count += 1
|
30
|
-
retry
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def download_collector(url = nil, redirect: false) # rubocop:disable Metrics/AbcSize
|
35
|
-
# Prevent double logging.
|
36
|
-
unless redirect
|
37
|
-
context.logger.debug("Downloading otelcol-contrib for version #{context.config.value('collector_version')}")
|
38
|
-
end
|
39
|
-
|
40
|
-
url_to_download = url || collector_url
|
41
|
-
uri = URI(url_to_download)
|
42
|
-
|
43
|
-
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
44
|
-
request = Net::HTTP::Get.new(uri)
|
45
|
-
http.request(request) do |response|
|
46
|
-
return download_collector(response['location'], redirect: true) if response.code == '302'
|
47
|
-
|
48
|
-
File.open(destination, 'wb') do |file|
|
49
|
-
response.read_body do |chunk|
|
50
|
-
file.write(chunk)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
private
|
58
|
-
|
59
|
-
def verify_checksum
|
60
|
-
raise 'Invalid checksum on download.' unless checksum.verified_checksum?
|
61
|
-
end
|
62
|
-
|
63
|
-
def collector_url
|
64
|
-
collector_version = context.config.value('collector_version')
|
65
|
-
architecture = Utils.get_architecture
|
66
|
-
host_os = Utils.get_host_os
|
67
|
-
|
68
|
-
# https://opentelemetry.io/docs/collector/installation/#manual-linux-installation
|
69
|
-
"https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v#{collector_version}/otelcol-contrib_#{collector_version}_#{host_os}_#{architecture}.tar.gz"
|
70
|
-
end
|
71
|
-
|
72
|
-
def destination
|
73
|
-
"#{context.config.value('collector_download_dir')}/otelcol.tar.gz"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ScoutApm
|
4
|
-
module Logging
|
5
|
-
module Collector
|
6
|
-
# Extracts the contents of the collector tar file.
|
7
|
-
class Extractor
|
8
|
-
attr_reader :context
|
9
|
-
|
10
|
-
def initialize(context)
|
11
|
-
@context = context
|
12
|
-
end
|
13
|
-
|
14
|
-
def extract!
|
15
|
-
# Already extracted. Noop.
|
16
|
-
return if has_been_extracted?
|
17
|
-
|
18
|
-
system("tar -xzf #{tar_path} -C #{context.config.value('collector_download_dir')}")
|
19
|
-
end
|
20
|
-
|
21
|
-
def has_been_extracted?
|
22
|
-
File.exist?(binary_path)
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def tar_path
|
28
|
-
"#{context.config.value('collector_download_dir')}/otelcol.tar.gz"
|
29
|
-
end
|
30
|
-
|
31
|
-
def binary_path
|
32
|
-
"#{context.config.value('collector_download_dir')}/otelcol-contrib"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative './checksum'
|
4
|
-
require_relative './configuration'
|
5
|
-
require_relative './downloader'
|
6
|
-
require_relative './extractor'
|
7
|
-
|
8
|
-
module ScoutApm
|
9
|
-
module Logging
|
10
|
-
module Collector
|
11
|
-
# Manager class for the downloading, configuring, and starting of the collector.
|
12
|
-
class Manager
|
13
|
-
attr_reader :context
|
14
|
-
|
15
|
-
def initialize(context)
|
16
|
-
@context = context
|
17
|
-
|
18
|
-
@checksum = Checksum.new(@context)
|
19
|
-
@configuration = Configuration.new(@context)
|
20
|
-
@downloader = Downloader.new(@context)
|
21
|
-
@extractor = Extractor.new(@context)
|
22
|
-
end
|
23
|
-
|
24
|
-
def setup!
|
25
|
-
@configuration.setup!
|
26
|
-
@downloader.download!
|
27
|
-
@extractor.extract!
|
28
|
-
|
29
|
-
start_collector if verified_checksum_and_extracted?
|
30
|
-
end
|
31
|
-
|
32
|
-
def start_collector
|
33
|
-
context.logger.info('Starting otelcol-contrib')
|
34
|
-
collector_process = Process.spawn("#{extracted_collector_path}/otelcol-contrib --config #{config_file}")
|
35
|
-
File.write(context.config.value('collector_pid_file'), collector_process)
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def verified_checksum_and_extracted?
|
41
|
-
has_verfied_checksum = @checksum.verified_checksum?(should_log_failures: true)
|
42
|
-
has_extracted_content = @extractor.has_been_extracted?
|
43
|
-
|
44
|
-
has_verfied_checksum && has_extracted_content
|
45
|
-
end
|
46
|
-
|
47
|
-
def extracted_collector_path
|
48
|
-
context.config.value('collector_download_dir')
|
49
|
-
end
|
50
|
-
|
51
|
-
def config_file
|
52
|
-
context.config.value('collector_config_file')
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|