lib/elastic_apm/transport/serializers/error_serializer.rb in elastic-apm-2.0.1 vs lib/elastic_apm/transport/serializers/error_serializer.rb in elastic-apm-2.1.0
- old
+ new
@@ -3,21 +3,25 @@
module ElasticAPM
module Transport
module Serializers
# @api private
class ErrorSerializer < Serializer
+ def context_serializer
+ @context_serializer ||= ContextSerializer.new(config)
+ end
+
# rubocop:disable Metrics/MethodLength
def build(error)
base = {
id: error.id,
transaction_id: error.transaction_id,
trace_id: error.trace_id,
parent_id: error.parent_id,
culprit: error.culprit,
timestamp: error.timestamp,
- context: error.context.to_h
+ context: context_serializer.build(error.context)
}
if (exception = error.exception)
base[:exception] = build_exception exception
end
@@ -33,24 +37,24 @@
private
def build_exception(exception)
{
message: exception.message,
- type: exception.type,
- module: exception.module,
- code: exception.code,
+ type: keyword_field(exception.type),
+ module: keyword_field(exception.module),
+ code: keyword_field(exception.code),
attributes: exception.attributes,
stacktrace: exception.stacktrace.to_a,
handled: exception.handled
}
end
def build_log(log)
{
message: log.message,
- level: log.level,
- logger_name: log.logger_name,
- param_message: log.param_message,
+ level: keyword_field(log.level),
+ logger_name: keyword_field(log.logger_name),
+ param_message: keyword_field(log.param_message),
stacktrace: log.stacktrace.to_a
}
end
end
end