Commit b2efd2c1 authored by Craig Furman's avatar Craig Furman

Fix a log schema inconsistency

In most of the application, structured logs that emit an "exception" key
for errors are sent with a Hash in this key. In this class, a string was
used. This frustrates Elasticsearch, which is commonly used to store
structured logs, causing it to have to drop logs from one instance or
the other due to the type mismatch.
parent c626c6a5
...@@ -35,12 +35,14 @@ module Gitlab ...@@ -35,12 +35,14 @@ module Gitlab
def log_create_failed(error) def log_create_failed(error)
logger.error({ logger.error({
exception: error.class.name, exception: {
class: error.class.name,
message: error.message
},
status_code: error.error_code, status_code: error.error_code,
namespace: name, namespace: name,
class_name: self.class.name, class_name: self.class.name,
event: :failed_to_create_namespace, event: :failed_to_create_namespace
message: error.message
}) })
end end
......
...@@ -92,12 +92,14 @@ describe Gitlab::Kubernetes::Namespace do ...@@ -92,12 +92,14 @@ describe Gitlab::Kubernetes::Namespace do
it 'logs the error' do it 'logs the error' do
expect(subject.send(:logger)).to receive(:error).with( expect(subject.send(:logger)).to receive(:error).with(
hash_including( hash_including(
exception: 'Kubeclient::HttpError', exception: {
class: 'Kubeclient::HttpError',
message: 'system failure'
},
status_code: 500, status_code: 500,
namespace: 'a_namespace', namespace: 'a_namespace',
class_name: 'Gitlab::Kubernetes::Namespace', class_name: 'Gitlab::Kubernetes::Namespace',
event: :failed_to_create_namespace, event: :failed_to_create_namespace
message: 'system failure'
) )
) )
......
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