Package org.bluezoo.gumdrop.telemetry
Class LogRecord
java.lang.Object
org.bluezoo.gumdrop.telemetry.LogRecord
A log record that can be associated with a span.
In OpenTelemetry, logs contain traceId and spanId for correlation.
- Author:
- Chris Burdess
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intSeverity number values matching OTLP SeverityNumber enum.static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttribute(String key, String value) Adds a string attribute to this log record.voidaddAttribute(Attribute attribute) Adds an attribute to this log record.static LogRecordCreates an ERROR level log record.Returns an unmodifiable view of the log attributes.getBody()Returns the log body.intReturns the severity number.Returns the severity text.Returns the span ID, or null if not correlated.longReturns the timestamp in nanoseconds since Unix epoch.Returns the trace ID, or null if not correlated.booleanReturns true if this log is correlated with a span.static LogRecordCreates an INFO level log record.toString()static LogRecordCreates a WARN level log record.
-
Field Details
-
SEVERITY_TRACE
public static final int SEVERITY_TRACESeverity number values matching OTLP SeverityNumber enum.- See Also:
-
SEVERITY_DEBUG
public static final int SEVERITY_DEBUG- See Also:
-
SEVERITY_INFO
public static final int SEVERITY_INFO- See Also:
-
SEVERITY_WARN
public static final int SEVERITY_WARN- See Also:
-
SEVERITY_ERROR
public static final int SEVERITY_ERROR- See Also:
-
SEVERITY_FATAL
public static final int SEVERITY_FATAL- See Also:
-
-
Constructor Details
-
LogRecord
Creates a log record from the current span context.- Parameters:
span- the span to correlate withseverityNumber- the severity levelbody- the log message
-
LogRecord
Creates a log record without span correlation.- Parameters:
severityNumber- the severity levelbody- the log message
-
-
Method Details
-
getTimeUnixNano
public long getTimeUnixNano()Returns the timestamp in nanoseconds since Unix epoch. -
getSeverityNumber
public int getSeverityNumber()Returns the severity number. -
getSeverityText
Returns the severity text. -
getBody
Returns the log body. -
getTraceId
Returns the trace ID, or null if not correlated. -
getSpanId
Returns the span ID, or null if not correlated. -
hasSpanContext
public boolean hasSpanContext()Returns true if this log is correlated with a span. -
getAttributes
Returns an unmodifiable view of the log attributes. -
addAttribute
Adds an attribute to this log record.- Parameters:
attribute- the attribute
-
addAttribute
Adds a string attribute to this log record.- Parameters:
key- the attribute keyvalue- the attribute value
-
info
Creates an INFO level log record.- Parameters:
span- the span to correlate withbody- the log message- Returns:
- a new log record
-
warn
Creates a WARN level log record.- Parameters:
span- the span to correlate withbody- the log message- Returns:
- a new log record
-
error
Creates an ERROR level log record.- Parameters:
span- the span to correlate withbody- the log message- Returns:
- a new log record
-
toString
-