public PeriodStats plus(PeriodStats toAdd) {
        PeriodStats result = new PeriodStats();

        result.messagesSent += this.messagesSent;
        result.messageSendErrors += this.messageSendErrors;
        result.bytesSent += this.bytesSent;
        result.messagesReceived += this.messagesReceived;
        result.bytesReceived += this.bytesReceived;
        result.totalMessagesSent += this.totalMessagesSent;
        result.totalMessageSendErrors += this.totalMessageSendErrors;
        result.totalMessagesReceived += this.totalMessagesReceived;
        result.publishLatency.add(this.publishLatency);
        result.publishDelayLatency.add(this.publishDelayLatency);
        result.endToEndLatency.add(this.endToEndLatency);

        result.messagesSent += toAdd.messagesSent;
        result.messageSendErrors += toAdd.messageSendErrors;
        result.bytesSent += toAdd.bytesSent;
        result.messagesReceived += toAdd.messagesReceived;
        result.bytesReceived += toAdd.bytesReceived;
        result.totalMessagesSent += toAdd.totalMessagesSent;
        result.totalMessageSendErrors += toAdd.totalMessageSendErrors;
        result.totalMessagesReceived += toAdd.totalMessagesReceived;
        result.publishLatency.add(toAdd.publishLatency);
        result.publishDelayLatency.add(toAdd.publishDelayLatency);
        result.endToEndLatency.add(toAdd.endToEndLatency);

        return result;
    }
@Test
    void plus() {
        PeriodStats one = new PeriodStats();
        one.messagesSent = 1;
        one.messageSendErrors = 2;
        one.bytesSent = 3;
        one.messagesReceived = 4;
        one.bytesReceived = 5;
        one.totalMessagesSent = 6;
        one.totalMessageSendErrors = 7;
        one.totalMessagesReceived = 8;
        PeriodStats two = new PeriodStats();
        two.messagesSent = 10;
        two.messageSendErrors = 20;
        two.bytesSent = 30;
        two.messagesReceived = 40;
        two.bytesReceived = 50;
        two.totalMessagesSent = 60;
        two.totalMessageSendErrors = 70;
        two.totalMessagesReceived = 80;
        PeriodStats result = one.plus(two);
        assertThat(result)
                .satisfies(
                        r -> {
                            assertThat(r.messagesSent).isEqualTo(11);
                            assertThat(r.messageSendErrors).isEqualTo(22);
                            assertThat(r.bytesSent).isEqualTo(33);
                            assertThat(r.messagesReceived).isEqualTo(44);
                            assertThat(r.bytesReceived).isEqualTo(55);
                            assertThat(r.totalMessagesSent).isEqualTo(66);
                            assertThat(r.totalMessageSendErrors).isEqualTo(77);
                            assertThat(r.totalMessagesReceived).isEqualTo(88);

                            two.publishLatency.add(one.publishLatency);
                            two.publishDelayLatency.add(one.publishDelayLatency);
                            two.endToEndLatency.add(one.endToEndLatency);

                            assertThat(r.publishLatency).isEqualTo(two.publishLatency);
                            assertThat(r.publishDelayLatency).isEqualTo(two.publishDelayLatency);
                            assertThat(r.endToEndLatency).isEqualTo(two.endToEndLatency);
                        });
    }