Skip to content

Commit

Permalink
Polish Javadocs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Schneider committed Oct 29, 2018
1 parent 0334b98 commit 3905415
Show file tree
Hide file tree
Showing 25 changed files with 159 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class AppOpticsMeterRegistry extends StepMeterRegistry {
private final AppOpticsConfig config;
private final HttpSender httpClient;

@SuppressWarnings("deprecation")
public AppOpticsMeterRegistry(AppOpticsConfig config, Clock clock) {
this(config, clock, DEFAULT_THREAD_FACTORY, new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout()));
}
Expand Down Expand Up @@ -269,6 +270,7 @@ public static class Builder {
private ThreadFactory threadFactory = DEFAULT_THREAD_FACTORY;
private HttpSender httpClient;

@SuppressWarnings("deprecation")
Builder(AppOpticsConfig config) {
this.config = config;
this.httpClient = new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public static class Builder {
@Nullable
private TelemetryConfiguration telemetryConfiguration;

public Builder(AzureMonitorConfig config) {
Builder(AzureMonitorConfig config) {
this.config = config;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,20 @@ public class DatadogMeterRegistry extends StepMeterRegistry {
*/
private final Set<String> verifiedMetadata = ConcurrentHashMap.newKeySet();

/**
* @param config Configuration options for the registry that are describable as properties.
* @param clock The clock to use for timings.
*/
@SuppressWarnings("deprecation")
public DatadogMeterRegistry(DatadogConfig config, Clock clock) {
this(config, clock, DEFAULT_THREAD_FACTORY);
this(config, clock, DEFAULT_THREAD_FACTORY,
new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout()));
}

/**
* @param config Configuration options for the registry that are describable as properties.
* @param clock The clock to use for timings.
* @param threadFactory The thread factory to use to create the publishing thread.
* @deprecated Use {@link #builder(DatadogConfig)} instead.
*/
@Deprecated
Expand Down Expand Up @@ -287,6 +296,7 @@ public static class Builder {
private ThreadFactory threadFactory = DEFAULT_THREAD_FACTORY;
private HttpSender httpClient;

@SuppressWarnings("deprecation")
Builder(DatadogConfig config) {
this.config = config;
this.httpClient = new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class DynatraceMeterRegistry extends StepMeterRegistry {
private final Set<String> createdCustomMetrics = ConcurrentHashMap.newKeySet();
private final String customMetricEndpointTemplate;

@SuppressWarnings("deprecation")
public DynatraceMeterRegistry(DynatraceConfig config, Clock clock) {
this(config, clock, DEFAULT_THREAD_FACTORY, new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout()));
}
Expand Down Expand Up @@ -259,11 +260,12 @@ public static class Builder {

private Clock clock = Clock.SYSTEM;
private ThreadFactory threadFactory = DEFAULT_THREAD_FACTORY;
private HttpSender pushHandler;
private HttpSender httpClient;

public Builder(DynatraceConfig config) {
@SuppressWarnings("deprecation")
Builder(DynatraceConfig config) {
this.config = config;
this.pushHandler = new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout());
this.httpClient = new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout());
}

public Builder clock(Clock clock) {
Expand All @@ -276,13 +278,13 @@ public Builder threadFactory(ThreadFactory threadFactory) {
return this;
}

public Builder httpPushHandler(HttpSender pushHandler) {
this.pushHandler = pushHandler;
public Builder httpClient(HttpSender httpClient) {
this.httpClient = httpClient;
return this;
}

public DynatraceMeterRegistry build() {
return new DynatraceMeterRegistry(config, clock, threadFactory, pushHandler);
return new DynatraceMeterRegistry(config, clock, threadFactory, httpClient);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public String apiToken() {
}
};
DynatraceMeterRegistry registry = DynatraceMeterRegistry.builder(config)
.httpPushHandler(request -> new HttpSender.Response(200, null))
.httpClient(request -> new HttpSender.Response(200, null))
.build();

Field createdCustomMetricsField = DynatraceMeterRegistry.class.getDeclaredField("createdCustomMetrics");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class ElasticMeterRegistry extends StepMeterRegistry {

private boolean checkedForIndexTemplate = false;

@SuppressWarnings("deprecation")
public ElasticMeterRegistry(ElasticConfig config, Clock clock) {
this(config, clock, DEFAULT_THREAD_FACTORY,
new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout()));
Expand Down Expand Up @@ -281,7 +282,8 @@ public static class Builder {
private ThreadFactory threadFactory = DEFAULT_THREAD_FACTORY;
private HttpSender httpClient;

public Builder(ElasticConfig config) {
@SuppressWarnings("deprecation")
Builder(ElasticConfig config) {
this.config = config;
this.httpClient = new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public static class Builder {
private ThreadFactory threadFactory = DEFAULT_THREAD_FACTORY;
private HierarchicalNameMapper nameMapper = HierarchicalNameMapper.DEFAULT;

public Builder(GangliaConfig config) {
Builder(GangliaConfig config) {
this.config = config;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class HumioMeterRegistry extends StepMeterRegistry {
private final HumioConfig config;
private final HttpSender httpClient;

@SuppressWarnings("deprecation")
public HumioMeterRegistry(HumioConfig config, Clock clock) {
this(config, clock, DEFAULT_THREAD_FACTORY, new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout()));
}
Expand Down Expand Up @@ -146,7 +147,8 @@ public static class Builder {
private ThreadFactory threadFactory = DEFAULT_THREAD_FACTORY;
private HttpSender httpClient;

public Builder(HumioConfig config) {
@SuppressWarnings("deprecation")
Builder(HumioConfig config) {
this.config = config;
this.httpClient = new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,21 @@ public class InfluxMeterRegistry extends StepMeterRegistry {
private final Logger logger = LoggerFactory.getLogger(InfluxMeterRegistry.class);
private boolean databaseExists = false;

public InfluxMeterRegistry(InfluxConfig config, Clock clock, ThreadFactory threadFactory) {
this(config, clock, threadFactory, new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout()));
@SuppressWarnings("deprecation")
public InfluxMeterRegistry(InfluxConfig config, Clock clock) {
this(config, clock, DEFAULT_THREAD_FACTORY,
new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout()));
}

public InfluxMeterRegistry(InfluxConfig config, Clock clock) {
this(config, clock, DEFAULT_THREAD_FACTORY);
/**
* @param config Configuration options for the registry that are describable as properties.
* @param clock The clock to use for timings.
* @param threadFactory The thread factory to use to create the publishing thread.
* @deprecated Use {@link #builder(InfluxConfig)} instead.
*/
@Deprecated
public InfluxMeterRegistry(InfluxConfig config, Clock clock, ThreadFactory threadFactory) {
this(config, clock, threadFactory, new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout()));
}

private InfluxMeterRegistry(InfluxConfig config, Clock clock, ThreadFactory threadFactory, HttpSender httpClient) {
Expand Down Expand Up @@ -218,7 +227,8 @@ public static class Builder {
private ThreadFactory threadFactory = DEFAULT_THREAD_FACTORY;
private HttpSender httpClient;

public Builder(InfluxConfig config) {
@SuppressWarnings("deprecation")
Builder(InfluxConfig config) {
this.config = config;
this.httpClient = new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class KairosMeterRegistry extends StepMeterRegistry {
private final KairosConfig config;
private final HttpSender httpClient;

@SuppressWarnings("deprecation")
public KairosMeterRegistry(KairosConfig config, Clock clock) {
this(config, clock, DEFAULT_THREAD_FACTORY, new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout()));
}
Expand Down Expand Up @@ -231,7 +232,8 @@ public static class Builder {
private ThreadFactory threadFactory = DEFAULT_THREAD_FACTORY;
private HttpSender httpClient;

public Builder(KairosConfig config) {
@SuppressWarnings("deprecation")
Builder(KairosConfig config) {
this.config = config;
this.httpClient = new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,20 @@ public class NewRelicMeterRegistry extends StepMeterRegistry {
private final HttpSender httpClient;
private final Logger logger = LoggerFactory.getLogger(NewRelicMeterRegistry.class);

/**
* @param config Configuration options for the registry that are describable as properties.
* @param clock The clock to use for timings.
*/
@SuppressWarnings("deprecation")
public NewRelicMeterRegistry(NewRelicConfig config, Clock clock) {
this(config, clock, DEFAULT_THREAD_FACTORY);
this(config, clock, DEFAULT_THREAD_FACTORY,
new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout()));
}

/**
* @param config Configuration options for the registry that are describable as properties.
* @param clock The clock to use for timings.
* @param threadFactory The thread factory to use to create the publishing thread.
* @deprecated Use {@link #builder(NewRelicConfig)} instead.
*/
@Deprecated
Expand Down Expand Up @@ -220,7 +229,8 @@ public static class Builder {
private ThreadFactory threadFactory = DEFAULT_THREAD_FACTORY;
private HttpSender httpClient;

public Builder(NewRelicConfig config) {
@SuppressWarnings("deprecation")
Builder(NewRelicConfig config) {
this.config = config;
this.httpClient = new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@

/**
* When running this as a main method, supply an environment variable GOOGLE_APPLICATION_CREDENTIALS with a service
* account JSON as described in the {@link <a href="https://cloud.google.com/monitoring/docs/reference/libraries#setting_up_authentication">here</a>}
* <p>
* Your service account must have the "monitoring.editor" role at least, as described
* {@link <a href="https://cloud.google.com/monitoring/access-control">here</a>}
* account JSON. Your service account must have the "monitoring.editor" role at least.
*
* @see <a href="https://cloud.google.com/monitoring/docs/reference/libraries#setting_up_authentication">Google Cloud authentication</a>
* @see <a href="https://cloud.google.com/monitoring/access-control">Google Cloud access control</a>
*/
public class ClearCustomMetricDescriptors {
public static void clearCustomMetricDescriptors(MetricServiceSettings settings, String projectId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ public static class Builder {
@Nullable
private Consumer<String> lineSink;

public Builder(StatsdConfig config) {
Builder(StatsdConfig config) {
this.config = config;
this.namingConvention = namingConventionFromFlavor(config.flavor());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ private BufferingFlux() {
* Creates a Flux that implements Nagle's algorithm to buffer messages -- joined by a delimiter string -- to up a
* maximum number of bytes, or a maximum duration of time. This avoids sending many small packets in favor of fewer
* larger ones.
* <p>
* Also see: https://en.wikipedia.org/wiki/Nagle%27s_algorithm
*
* @param source The input flux.
* @param delimiter The delimiter to use to join messages
* @param maxByteArraySize The buffered payload will contain no more than this number of bytes
* @param maxMillisecondsBetweenEmits Buffered payloads will be emitted no less frequently than this.
* @return A flux implementing Nagle's algorithm.
* @see <a href="https://en.wikipedia.org/wiki/Nagle%27s_algorithm">Nagle's algorithm</a>
*/
public static Flux<String> create(final Flux<String> source, final String delimiter, final int maxByteArraySize, final long maxMillisecondsBetweenEmits) {
return Flux.defer(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,20 @@ public class WavefrontMeterRegistry extends StepMeterRegistry {
private final WavefrontConfig config;
private final HttpSender httpClient;

/**
* @param config Configuration options for the registry that are describable as properties.
* @param clock The clock to use for timings.
*/
@SuppressWarnings("deprecation")
public WavefrontMeterRegistry(WavefrontConfig config, Clock clock) {
this(config, clock, DEFAULT_THREAD_FACTORY);
this(config, clock, DEFAULT_THREAD_FACTORY,
new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout()));
}

/**
* @param config Configuration options for the registry that are describable as properties.
* @param clock The clock to use for timings.
* @param threadFactory The thread factory to use to create the publishing thread.
* @deprecated Use {@link #builder(WavefrontConfig)} instead.
*/
@Deprecated
Expand Down Expand Up @@ -85,6 +94,7 @@ public void start(ThreadFactory threadFactory) {
super.start(threadFactory);
}

@SuppressWarnings("deprecation")
@Override
protected void publish() {
for (List<Meter> batch : MeterPartition.partition(this, config.batchSize())) {
Expand Down Expand Up @@ -116,6 +126,7 @@ protected void publish() {
SocketAddress endpoint = uri.getHost() != null ? new InetSocketAddress(uri.getHost(), uri.getPort()) :
new InetSocketAddress(InetAddress.getByName(null), uri.getPort());
try (Socket socket = new Socket()) {
// connectTimeout should be pulled up to WavefrontConfig when it is removed elsewhere
socket.connect(endpoint, (int) this.config.connectTimeout().toMillis());
try (OutputStreamWriter writer = new OutputStreamWriter(socket.getOutputStream(), StandardCharsets.UTF_8)) {
writer.write(stream.collect(joining("\n")) + "\n");
Expand All @@ -137,7 +148,7 @@ private void logSuccessfulMetricsSent(List<Meter> batch) {
}

private boolean directToApi() {
return !"proxy" .equals(URI.create(config.uri()).getScheme());
return !"proxy".equals(URI.create(config.uri()).getScheme());
}

private Stream<String> writeFunctionTimer(FunctionTimer timer) {
Expand Down Expand Up @@ -271,6 +282,7 @@ public static class Builder {
private ThreadFactory threadFactory = DEFAULT_THREAD_FACTORY;
private HttpSender httpClient;

@SuppressWarnings("deprecation")
Builder(WavefrontConfig config) {
this.config = config;
this.httpClient = new HttpUrlConnectionSender(config.connectTimeout(), config.readTimeout());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public interface Gauge extends Meter {
* is determined from.
* @param f A function that yields a double value for the gauge, based on the state of
* {@code obj}.
* @param <T> The type of object to gauge.
* @return A new gauge builder.
*/
static <T> Builder<T> builder(String name, @Nullable T obj, ToDoubleFunction<T> f) {
Expand Down Expand Up @@ -154,7 +155,8 @@ public Builder<T> baseUnit(@Nullable String unit) {
* This method may be removed in future minor or major releases if we find a way to mark derivatives in a
* private way that does not have other API compatibility consequences.
*
* @return The meter id of a meter for which this metric is a synthetic derivative.
* @param syntheticAssociation The meter id of a meter for which this metric is a synthetic derivative.
* @return The gauge builder with added base unit.
*/
@Incubating(since = "1.1.0")
public Builder<T> synthetic(Meter.Id syntheticAssociation) {
Expand All @@ -166,6 +168,8 @@ public Builder<T> synthetic(Meter.Id syntheticAssociation) {
* Indicates that the gauge should maintain a strong reference on the object upon which
* its instantaneous value is determined.
*
* @param strong Whether or not to maintain a strong reference on the gauged object.
* @return The gauge builder with added base unit.
* @since 1.1.0
*/
@Incubating(since = "1.1.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public void register(Iterable<Row> rows) {
register(rows, false);
}

@SuppressWarnings("unchecked")
public void register(Iterable<Row> rows, boolean overwrite) {
registeredRows.getAndUpdate(oldRows -> {
// for some reason the compiler needs type assistance by creating this intermediate variable.
Expand All @@ -68,7 +69,6 @@ public void register(Iterable<Row> rows, boolean overwrite) {
}

if (overwrite || !previouslyDefined) {
// noinspection unchecked
registry.gauge(rowId, row.obj, new StrongReferenceGaugeFunction<>(row.obj, row.valueFunction));
}

Expand Down
Loading

0 comments on commit 3905415

Please sign in to comment.