Class LogSerializer

java.lang.Object
org.bluezoo.gumdrop.telemetry.protobuf.LogSerializer

public class LogSerializer extends Object
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 Details

    • LogSerializer

      public LogSerializer(String serviceName)
      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 name
      serviceVersion - the service version
      serviceNamespace - the service namespace
      resourceAttributes - additional resource attributes
  • Method Details

    • serialize

      public void serialize(List<LogRecord> records, WritableByteChannel channel) throws IOException
      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 serialize
      channel - the channel to write to
      Throws:
      IOException - if an I/O error occurs
    • serialize

      public ByteBuffer serialize(List<LogRecord> records) throws IOException
      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

      public void serialize(LogRecord record, WritableByteChannel channel) throws IOException
      Serializes a single log record to OTLP LogsData format, writing to a channel.
      Parameters:
      record - the log record to serialize
      channel - the channel to write to
      Throws:
      IOException - if an I/O error occurs
    • serialize

      public ByteBuffer serialize(LogRecord record) throws IOException
      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