Commit bf7edb28 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'ag-json-logging' into 'master'

Use ISO time format with 3 fraction digits

See merge request gitlab-org/gitlab!21835
parents c4dd9eb4 d2640e4c
...@@ -117,7 +117,7 @@ module Gitlab ...@@ -117,7 +117,7 @@ module Gitlab
def format_time(timestamp) def format_time(timestamp)
return timestamp if timestamp.is_a?(String) return timestamp if timestamp.is_a?(String)
Time.at(timestamp).utc.iso8601(6) Time.at(timestamp).utc.iso8601(3)
end end
def limited_job_args(args) def limited_job_args(args)
......
...@@ -4,7 +4,7 @@ require 'fast_spec_helper' ...@@ -4,7 +4,7 @@ require 'fast_spec_helper'
describe Gitlab::SidekiqLogging::StructuredLogger do describe Gitlab::SidekiqLogging::StructuredLogger do
describe '#call' do describe '#call' do
let(:timestamp) { Time.iso8601('2018-01-01T12:00:00Z') } let(:timestamp) { Time.iso8601('2018-01-01T12:00:00.000Z') }
let(:created_at) { timestamp - 1.second } let(:created_at) { timestamp - 1.second }
let(:scheduling_latency_s) { 1.0 } let(:scheduling_latency_s) { 1.0 }
...@@ -30,8 +30,8 @@ describe Gitlab::SidekiqLogging::StructuredLogger do ...@@ -30,8 +30,8 @@ describe Gitlab::SidekiqLogging::StructuredLogger do
'message' => 'TestWorker JID-da883554ee4fe414012f5f42: start', 'message' => 'TestWorker JID-da883554ee4fe414012f5f42: start',
'job_status' => 'start', 'job_status' => 'start',
'pid' => Process.pid, 'pid' => Process.pid,
'created_at' => created_at.iso8601(6), 'created_at' => created_at.iso8601(3),
'enqueued_at' => created_at.iso8601(6), 'enqueued_at' => created_at.iso8601(3),
'scheduling_latency_s' => scheduling_latency_s 'scheduling_latency_s' => scheduling_latency_s
) )
end end
...@@ -40,7 +40,7 @@ describe Gitlab::SidekiqLogging::StructuredLogger do ...@@ -40,7 +40,7 @@ describe Gitlab::SidekiqLogging::StructuredLogger do
'message' => 'TestWorker JID-da883554ee4fe414012f5f42: done: 0.0 sec', 'message' => 'TestWorker JID-da883554ee4fe414012f5f42: done: 0.0 sec',
'job_status' => 'done', 'job_status' => 'done',
'duration' => 0.0, 'duration' => 0.0,
"completed_at" => timestamp.iso8601(6), "completed_at" => timestamp.iso8601(3),
"cpu_s" => 1.111112 "cpu_s" => 1.111112
) )
end end
...@@ -145,7 +145,7 @@ describe Gitlab::SidekiqLogging::StructuredLogger do ...@@ -145,7 +145,7 @@ describe Gitlab::SidekiqLogging::StructuredLogger do
end end
context 'with latency' do context 'with latency' do
let(:created_at) { Time.iso8601('2018-01-01T10:00:00Z') } let(:created_at) { Time.iso8601('2018-01-01T10:00:00.000Z') }
let(:scheduling_latency_s) { 7200.0 } let(:scheduling_latency_s) { 7200.0 }
it 'logs with scheduling latency' do it 'logs with scheduling latency' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment