rails_loki_exporter 1.0.5 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 733316b790e527c137a95c3a5796b22d1367f53536d9afdaaca0ed8d5afe851d
4
- data.tar.gz: b9ce3c6abaf28609f52d2783028a43635c45f3e87fdcadcebd892d08603cebe8
3
+ metadata.gz: 93cc7ab2fe4c6fadb43616ca5f9416b0f82bc1f8434bfa8c389329c016d4528a
4
+ data.tar.gz: b70e7a5189a35825e996c582658d5b062f2849891dd2262181eacc025e5e52dc
5
5
  SHA512:
6
- metadata.gz: 3ad48d68cda1540c115a7bcfbea1f739ec38b4b373633189d3e1c00daeff525b0e645ca6e37360cee32f0ba86c31baeb0c2f88042b9164fbd088c95fb635d081
7
- data.tar.gz: d8c4111d0e92fa6b58141cc5eee83f36827d889d4e72304a949c1b00065ad2810ab9c457d8a9c5099c4cb7393447cc0df9f06b324368357aa16b47e76bc36fd1
6
+ metadata.gz: 06fbb48beee20de45796edfbd1c58299649b919d9ec5551d4701c7dbae04a4033e07c5dfed3f83719f388d7e2b54285cd6eccd8e0afc5396ab79c2110b0f0b78
7
+ data.tar.gz: 425291ee06d0bff6430703a46894d2436f3116edb7b6d0def9e121b8685d7834e0e344f319c846833fdc7aa7645e4349d6351656b4df601bf967a78492fc531e
@@ -44,10 +44,10 @@ module RailsLokiExporter
44
44
  private
45
45
 
46
46
  def format_message(severity, datetime, progname, msg)
47
- puts "severity: #{severity}"
48
- puts "datetime: #{datetime}"
49
- puts "progname: #{progname}"
50
- puts "msg: #{msg}"
47
+ # puts "severity: #{severity}"
48
+ # puts "datetime: #{datetime}"
49
+ # puts "progname: #{progname}"
50
+ # puts "msg: #{msg}"
51
51
  "#{severity} #{progname}: #{msg}\n"
52
52
  end
53
53
 
@@ -32,27 +32,30 @@ module RailsLokiExporter
32
32
  end
33
33
 
34
34
  def send_log(log_message)
35
- @log_buffer << log_message
36
- if @log_buffer.size >= @max_buffer_size || can_send_log?
37
- send_buffered_logs
38
- @last_interaction_time = Time.now
39
- else
40
- # @logger.info('Log buffered. Waiting for more logs or interaction interval.')
41
- end
35
+ current_timestamp = Time.now.to_f * 1_000_000_000
36
+ @log_buffer << [current_timestamp.to_i.to_s, log_message.chomp]
37
+ if @log_buffer.size >= @max_buffer_size || can_send_log?
38
+ send_buffered_logs
39
+ @last_interaction_time = Time.now
40
+ else
41
+ # @logger.info('Log buffered. Waiting for more logs or interaction interval.')
42
+ end
42
43
  end
43
44
 
44
45
  private
45
46
  def send_buffered_logs
46
47
  return if @log_buffer.empty?
47
48
 
48
- curr_datetime = Time.now.to_i * 1_000_000_000
49
49
  msg = "On server #{@host_name} detected error"
50
50
  payload = {
51
51
  'streams' => [
52
- { 'stream' => {
53
- 'job' => @job_name,
54
- 'host' => @host_name },
55
- 'values' => @log_buffer.map { |log| [curr_datetime.to_s, log] }}
52
+ {
53
+ 'stream' => {
54
+ 'job' => @job_name,
55
+ 'host' => @host_name,
56
+ },
57
+ 'values' => @log_buffer,
58
+ }
56
59
  ]
57
60
  }
58
61
 
@@ -1,3 +1,3 @@
1
1
  module RailsLokiExporter
2
- VERSION = '1.0.5'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -17,5 +17,6 @@ Gem::Specification.new do |spec|
17
17
  spec.extra_rdoc_files = ['README.md']
18
18
  spec.require_paths = ['lib']
19
19
  spec.add_dependency 'zeitwerk', '~> 2.4'
20
- spec.add_dependency 'rspec'
20
+ spec.add_development_dependency 'rspec'
21
+ spec.add_development_dependency 'rake'
21
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_loki_exporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - planning.how
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-04-20 00:00:00.000000000 Z
13
+ date: 2024-10-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: zeitwerk
@@ -33,7 +33,21 @@ dependencies:
33
33
  - - ">="
34
34
  - !ruby/object:Gem::Version
35
35
  version: '0'
36
- type: :runtime
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rake
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :development
37
51
  prerelease: false
38
52
  version_requirements: !ruby/object:Gem::Requirement
39
53
  requirements: