Class LogRecordJson
java.lang.Object
codes.grow.packages.betterstack.logging.LogRecordJson
Converts
LogRecord to and from the normalized JSON wire form (
spec/schemas/log-record.schema.json).
Fields: timestamp and the optional observedTimestamp (RFC 3339 UTC, nanosecond
precision), severity (OTel number), severityText, body,
attributes, resource and the optional traceId, spanId,
traceFlags.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intReturns the UTF-8 size of the record's JSON form (the unit ofmaxBatchBytes).static LogRecordParses one record from JSON text.static LogRecordfromJsonNode(com.fasterxml.jackson.databind.JsonNode node) Parses one record from a Jackson tree.static ObjecttoAttrValue(com.fasterxml.jackson.databind.JsonNode node) Converts a JSON tree into attribute values (AttrValues).static StringSerialises a record to compact JSON.Returns the wire form as an ordered map of plain JSON values.
-
Method Details
-
toMap
Returns the wire form as an ordered map of plain JSON values.- Parameters:
record- the record- Returns:
- an ordered map
-
toJson
Serialises a record to compact JSON.- Parameters:
record- the record- Returns:
- JSON text
-
byteSize
Returns the UTF-8 size of the record's JSON form (the unit ofmaxBatchBytes).- Parameters:
record- the record- Returns:
- size in bytes
-
fromJson
Parses one record from JSON text.- Parameters:
json- JSON object text- Returns:
- the record
- Throws:
ValidationException- when the JSON is not a valid record
-
fromJsonNode
Parses one record from a Jackson tree. Unknown fields are ignored; a non-stringbodyis JSON-encoded;severitymay be a number (also read from the OTLP nameseverityNumber) and is derived fromseverityTextwhen missing.- Parameters:
node- JSON object- Returns:
- the record
- Throws:
ValidationException- when the node is not a valid record
-
toAttrValue
Converts a JSON tree into attribute values (AttrValues).- Parameters:
node- JSON value- Returns:
- String, Long, Double, Boolean, List or Map
-