aeron-driver/src/main/java/io/aeron/driver/reports/LossReport.java
public ReportEntry createEntry(
        final long initialBytesLost,
        final long timestampMs,
        final int sessionId,
        final int streamId,
        final String channel,
        final String source)
    {
        ReportEntry reportEntry = null;

        final int requiredCapacity = CHANNEL_OFFSET + (SIZE_OF_INT * 2) + channel.length() + source.length();

        if (requiredCapacity <= (buffer.capacity() - nextRecordOffset))
        {
            final int offset = nextRecordOffset;

            buffer.putLong(offset + TOTAL_BYTES_LOST_OFFSET, initialBytesLost);
            buffer.putLong(offset + FIRST_OBSERVATION_OFFSET, timestampMs);
            buffer.putLong(offset + LAST_OBSERVATION_OFFSET, timestampMs);
            buffer.putInt(offset + SESSION_ID_OFFSET, sessionId);
            buffer.putInt(offset + STREAM_ID_OFFSET, streamId);

            final int encodedChannelLength = buffer.putStringAscii(offset + CHANNEL_OFFSET, channel);
            buffer.putStringAscii(offset + CHANNEL_OFFSET + encodedChannelLength, source);

            buffer.putLongOrdered(offset + OBSERVATION_COUNT_OFFSET, 1);

            reportEntry = new ReportEntry(buffer, offset);
            nextRecordOffset += BitUtil.align(requiredCapacity, ENTRY_ALIGNMENT);
        }

        return reportEntry;
    }
public ReportEntry createEntry(
        final long initialBytesLost,
        final long timestampMs,
        final int sessionId,
        final int streamId,
        final String channel,
        final String source)
    {
        ReportEntry reportEntry = null;

        final int requiredCapacity = CHANNEL_OFFSET + (SIZE_OF_INT * 2) + channel.length() + source.length();

        if (requiredCapacity <= (buffer.capacity() - nextRecordOffset))
        {
            final int offset = nextRecordOffset;

            buffer.putLong(offset + TOTAL_BYTES_LOST_OFFSET, initialBytesLost);
            buffer.putLong(offset + FIRST_OBSERVATION_OFFSET, timestampMs);
            buffer.putLong(offset + LAST_OBSERVATION_OFFSET, timestampMs);
            buffer.putInt(offset + SESSION_ID_OFFSET, sessionId);
            buffer.putInt(offset + STREAM_ID_OFFSET, streamId);

            final int encodedChannelLength = buffer.putStringAscii(offset + CHANNEL_OFFSET, channel);
            buffer.putStringAscii(offset + CHANNEL_OFFSET + encodedChannelLength, source);

            buffer.putLongOrdered(offset + OBSERVATION_COUNT_OFFSET, 1);

            reportEntry = new ReportEntry(buffer, offset);
            nextRecordOffset += BitUtil.align(requiredCapacity, ENTRY_ALIGNMENT);
        }

        return reportEntry;
    }
Create a new entry for recording loss on a given stream.
<p>
If not space is remaining in the error report then null is returned.

@param initialBytesLost on the stream.
@param timestampMs      at which the first loss was observed.
@param sessionId        for the stream.
@param streamId         for the stream.
@param channel          for the stream.
@param source           of the stream.
@return a new record or null if the error log has insufficient space.