public boolean record(final Throwable observation)
    {
        final long timestampMs;
        DistinctObservation distinctObservation;

        timestampMs = clock.time();
        synchronized (this)
        {
            distinctObservation = find(distinctObservations, observation);

            if (null == distinctObservation)
            {
                distinctObservation = newObservation(timestampMs, observation);
                if (INSUFFICIENT_SPACE == distinctObservation)
                {
                    return false;
                }
            }
        }

        final int offset = distinctObservation.offset;
        buffer.getAndAddInt(offset + OBSERVATION_COUNT_OFFSET, 1);
        buffer.putLongOrdered(offset + LAST_OBSERVATION_TIMESTAMP_OFFSET, timestampMs);

        return true;
    }
@Test
    void shouldRecordFirstObservation()
    {
        final long timestamp = 7;
        final int offset = 0;
        final RuntimeException error = new RuntimeException("Test Error");

        when(clock.time()).thenReturn(timestamp);

        assertTrue(log.record(error));

        final InOrder inOrder = inOrder(buffer);
        inOrder.verify(buffer).putBytes(eq(offset + ENCODED_ERROR_OFFSET), any(byte[].class));
        inOrder.verify(buffer).putLong(offset + FIRST_OBSERVATION_TIMESTAMP_OFFSET, timestamp);
        inOrder.verify(buffer).putIntOrdered(eq(offset + LENGTH_OFFSET), anyInt());
        inOrder.verify(buffer).getAndAddInt(offset + OBSERVATION_COUNT_OFFSET, 1);
        inOrder.verify(buffer).putLongOrdered(offset + LAST_OBSERVATION_TIMESTAMP_OFFSET, timestamp);
    }