Class StatsdClientImpl
java.lang.Object
com.itrsgroup.collection.instr.AbstractMetricsClient
com.itrsgroup.collection.instr.statsd.StatsdClientImpl
- All Implemented Interfaces:
MetricsClient,AutoCloseable
Statsd
MetricsClient with the following characteristics:
- All instrumentation methods never block or throw, ensuring that callers are not disrupted by metrics delivery.
- All post-construction exceptions are delivered via an optionally provided callback. If no callback is specified, exceptions are silently ignored.
-
Instrumentation requests are queued and delivered by a dedicated thread. If the queue is full when a new
request is submitted, the request will be dropped. An
IOExceptionwill be raised via the callback the first time this occurs; future occurrences are silently ignored.This situation likely indicates a network problem or that the application is sending metrics faster than they can be processed. In the latter case, the queue can be increased to accommodate the load.
-
The client is configured with a maximum message size. Any message that exceeds this size will be dropped and
an
IllegalArgumentExceptionwill be raised via the callback. - Metric names and dimension keys/values are encoded using UTF-8.
- Safe for concurrent use by multiple threads.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.itrsgroup.collection.instr.AbstractMetricsClient
AbstractMetricsClient.Sampler -
Field Summary
Fields inherited from class com.itrsgroup.collection.instr.AbstractMetricsClient
NO_DIMENSIONS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedStatsdClientImpl(StatsdSender sender, Set<Dimension> defaultDimensions, long samplingInterval, int maxMessageSize, Consumer<Throwable> errorCallback) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voiddoAttribute(String name, String value, Set<Dimension> dimensions) protected voiddoClose()Close hook for implementations.protected voidprotected voidprotected voidprotected voiddoEvent(String namespace, String name, String message, Severity severity, Set<Dimension> dimensions) protected voidprotected voiddoGauge(String namespace, String metric, double value, boolean isDelta, Unit unit, Set<Dimension> dimensions) protected voidprotected voiddoTimer(String namespace, String name, long value, TimeUnit unit, double sampleRate, Set<Dimension> dimensions) protected voidprotected voidintMethods inherited from class com.itrsgroup.collection.instr.AbstractMetricsClient
adjustGauge, adjustGauge, adjustGauge, adjustGauge, adjustGauge, adjustGauge, adjustGauge, adjustGauge, attribute, attribute, attribute, attribute, clearGaugeSamplers, close, count, count, count, count, count, count, count, count, decrement, decrement, decrement, decrement, decrement, decrement, decrement, decrement, event, event, event, event, fractionalMillis, gauge, gauge, gauge, gauge, gauge, gauge, gauge, gauge, gauge, gauge, gauge, gauge, gauge, gauge, gauge, gauge, getSamplingInterval, increment, increment, increment, increment, increment, increment, increment, increment, isClosing, removeGaugeSampler, removeGaugeSampler, removeGaugeSampler, removeGaugeSampler, requireNotEmpty, requireNotNull, scheduleTask, shouldSample, submitTask, timer, timer, timer, timer, timer, timer, timer, timer, timer, timer, timer, timer, timer, timer, timer, timer, unique, unique, unique, unique
-
Constructor Details
-
StatsdClientImpl
protected StatsdClientImpl(StatsdSender sender, Set<Dimension> defaultDimensions, long samplingInterval, int maxMessageSize, Consumer<Throwable> errorCallback) Constructor.This constructor should not be used directly - use
StatsdClientBuilderto create a client.- Parameters:
sender- senderdefaultDimensions- dimensions to add to all metricssamplingInterval- interval (in millis) for periodic metric samplingmaxMessageSize- maximum message size (messages exceeding this are dropped)errorCallback- callback for receiving exceptions
-
-
Method Details
-
doAttribute
- Specified by:
doAttributein classAbstractMetricsClient
-
doAttribute
- Overrides:
doAttributein classAbstractMetricsClient
-
doCount
- Specified by:
doCountin classAbstractMetricsClient
-
doCount
protected void doCount(String ns, String metric, long delta, double sampleRate, Set<Dimension> dimensions) - Overrides:
doCountin classAbstractMetricsClient
-
doEvent
- Specified by:
doEventin classAbstractMetricsClient
-
doEvent
protected void doEvent(String namespace, String name, String message, Severity severity, Set<Dimension> dimensions) - Overrides:
doEventin classAbstractMetricsClient
-
doGauge
protected void doGauge(String metric, double value, boolean isDelta, Unit unit, Set<Dimension> dimensions) - Specified by:
doGaugein classAbstractMetricsClient
-
doGauge
protected void doGauge(String namespace, String metric, double value, boolean isDelta, Unit unit, Set<Dimension> dimensions) - Overrides:
doGaugein classAbstractMetricsClient
-
doTimer
protected void doTimer(String name, long value, TimeUnit unit, double sampleRate, Set<Dimension> dimensions) - Specified by:
doTimerin classAbstractMetricsClient
-
doTimer
protected void doTimer(String namespace, String name, long value, TimeUnit unit, double sampleRate, Set<Dimension> dimensions) - Overrides:
doTimerin classAbstractMetricsClient
-
doUnique
- Specified by:
doUniquein classAbstractMetricsClient
-
doUnique
protected void doUnique(String namespace, String metric, String identifier, Set<Dimension> dimensions) - Overrides:
doUniquein classAbstractMetricsClient
-
doClose
protected void doClose()Description copied from class:AbstractMetricsClientClose hook for implementations.- Overrides:
doClosein classAbstractMetricsClient
-
getMaxMessageSize
public int getMaxMessageSize()- Returns:
- max configured message size in bytes
-
getDefaultDimensions
- Returns:
- default dimensions added to each message
-