Closed
Description
Original Issue: madzak/python-json-logger#171
I tried the following configuration to get field names matching the OpenTelemetry semantic conventions:
json: (): pythonjsonlogger.jsonlogger.JsonFormatter rename_fields: otelTraceID: trace_id otelSpanID: span_id otelServiceName: service.name levelname: severity message: body threadName: thread.name exc_type: exception.type exc_val: exception.message traceback: exception.stacktrace pathname: code.filepath lineno: code.lineno funcName: code.function format: '%(levelname)s %(name)s %(threadName)s %(message)s %(pathname)s %(lineno)s %(funcName)s'It would not work because some of these fields were not present in every log record, but the field rename function requires cannot handle missing fields. In particular, renaming the exception related fields is impossible.
Addendum: explicitly adding these fields to
format
removes the error, but then they have null values where a log record does not contain an exception. Would it be possible to get fields renamed without making them mandatory?
madzak/python-json-logger#189 appears to be a duplicate