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
def log_create_failed(error)
logger.error({
exception: error.class.name,
exception: {
class: error.class.name,
message: error.message
},
status_code: error.error_code,
namespace: name,
class_name: self.class.name,
event: :failed_to_create_namespace,
message: error.message
event: :failed_to_create_namespace
})
end
......
......@@ -92,12 +92,14 @@ describe Gitlab::Kubernetes::Namespace do
it 'logs the error' do
expect(subject.send(:logger)).to receive(:error).with(
hash_including(
exception: 'Kubeclient::HttpError',
exception: {
class: 'Kubeclient::HttpError',
message: 'system failure'
},
status_code: 500,
namespace: 'a_namespace',
class_name: 'Gitlab::Kubernetes::Namespace',
event: :failed_to_create_namespace,
message: 'system failure'
event: :failed_to_create_namespace
)
)
......
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