com.github.kristofa.flume.UniformHistogramBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of flume-zipkin-metrics-sink Show documentation
Show all versions of flume-zipkin-metrics-sink Show documentation
Flume Sink that will get application submitted annotations with duration from Zipkin spans and submit them to Metrics. Metrics can be configured to send metrics to several back-ends. Today this sink supports Graphite as back-end.
package com.github.kristofa.flume;
import com.codahale.metrics.Histogram;
import com.codahale.metrics.UniformReservoir;
/**
* Creates histograms with the {@link UniformReservoir}.
*
* @author kristof
*/
class UniformHistogramBuilder implements HistogramBuilder {
private int nrOfSamples;
/**
* Creates Histograms using {@link UniformReservoir} with default number of samples.
*/
public UniformHistogramBuilder() {
}
/**
* Creates Histograms using {@link UniformReservoir} with custom number of samples.
*
* @param nrOfSamples
*/
public UniformHistogramBuilder(final int nrOfSamples) {
this.nrOfSamples = nrOfSamples;
}
/**
* {@inheritDoc}
*/
@Override
public Histogram buildHistogram() {
UniformReservoir reservoir;
if (nrOfSamples == 0) {
reservoir = new UniformReservoir();
} else {
reservoir = new UniformReservoir(nrOfSamples);
}
return new Histogram(reservoir);
}
}