Class LogSerializer
java.lang.Object
org.bluezoo.gumdrop.telemetry.protobuf.LogSerializer
Serializes log records to OTLP protobuf format.
The serializer can write directly to a WritableByteChannel for
streaming output, or to a ByteBuffer for buffered output.
- Author:
- Chris Burdess
-
Constructor Summary
ConstructorsConstructorDescriptionLogSerializer(String serviceName) Creates a log serializer with the given service name.LogSerializer(String serviceName, String serviceVersion, String serviceNamespace, Map<String, String> resourceAttributes) Creates a log serializer with service metadata. -
Method Summary
Modifier and TypeMethodDescriptionSerializes log records to OTLP LogsData format, returning a ByteBuffer.voidserialize(List<LogRecord> records, WritableByteChannel channel) Serializes log records to OTLP LogsData format, writing to a channel.Serializes a single log record to OTLP LogsData format, returning a ByteBuffer.voidserialize(LogRecord record, WritableByteChannel channel) Serializes a single log record to OTLP LogsData format, writing to a channel.
-
Constructor Details
-
LogSerializer
Creates a log serializer with the given service name.- Parameters:
serviceName- the service name for the Resource
-
LogSerializer
public LogSerializer(String serviceName, String serviceVersion, String serviceNamespace, Map<String, String> resourceAttributes) Creates a log serializer with service metadata.- Parameters:
serviceName- the service nameserviceVersion- the service versionserviceNamespace- the service namespaceresourceAttributes- additional resource attributes
-
-
Method Details
-
serialize
Serializes log records to OTLP LogsData format, writing to a channel.This is the primary serialization method. Data is streamed to the channel as it is serialized.
- Parameters:
records- the log records to serializechannel- the channel to write to- Throws:
IOException- if an I/O error occurs
-
serialize
Serializes log records to OTLP LogsData format, returning a ByteBuffer.Convenience method for callers who need buffered output.
- Parameters:
records- the log records to serialize- Returns:
- a ByteBuffer containing the serialized logs (ready for reading)
- Throws:
IOException- if serialization fails
-
serialize
Serializes a single log record to OTLP LogsData format, writing to a channel.- Parameters:
record- the log record to serializechannel- the channel to write to- Throws:
IOException- if an I/O error occurs
-
serialize
Serializes a single log record to OTLP LogsData format, returning a ByteBuffer.- Parameters:
record- the log record to serialize- Returns:
- a ByteBuffer containing the serialized log (ready for reading)
- Throws:
IOException- if serialization fails
-