Package codes.grow.packages.betterstack
Class BetterStackEvents
java.lang.Object
codes.grow.packages.betterstack.BetterStackEvents
Maps
LogRecords to Better Stack events and encodes request bodies (JSON, NDJSON,
MessagePack).-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]encode(List<? extends Map<String, ?>> events, IngestEncoding encoding) Encodes events as one request body:JSONa JSON array,NDJSONone object per line,MSGPACKa MessagePack array withInstantvalues as timestamp extensions.static StringJSON text of one event (Instantvalues become RFC 3339 UTC strings).static StringFormats an instant as RFC 3339 UTC with up to nanosecond digits (2026-11-18T21:00:00.123456789Z).Maps a record to the Better Stack event shape (the JSON stored in therawcolumn):{dt, message, level, severity_number, span: {trace_id, span_id}, trace_flags, resource, attributes, observed_dt}.
-
Method Details
-
toEvent
Maps a record to the Better Stack event shape (the JSON stored in therawcolumn):{dt, message, level, severity_number, span: {trace_id, span_id}, trace_flags, resource, attributes, observed_dt}.span.trace_id/span.span_idare Better Stack's log to trace correlation fields.dtandobserved_dtareInstants until encoded; emptyresource/attributesare left out.- Parameters:
record- record- Returns:
- a mutable event map
-
formatTimestamp
Formats an instant as RFC 3339 UTC with up to nanosecond digits (2026-11-18T21:00:00.123456789Z).- Parameters:
t- instant- Returns:
- the text
-
eventJson
JSON text of one event (Instantvalues become RFC 3339 UTC strings).- Parameters:
event- event- Returns:
- compact JSON
-
encode
Encodes events as one request body:JSONa JSON array,NDJSONone object per line,MSGPACKa MessagePack array withInstantvalues as timestamp extensions.- Parameters:
events- eventsencoding- body encoding- Returns:
- the body
-