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 +4 -4
- data/lib/civo/logger/middleware.rb +14 -10
- data/lib/civo/logger/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3430bd91180661a75332131dcd938e8767ed6248
|
4
|
+
data.tar.gz: a3a01fee4b1585d18945006930632fd3ecbe8650
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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: {
|
118
|
-
timestamp: (Time.now.
|
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
|
-
|
123
|
-
|
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.
|
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
|
-
|
233
|
-
|
236
|
+
rescue InfluxDB::Error => e
|
237
|
+
puts "ERROR! InfluxDB error #{e.message}"
|
234
238
|
ensure
|
235
239
|
@recording = false
|
236
240
|
end
|
data/lib/civo/logger/version.rb
CHANGED