All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lightstep.tracer.shared.ClientMetrics Maven / Gradle / Ivy

There is a newer version: 0.32.0
Show newest version
package com.lightstep.tracer.shared;

import com.lightstep.tracer.grpc.InternalMetrics;
import com.lightstep.tracer.grpc.MetricsSample;

import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicLong;

/**
 * Tracks client metrics for internal purposes.
 */
class ClientMetrics {
    private final AtomicLong spansDropped = new AtomicLong(0);

    void addSpansDropped(int size) {
        if (size != 0) {
            spansDropped.addAndGet(size);
        }
    }

    long getSpansDropped() {
        return spansDropped.get();
    }

    InternalMetrics toInternalMetricsAndReset() {
        return InternalMetrics.newBuilder()
                .addCounts(MetricsSample.newBuilder()
                        .setName("spans.dropped")
                        .setIntValue(getAndResetSpansDropped())
                        .build()
                ).build();
    }

    private long getAndResetSpansDropped() {
        return spansDropped.getAndSet(0);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy