civo-logger 0.3.5 → 0.3.6

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
  SHA1:
3
- metadata.gz: 1a993ade5fab4fe045bf09545478b9cdc23bad7a
4
- data.tar.gz: e1e1f78e26f30630ebea95fe9a33ee8dff17896c
3
+ metadata.gz: 3430bd91180661a75332131dcd938e8767ed6248
4
+ data.tar.gz: a3a01fee4b1585d18945006930632fd3ecbe8650
5
5
  SHA512:
6
- metadata.gz: ed8c32275a085192fcdeb002f5f96b8662cf7b833c0fe3537ad073d46d7c57aa3f6bc1b6d2eab1db965b68cda3002496cc59d9be1cd2a2981d383b87afa147e0
7
- data.tar.gz: 591e06334c320bc85779a46276d885f966a4a8bab317d5989ddaba61c5ecc9a58c1114bd80df0d4760b64b7cf90cdc48ebd2cd538a7e041c38eb280b00d3632b
6
+ metadata.gz: 07a1df43d3892865a43a5988cb7d353fab43bbb07934737ca0f2bc56058f057593b6cc88b1ccd29d82146ad1ec0643fef745a698b7c272058f4afb679cd262d1
7
+ data.tar.gz: 11d5f3f72a691fa02cb6899fd43c111af679ecd2298cb290ad89a0e48ea1023246bd80b5e97eccfbfed450a7a4b66c7315fddaa650221d4e07abbaa02ffeee6f
@@ -19,8 +19,10 @@ module Civo
19
19
  @taggers = taggers || []
20
20
  Rails.logger = ActionController::Base.logger = ActiveRecord::Base.logger = self
21
21
  $stdout.sync = true
22
- options = {host: ENV["INFLUX_LOGGER_HOSTNAME"], port: ENV["INFLUX_LOGGER_PORT"], password: ENV["INFLUX_LOGGER_PASSWORD"], username: ENV["INFLUX_LOGGER_USERNAME"], timeout: 1, time_precision: "ms"}
22
+ options = {host: ENV["INFLUX_LOGGER_HOSTNAME"], port: ENV["INFLUX_LOGGER_PORT"], password: ENV["INFLUX_LOGGER_PASSWORD"], username: ENV["INFLUX_LOGGER_USERNAME"], open_timeout: 1, read_timeout: 1, timeout: 1, time_precision: "ms", retry: false}
23
23
  @influxdb = InfluxDB::Client.new ENV["INFLUX_LOGGER_DATABASE"], options
24
+ rescue InfluxDB::Error
25
+ @influxdb = nil
24
26
  end
25
27
 
26
28
  def call(env)
@@ -100,7 +102,7 @@ module Civo
100
102
  def start_worker(name)
101
103
  @name = name
102
104
  @lines = []
103
- @start = Time.now.to_f
105
+ @start = Time.now.to_f * 1000
104
106
  @recording = true
105
107
  end
106
108
 
@@ -112,15 +114,17 @@ module Civo
112
114
  return
113
115
  end
114
116
 
117
+ @end = Time.now.to_f * 1000
118
+
115
119
  data = {
116
- values: { log: @lines.join("\n") },
117
- tags: { name: @name, app: app_name },
118
- timestamp: (Time.now.to_r * 1000).to_i
120
+ values: { log: @lines.join("\n"), log_size: @lines.join("\n").length, ms_taken: (@end-@start).to_i },
121
+ tags: { job_name: @name, app: app_name, run_id: SecureRandom.uuid },
122
+ timestamp: (Time.now.to_f * 1000.0).to_i
119
123
  }
120
124
 
121
125
  @influxdb.write_point("workers", data, INFLUXDB_PRECISION)# , INFLUXDB_RETENTION)
122
- # rescue Redis::TimeoutError, Redis::CannotConnectError => e
123
- # puts "ERROR! Redis error #{e.message}"
126
+ rescue InfluxDB::Error => e
127
+ puts "ERROR! InfluxDB error #{e.message}"
124
128
  ensure
125
129
  @recording = false
126
130
  end
@@ -214,7 +218,7 @@ module Civo
214
218
  data = {
215
219
  values: { log: @log[0, 65535], output: @output, output_length: @output.length, status: @status, ms_taken: @time_taken.to_i},
216
220
  tags: { url: request.fullpath, method: request.request_method, app: app_name },
217
- timestamp: (Time.now.to_r * 1000).to_i
221
+ timestamp: (Time.now.to_f * 1000.0).to_i
218
222
  }
219
223
  data[:values][:email] = request.headers["X-CivoCom-User-Email"] if request.headers["X-CivoCom-User-Email"].present?
220
224
  data[:values][:civocom_request_path] = request.headers["X-CivoCom-Request-Path"] if request.headers["X-CivoCom-Request-Path"].present?
@@ -229,8 +233,8 @@ module Civo
229
233
  end
230
234
  end
231
235
 
232
- # rescue Redis::TimeoutError, Redis::CannotConnectError => e
233
- # puts "ERROR! Redis error #{e.message}"
236
+ rescue InfluxDB::Error => e
237
+ puts "ERROR! InfluxDB error #{e.message}"
234
238
  ensure
235
239
  @recording = false
236
240
  end
@@ -1,5 +1,5 @@
1
1
  module Civo
2
2
  module Logger
3
- VERSION = "0.3.5"
3
+ VERSION = "0.3.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: civo-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Jeffries