scout_apm_logging 0.0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/test.yml +37 -0
  3. data/.gitignore +13 -0
  4. data/.rubocop.yml +65 -0
  5. data/Dockerfile +18 -0
  6. data/Gemfile +5 -0
  7. data/README.md +58 -0
  8. data/Rakefile +35 -0
  9. data/bin/scout_apm_logging_monitor +5 -0
  10. data/gems/rails.gemfile +3 -0
  11. data/lib/scout_apm/logging/config.rb +265 -0
  12. data/lib/scout_apm/logging/context.rb +58 -0
  13. data/lib/scout_apm/logging/logger.rb +26 -0
  14. data/lib/scout_apm/logging/loggers/capture.rb +46 -0
  15. data/lib/scout_apm/logging/loggers/formatter.rb +86 -0
  16. data/lib/scout_apm/logging/loggers/logger.rb +82 -0
  17. data/lib/scout_apm/logging/loggers/proxy.rb +39 -0
  18. data/lib/scout_apm/logging/loggers/swap.rb +82 -0
  19. data/lib/scout_apm/logging/monitor/collector/checksum.rb +51 -0
  20. data/lib/scout_apm/logging/monitor/collector/configuration.rb +148 -0
  21. data/lib/scout_apm/logging/monitor/collector/downloader.rb +78 -0
  22. data/lib/scout_apm/logging/monitor/collector/extractor.rb +37 -0
  23. data/lib/scout_apm/logging/monitor/collector/manager.rb +57 -0
  24. data/lib/scout_apm/logging/monitor/monitor.rb +214 -0
  25. data/lib/scout_apm/logging/monitor_manager/manager.rb +150 -0
  26. data/lib/scout_apm/logging/state.rb +70 -0
  27. data/lib/scout_apm/logging/utils.rb +86 -0
  28. data/lib/scout_apm/logging/version.rb +7 -0
  29. data/lib/scout_apm_logging.rb +35 -0
  30. data/scout_apm_logging.gemspec +27 -0
  31. data/spec/data/config_test_1.yml +27 -0
  32. data/spec/data/empty_logs_config.yml +0 -0
  33. data/spec/data/logs_config.yml +3 -0
  34. data/spec/data/mock_config.yml +29 -0
  35. data/spec/data/state_file.json +3 -0
  36. data/spec/integration/loggers/capture_spec.rb +78 -0
  37. data/spec/integration/monitor/collector/downloader/will_verify_checksum.rb +47 -0
  38. data/spec/integration/monitor/collector_healthcheck_spec.rb +27 -0
  39. data/spec/integration/monitor/continuous_state_collector_spec.rb +29 -0
  40. data/spec/integration/monitor/previous_collector_setup_spec.rb +42 -0
  41. data/spec/integration/monitor_manager/disable_agent_spec.rb +28 -0
  42. data/spec/integration/monitor_manager/monitor_pid_file_spec.rb +36 -0
  43. data/spec/integration/monitor_manager/single_monitor_spec.rb +53 -0
  44. data/spec/integration/rails/lifecycle_spec.rb +29 -0
  45. data/spec/spec_helper.rb +65 -0
  46. data/spec/unit/config_spec.rb +25 -0
  47. data/spec/unit/loggers/capture_spec.rb +64 -0
  48. data/spec/unit/monitor/collector/configuration_spec.rb +64 -0
  49. data/spec/unit/state_spec.rb +20 -0
  50. data/tooling/checksums.rb +106 -0
  51. metadata +167 -0
@@ -0,0 +1,106 @@
1
+ ###
2
+ # Calculates the checksums for the otelcol-contrib files
3
+ # Usage: ruby tooling/checksums.rb <version>
4
+ ##
5
+ # frozen_string_literal: true
6
+
7
+ require 'digest'
8
+ require 'fileutils'
9
+ require 'net/http'
10
+ require 'pp'
11
+
12
+ DOUBLES = [
13
+ 'darwin_amd64',
14
+ 'darwin_arm64',
15
+ 'linux_amd64',
16
+ 'linux_arm64'
17
+ ]
18
+
19
+ version = ARGV[0]
20
+
21
+ current_directory = Dir.pwd
22
+ unless current_directory.include?("/tooling")
23
+ tooling_directory = File.join(current_directory, "/tooling")
24
+ FileUtils.cd(tooling_directory)
25
+ end
26
+
27
+ def download_source_checksums(url, destination)
28
+ uri = URI(url)
29
+
30
+ Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
31
+ request = Net::HTTP::Get.new(uri)
32
+ http.request(request) do |response|
33
+ return download_source_checksums(response['location'], destination) if response.code == '302'
34
+
35
+ File.open(destination, 'wb') do |file|
36
+ response.read_body do |chunk|
37
+ file.write(chunk)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ def validate_and_return_checksums(version)
45
+ checksum_file_url = "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v#{version}/opentelemetry-collector-releases_otelcol-contrib_checksums.txt"
46
+ destination = "./opentelemetry-collector-releases_otelcol-contrib_checksums.txt"
47
+
48
+ download_source_checksums(checksum_file_url, destination)
49
+
50
+ contents = File.read(destination)
51
+ lines = contents.split("\n")
52
+ pairs = lines.each_with_object({}) do |item, hash|
53
+ value, key = item.split
54
+ hash[key] = value
55
+ end
56
+
57
+
58
+ relavent_pairs = {}
59
+ DOUBLES.each do |double|
60
+ file_name = "otelcol-contrib_#{version}_#{double}.tar.gz"
61
+ file_location = "./#{file_name}"
62
+
63
+ local_checksum = Digest::SHA256.file(file_location).hexdigest
64
+ source_checksum = pairs[file_name]
65
+
66
+ if source_checksum != local_checksum
67
+ puts "#{double} contains different checksums: Local checksum #{local_checksum} -- Source checksum #{source_checksum}"
68
+ raise "Different checksums for #{double}"
69
+ end
70
+
71
+ relavent_pairs[double] = local_checksum
72
+ end
73
+
74
+ relavent_pairs
75
+ end
76
+
77
+ def download_collector(url, destination)
78
+ uri = URI(url)
79
+
80
+ Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
81
+ request = Net::HTTP::Get.new(uri)
82
+ http.request(request) do |response|
83
+ return download_collector(response['location'], destination) if response.code == '302'
84
+
85
+ File.open(destination, 'wb') do |file|
86
+ response.read_body do |chunk|
87
+ file.write(chunk)
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
93
+
94
+ DOUBLES.each do |double|
95
+ host_os, architecture = double.split('_')
96
+
97
+ url = "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v#{version}/otelcol-contrib_#{version}_#{host_os}_#{architecture}.tar.gz"
98
+
99
+ destination = "./otelcol-contrib_#{version}_#{host_os}_#{architecture}.tar.gz"
100
+
101
+ download_collector(url, destination)
102
+ end
103
+
104
+ checksums = validate_and_return_checksums(version)
105
+
106
+ pp checksums
metadata ADDED
@@ -0,0 +1,167 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scout_apm_logging
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Scout APM
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-07-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: scout_apm
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: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 1.50.2
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.50.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-ast
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.30.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.30.0
69
+ description: Sets up log monitoring for Scout APM Ruby clients.
70
+ email:
71
+ - support@scoutapp.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".github/workflows/test.yml"
77
+ - ".gitignore"
78
+ - ".rubocop.yml"
79
+ - Dockerfile
80
+ - Gemfile
81
+ - README.md
82
+ - Rakefile
83
+ - bin/scout_apm_logging_monitor
84
+ - gems/rails.gemfile
85
+ - lib/scout_apm/logging/config.rb
86
+ - lib/scout_apm/logging/context.rb
87
+ - lib/scout_apm/logging/logger.rb
88
+ - lib/scout_apm/logging/loggers/capture.rb
89
+ - lib/scout_apm/logging/loggers/formatter.rb
90
+ - lib/scout_apm/logging/loggers/logger.rb
91
+ - lib/scout_apm/logging/loggers/proxy.rb
92
+ - lib/scout_apm/logging/loggers/swap.rb
93
+ - lib/scout_apm/logging/monitor/collector/checksum.rb
94
+ - lib/scout_apm/logging/monitor/collector/configuration.rb
95
+ - lib/scout_apm/logging/monitor/collector/downloader.rb
96
+ - lib/scout_apm/logging/monitor/collector/extractor.rb
97
+ - lib/scout_apm/logging/monitor/collector/manager.rb
98
+ - lib/scout_apm/logging/monitor/monitor.rb
99
+ - lib/scout_apm/logging/monitor_manager/manager.rb
100
+ - lib/scout_apm/logging/state.rb
101
+ - lib/scout_apm/logging/utils.rb
102
+ - lib/scout_apm/logging/version.rb
103
+ - lib/scout_apm_logging.rb
104
+ - scout_apm_logging.gemspec
105
+ - spec/data/config_test_1.yml
106
+ - spec/data/empty_logs_config.yml
107
+ - spec/data/logs_config.yml
108
+ - spec/data/mock_config.yml
109
+ - spec/data/state_file.json
110
+ - spec/integration/loggers/capture_spec.rb
111
+ - spec/integration/monitor/collector/downloader/will_verify_checksum.rb
112
+ - spec/integration/monitor/collector_healthcheck_spec.rb
113
+ - spec/integration/monitor/continuous_state_collector_spec.rb
114
+ - spec/integration/monitor/previous_collector_setup_spec.rb
115
+ - spec/integration/monitor_manager/disable_agent_spec.rb
116
+ - spec/integration/monitor_manager/monitor_pid_file_spec.rb
117
+ - spec/integration/monitor_manager/single_monitor_spec.rb
118
+ - spec/integration/rails/lifecycle_spec.rb
119
+ - spec/spec_helper.rb
120
+ - spec/unit/config_spec.rb
121
+ - spec/unit/loggers/capture_spec.rb
122
+ - spec/unit/monitor/collector/configuration_spec.rb
123
+ - spec/unit/state_spec.rb
124
+ - tooling/checksums.rb
125
+ homepage: https://github.com/scoutapp/scout_apm_ruby_logging
126
+ licenses:
127
+ - MIT
128
+ metadata: {}
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '2.6'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubygems_version: 3.0.8
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: Ruby Logging Support
148
+ test_files:
149
+ - spec/data/config_test_1.yml
150
+ - spec/data/empty_logs_config.yml
151
+ - spec/data/logs_config.yml
152
+ - spec/data/mock_config.yml
153
+ - spec/data/state_file.json
154
+ - spec/integration/loggers/capture_spec.rb
155
+ - spec/integration/monitor/collector/downloader/will_verify_checksum.rb
156
+ - spec/integration/monitor/collector_healthcheck_spec.rb
157
+ - spec/integration/monitor/continuous_state_collector_spec.rb
158
+ - spec/integration/monitor/previous_collector_setup_spec.rb
159
+ - spec/integration/monitor_manager/disable_agent_spec.rb
160
+ - spec/integration/monitor_manager/monitor_pid_file_spec.rb
161
+ - spec/integration/monitor_manager/single_monitor_spec.rb
162
+ - spec/integration/rails/lifecycle_spec.rb
163
+ - spec/spec_helper.rb
164
+ - spec/unit/config_spec.rb
165
+ - spec/unit/loggers/capture_spec.rb
166
+ - spec/unit/monitor/collector/configuration_spec.rb
167
+ - spec/unit/state_spec.rb