static Counter allocateErrorCounter(
        final Aeron aeron,
        final MutableDirectBuffer tempBuffer,
        final long archiveId)
    {
        int index = 0;
        tempBuffer.putLong(index, archiveId);
        index += SIZE_OF_LONG;
        final int keyLength = index;

        index += tempBuffer.putStringWithoutLengthAscii(index, "Archive Errors");
        index += appendArchiveIdLabel(tempBuffer, index, archiveId);
        index += AeronCounters.appendVersionInfo(tempBuffer, index, ArchiveVersion.VERSION, ArchiveVersion.GIT_SHA);

        return aeron.addCounter(
            AeronCounters.ARCHIVE_ERROR_COUNT_TYPE_ID,
            tempBuffer,
            0,
            keyLength,
            tempBuffer,
            keyLength,
            index - keyLength);
    }
@Test
    void allocateErrorCounter()
    {
        final long archiveId = 24623864;
        final String expectedLabel = "Archive Errors - archiveId=" + archiveId + " " +
            AeronCounters.formatVersionInfo(ArchiveVersion.VERSION, ArchiveVersion.GIT_SHA);
        final Aeron aeron = mock(Aeron.class);
        final MutableDirectBuffer tempBuffer = new UnsafeBuffer(new byte[200]);
        final Counter counter = mock(Counter.class);
        when(aeron.clientId()).thenReturn(archiveId);
        when(aeron.addCounter(
            AeronCounters.ARCHIVE_ERROR_COUNT_TYPE_ID,
            tempBuffer,
            0,
            SIZE_OF_LONG,
            tempBuffer,
            SIZE_OF_LONG,
            expectedLabel.length()))
            .thenReturn(counter);

        final Counter result = ArchiveCounters.allocateErrorCounter(aeron, tempBuffer, aeron.clientId());

        assertSame(counter, result);
        final InOrder inOrder = inOrder(aeron);
        inOrder.verify(aeron).clientId();
        inOrder.verify(aeron).addCounter(anyInt(), any(), anyInt(), anyInt(), any(), anyInt(), anyInt());
        inOrder.verifyNoMoreInteractions();
        assertEquals(archiveId, tempBuffer.getLong(0));
        assertEquals(expectedLabel, tempBuffer.getStringWithoutLengthAscii(SIZE_OF_LONG, expectedLabel.length()));
    }