Skip to content

Commit

Permalink
Fix all Javadoc warnings, fix SignalFx tag key naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Schneider committed Feb 20, 2018
1 parent 1715f07 commit e303238
Show file tree
Hide file tree
Showing 65 changed files with 496 additions and 376 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ protected <T> io.micrometer.core.instrument.Gauge newGauge(Meter.Id id, @Nullabl
}

@Override
protected <T> FunctionCounter newFunctionCounter(Meter.Id id, T obj, ToDoubleFunction<T> valueFunction) {
FunctionCounter fc = new StepFunctionCounter<>(id, clock, atlasConfig.step().toMillis(), obj, valueFunction);
protected <T> FunctionCounter newFunctionCounter(Meter.Id id, T obj, ToDoubleFunction<T> countFunction) {
FunctionCounter fc = new StepFunctionCounter<>(id, clock, atlasConfig.step().toMillis(), obj, countFunction);
newMeter(id, Meter.Type.COUNTER, fc.measure());
return fc;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import io.micrometer.core.lang.Nullable;

/**
* Configuration for Datadog exporting.
* Configuration for {@link DatadogMeterRegistry}.
*
* @author Jon Schneider
*/
Expand All @@ -37,18 +37,22 @@ default String prefix() {

default String apiKey() {
String v = get(prefix() + ".apiKey");
if(v == null)
if (v == null)
throw new MissingRequiredConfigurationException("apiKey must be set to report metrics to Datadog");
return v;
}

/**
* @return The Datadog application key. This is only required if you care for metadata like base units, description,
* and meter type to be published to Datadog.
*/
@Nullable
default String applicationKey() {
return get(prefix() + ".applicationKey");
}

/**
* The tag that will be mapped to "host" when shipping metrics to datadog, or {@code null} if
* @return The tag that will be mapped to "host" when shipping metrics to datadog, or {@code null} if
* host should be omitted on publishing.
*/
@Nullable
Expand All @@ -58,7 +62,7 @@ default String hostTag() {
}

/**
* The URI to ship metrics to. If you need to publish metrics to an internal proxy en route to
* @return The URI to ship metrics to. If you need to publish metrics to an internal proxy en route to
* datadoghq, you can define the location of the proxy with this.
*/
default String uri() {
Expand All @@ -67,13 +71,11 @@ default String uri() {
}

/**
* {@code true} if meter descriptions should be sent to Datadog.
* @return {@code true} if meter descriptions should be sent to Datadog.
* Turn this off to minimize the amount of data sent on each scrape.
*/
default boolean descriptions() {
String v = get(prefix() + ".descriptions");
return v == null || Boolean.valueOf(v);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.util.concurrent.TimeUnit;

/**
* Configuration for {@link GangliaMeterRegistry}.
*
* @author Jon Schneider
*/
public interface GangliaConfig extends DropwizardConfig {
Expand All @@ -33,16 +35,14 @@ public interface GangliaConfig extends DropwizardConfig {
/**
* Get the value associated with a key.
*
* @param key
* Key to lookup in the config.
* @return
* Value for the key or null if no key is present.
* @param key Key to lookup in the config.
* @return Value for the key or null if no key is present.
*/
@Nullable
String get(String key);

/**
* Property prefix to prepend to configuration names.
* @return Property prefix to prepend to configuration names.
*/
default String prefix() {
return "ganglia";
Expand All @@ -60,19 +60,19 @@ default TimeUnit durationUnits() {

default String protocolVersion() {
String v = get(prefix() + ".protocolVersion");
if(v == null)
if (v == null)
return "3.1";
if(!v.equals("3.1") && !v.equals("3.0")) {
if (!v.equals("3.1") && !v.equals("3.0")) {
throw new IllegalArgumentException("Ganglia version must be one of 3.1 or 3.0 (check property " + prefix() + ".protocolVersion)");
}
return v;
}

default GMetric.UDPAddressingMode addressingMode() {
String v = get(prefix() + ".addressingMode");
if(v == null)
if (v == null)
return GMetric.UDPAddressingMode.MULTICAST;
if(!v.equalsIgnoreCase("unicast") && !v.equalsIgnoreCase("multicast")) {
if (!v.equalsIgnoreCase("unicast") && !v.equalsIgnoreCase("multicast")) {
throw new IllegalArgumentException("Ganglia UDP addressing mode must be one of 'unicast' or 'multicast' (check property " + prefix() + ".addressingMode)");
}
return GMetric.UDPAddressingMode.valueOf(v.toUpperCase());
Expand All @@ -94,7 +94,7 @@ default int port() {
}

/**
* Returns true if publishing is enabled. Default is {@code true}.
* @return {@code true} if publishing is enabled. Default is {@code true}.
*/
default boolean enabled() {
String v = get(prefix() + ".enabled");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.util.concurrent.TimeUnit;

/**
* Configuration for {@link GraphiteMeterRegistry}.
*
* @author Jon Schneider
*/
public interface GraphiteConfig extends DropwizardConfig {
Expand All @@ -32,23 +34,21 @@ public interface GraphiteConfig extends DropwizardConfig {
/**
* Get the value associated with a key.
*
* @param key
* Key to lookup in the config.
* @return
* Value for the key or null if no key is present.
* @param key Key to lookup in the config.
* @return Value for the key or null if no key is present.
*/
@Nullable
String get(String key);

/**
* Property prefix to prepend to configuration names.
* @return Property prefix to prepend to configuration names.
*/
default String prefix() {
return "graphite";
}

/**
* For the default naming convention, turn the specified tag keys into
* @return For the default naming convention, turn the specified tag keys into
* part of the metric prefix.
*/
default String[] tagsAsPrefix() {
Expand Down Expand Up @@ -76,24 +76,24 @@ default int port() {
}

/**
* Returns true if publishing is enabled. Default is {@code true}.
* @return {@code true} if publishing is enabled. Default is {@code true}.
*/
default boolean enabled() {
String v = get(prefix() + ".enabled");
return v == null || Boolean.valueOf(v);
}

/**
* Protocol to use while shipping data to Graphite.
* @return Protocol to use while shipping data to Graphite.
*/
default GraphiteProtocol protocol() {
String v = get(prefix() + ".protocol");

if(v == null)
if (v == null)
return GraphiteProtocol.PICKLED;

for (GraphiteProtocol flavor : GraphiteProtocol.values()) {
if(flavor.toString().equalsIgnoreCase(v))
if (flavor.toString().equalsIgnoreCase(v))
return flavor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import io.micrometer.core.lang.Nullable;

/**
* Configuration for {@link InfluxMeterRegistry}.
*
* @author Jon Schneider
*/
public interface InfluxConfig extends StepRegistryConfig {
Expand All @@ -33,28 +35,26 @@ default String prefix() {
}

/**
* The db to send metrics to. Defaults to "mydb".
* @return The db to send metrics to. Defaults to "mydb".
*/
default String db() {
String v = get(prefix() + ".db");
return v == null ? "mydb" : v;
}

/**
* Sets the write consistency for each point. The Influx default is 'one'. Must
* be one of 'any', 'one', 'quorum', or 'all'.
*
* Only available for InfluxEnterprise clusters.
* @return Sets the write consistency for each point. The Influx default is 'one'. Must
* be one of 'any', 'one', 'quorum', or 'all'. Only available for InfluxEnterprise clusters.
*/
default InfluxConsistency consistency() {
String v = get(prefix() + ".consistency");
if(v == null)
if (v == null)
return InfluxConsistency.ONE;
return InfluxConsistency.valueOf(v.toUpperCase());
}

/**
* Authenticate requests with this user. By default is {@code null}, and the registry will not
* @return Authenticate requests with this user. By default is {@code null}, and the registry will not
* attempt to present credentials to Influx.
*/
@Nullable
Expand All @@ -63,7 +63,7 @@ default String userName() {
}

/**
* Authenticate requests with this password. By default is {@code null}, and the registry will not
* @return Authenticate requests with this password. By default is {@code null}, and the registry will not
* attempt to present credentials to Influx.
*/
@Nullable
Expand All @@ -72,16 +72,15 @@ default String password() {
}

/**
* Influx writes to the DEFAULT retention policy if one is not specified.
* @return Influx writes to the DEFAULT retention policy if one is not specified.
*/
@Nullable
default String retentionPolicy() {
return get(prefix() + ".retentionPolicy");
}

/**
* Returns the URI for the Influx backend. The default is
* {@code http://localhost:8086/write}.
* @return The URI for the Influx backend. The default is {@code http://localhost:8086}.
*/
default String uri() {
String v = get(prefix() + ".uri");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
import io.micrometer.core.instrument.config.MissingRequiredConfigurationException;
import io.micrometer.core.instrument.step.StepRegistryConfig;

/**
* Configuration for {@link NewRelicMeterRegistry}.
*
* @author Jon Schneider
*/
public interface NewRelicConfig extends StepRegistryConfig {
/**
* Accept configuration defaults
Expand All @@ -44,7 +49,7 @@ default String accountId() {
}

/**
* Returns the URI for the New Relic insights API. The default is
* @return The URI for the New Relic insights API. The default is
* {@code https://insights-collector.newrelic.com}. If you need to pass through
* a proxy, you can change this value.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@

import java.time.Duration;

/**
* Configuration for {@link PrometheusMeterRegistry}.
*
* @author Jon Schneider
*/
public interface PrometheusConfig extends MeterRegistryConfig {
/**
* Accept configuration defaults
Expand All @@ -31,7 +36,7 @@ default String prefix() {
}

/**
* {@code true} if meter descriptions should be sent to Prometheus.
* @return {@code true} if meter descriptions should be sent to Prometheus.
* Turn this off to minimize the amount of data sent on each scrape.
*/
default boolean descriptions() {
Expand All @@ -40,7 +45,7 @@ default boolean descriptions() {
}

/**
* Returns the step size to use in computing windowed statistics like max. The default is 1 minute.
* @return The step size to use in computing windowed statistics like max. The default is 1 minute.
* To get the most out of these statistics, align the step interval to be close to your scrape interval.
*/
default Duration step() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public int hashCode() {
/**
* For Prometheus we cannot use the histogram counts from HistogramSnapshot, as it is based on a
* rolling histogram. Prometheus requires a histogram that accumulates values over the lifetime of the app.
*
* @return Cumulative histogram buckets.
*/
public CountAtBucket[] histogramCounts() {
return percentilesHistogram.takeSnapshot(0, 0, 0, true).histogramCounts();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public PrometheusMeterRegistry(PrometheusConfig config, CollectorRegistry regist
}

/**
* Content that should be included in the response body for an endpoint designate for
* @return Content that should be included in the response body for an endpoint designate for
* Prometheus to scrape from.
*/
public String scrape() {
Expand Down Expand Up @@ -263,9 +263,9 @@ protected <T> FunctionTimer newFunctionTimer(Meter.Id id, T obj, ToLongFunction<
}

@Override
protected <T> FunctionCounter newFunctionCounter(Meter.Id id, T obj, ToDoubleFunction<T> valueFunction) {
protected <T> FunctionCounter newFunctionCounter(Meter.Id id, T obj, ToDoubleFunction<T> countFunction) {
MicrometerCollector collector = collectorByName(id, Collector.Type.COUNTER);
FunctionCounter fc = new CumulativeFunctionCounter<>(id, obj, valueFunction);
FunctionCounter fc = new CumulativeFunctionCounter<>(id, obj, countFunction);
List<String> tagValues = tagValues(id);

collector.add((conventionName, tagKeys) -> Stream.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import io.micrometer.core.instrument.AbstractTimer;
import io.micrometer.core.instrument.Clock;
import io.micrometer.core.instrument.distribution.CountAtBucket;
import io.micrometer.core.instrument.Timer;
import io.micrometer.core.instrument.distribution.CountAtBucket;
import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
import io.micrometer.core.instrument.distribution.TimeWindowLatencyHistogram;
import io.micrometer.core.instrument.distribution.pause.PauseDetector;
Expand Down Expand Up @@ -74,6 +74,8 @@ public double max(TimeUnit unit) {
/**
* For Prometheus we cannot use the histogram counts from HistogramSnapshot, as it is based on a
* rolling histogram. Prometheus requires a histogram that accumulates values over the lifetime of the app.
*
* @return Cumulative histogram buckets.
*/
public CountAtBucket[] histogramCounts() {
return percentilesHistogram.takeSnapshot(0, 0, 0, true).histogramCounts();
Expand Down
Loading

0 comments on commit e303238

Please sign in to comment.