Interface MetricPublisher
-
- All Superinterfaces:
AutoCloseable
,SdkAutoCloseable
- All Known Implementing Classes:
LoggingMetricPublisher
@ThreadSafe public interface MetricPublisher extends SdkAutoCloseable
Interface to report and publish the collected SDK metric events to external sources.Conceptually, a publisher receives a stream of
MetricCollection
objects overs its lifetime through itspublish(MetricCollection)
)} method. Implementations are then free further aggregate these events into sets of metrics that are then published to some external system for further use. As long as a publisher is not closed, then it can receiveMetricCollection
objects at any time. In addition, as the SDK makes use of multithreading, it's possible that the publisher is shared concurrently by multiple threads, and necessitates that all implementations are threadsafe.The SDK may invoke methods on the interface from multiple threads concurrently so implementations must be threadsafe.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
void
publish(MetricCollection metricCollection)
Notify the publisher of new metric data.
-
-
-
Method Detail
-
publish
void publish(MetricCollection metricCollection)
Notify the publisher of new metric data. After this call returns, the caller can safely discard the givenmetricCollection
instance if it no longer needs it. Implementations are strongly encouraged to complete any further aggregation and publishing of metrics in an asynchronous manner to avoid blocking the calling thread.With the exception of a
null
metricCollection
, all invocations of this method must return normally. This is to ensure that callers of the publisher can safely assume that even in situations where an error happens during publishing that it will not interrupt the calling thread.- Parameters:
metricCollection
- The collection of metrics.- Throws:
IllegalArgumentException
- IfmetricCollection
isnull
.
-
close
void close()
Important: Implementations must block the calling thread until all pending metrics are published and any resources acquired have been freed.
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceSdkAutoCloseable
-
-