Class LogRecord.Builder
java.lang.Object
codes.grow.packages.betterstack.logging.LogRecord.Builder
- Enclosing class:
LogRecord
Builder for
LogRecord.-
Method Summary
Modifier and TypeMethodDescriptionAdds one attribute.attributes(Map<String, ?> attributes) Replaces all attributes.Sets the message.build()Builds the record.observedTimestamp(Instant observedTimestamp) Sets the observed time.Replaces all resource attributes.Sets the severity; the severity text follows unless set explicitly.severityText(String severityText) Sets a vendor severity text (defaults to the severity name).Sets the span id (16 hex).Sets the event time.traceFlags(Integer traceFlags) Sets the W3C trace flags (0–255).Sets the trace id (32 hex; upper case is accepted, 16 hex is left-padded).
-
Method Details
-
timestamp
Sets the event time.- Parameters:
timestamp- event time- Returns:
- this builder
-
observedTimestamp
Sets the observed time.- Parameters:
observedTimestamp- observed time (may benull)- Returns:
- this builder
-
severity
Sets the severity; the severity text follows unless set explicitly.- Parameters:
severity- severity- Returns:
- this builder
-
severityText
Sets a vendor severity text (defaults to the severity name).- Parameters:
severityText- text (may benull)- Returns:
- this builder
-
body
Sets the message.- Parameters:
body- message (nullbecomes empty)- Returns:
- this builder
-
attributes
Replaces all attributes.- Parameters:
attributes- attributes (may benull)- Returns:
- this builder
-
attribute
Adds one attribute.- Parameters:
key- namevalue- attribute value- Returns:
- this builder
-
resource
Replaces all resource attributes.- Parameters:
resource- resource attributes (may benull)- Returns:
- this builder
-
traceId
Sets the trace id (32 hex; upper case is accepted, 16 hex is left-padded).- Parameters:
traceId- trace id ornull- Returns:
- this builder
-
spanId
Sets the span id (16 hex).- Parameters:
spanId- span id ornull- Returns:
- this builder
-
traceFlags
Sets the W3C trace flags (0–255).- Parameters:
traceFlags- flags ornull- Returns:
- this builder
-
build
Builds the record.- Returns:
- the record
- Throws:
ValidationException- when a trace id, span id or trace flags value is invalid
-