public abstract class MetricPublisher<T> extends Object implements AutoCloseable
| Modifier and Type | Field and Description |
|---|---|
protected BulletConfig |
config |
| Constructor and Description |
|---|
MetricPublisher(BulletConfig config)
Constructor taking a
BulletConfig. |
| Modifier and Type | Method and Description |
|---|---|
abstract T |
convert(Map<String,String> dimensions,
Map<String,Number> metrics)
Convert the given dimensions and metrics into the concrete type of this class.
|
void |
fire(Map<String,Number> metrics)
Fire and forget an event with no extra dimensions and the given metrics.
|
void |
fire(Map<String,String> dimensions,
Map<String,Number> metrics)
Fire and forget an event with the given extra dimensions and the given metrics.
|
void |
fire(String metricName,
Number metricValue)
Fire and forget an event with no extra dimensions and the given single metric.
|
static MetricPublisher |
from(BulletConfig config)
Create a
MetricPublisher instance using the class specified in the config file. |
Map<String,String> |
getDimensions(Map<String,String> extraDimensions)
Returns any static dimensions to use.
|
CompletableFuture<Boolean> |
publish(Map<String,Number> metrics)
Publishes an event no extra dimensions and the given metrics.
|
CompletableFuture<Boolean> |
publish(Map<String,String> dimensions,
Map<String,Number> metrics)
Publish an event with the given dimensions and metrics.
|
CompletableFuture<Boolean> |
publish(String metricName,
Number metricValue)
Publishes an event with no extra dimensions and the given single metric.
|
abstract CompletableFuture<Boolean> |
publish(T payload)
Publish a payload of the concrete type of this class.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcloseprotected BulletConfig config
public MetricPublisher(BulletConfig config)
BulletConfig.config - The config to use containing the necessary information.public Map<String,String> getDimensions(Map<String,String> extraDimensions)
public void fire(String metricName, Number metricValue)
metricName - The name of the metric being published.metricValue - The value of the metric being published.public void fire(Map<String,Number> metrics)
metrics - The metrics to publish.public void fire(Map<String,String> dimensions, Map<String,Number> metrics)
dimensions - The additional dimensions to publish.metrics - The metrics to publish.public CompletableFuture<Boolean> publish(String metricName, Number metricValue)
metricName - The name of the metric being published.metricValue - The value of the metric being published.CompletableFuture that resolves to true or false depending on whether the publish succeeded.public CompletableFuture<Boolean> publish(Map<String,Number> metrics)
metrics - The metrics to publish.CompletableFuture that resolves to true or false depending on whether the publish succeeded.public CompletableFuture<Boolean> publish(Map<String,String> dimensions, Map<String,Number> metrics)
dimensions - The non-null additional dimensions to publish.metrics - The metrics to publish.CompletableFuture that resolves to true or false depending on whether the publish succeeded.public abstract T convert(Map<String,String> dimensions, Map<String,Number> metrics)
public abstract CompletableFuture<Boolean> publish(T payload)
payload - The payload to publish.CompletableFuture that resolves to true or false depending on whether the publish succeeded.public static MetricPublisher from(BulletConfig config)
MetricPublisher instance using the class specified in the config file.config - The non-null BulletConfig containing the class name and metric publisher settings.Copyright © 2021. All rights reserved.