diff --git a/implementations/micrometer-registry-kairos/src/main/java/io/micrometer/kairos/KairosConfig.java b/implementations/micrometer-registry-kairos/src/main/java/io/micrometer/kairos/KairosConfig.java index 1e275006cc..b25a3eef8c 100644 --- a/implementations/micrometer-registry-kairos/src/main/java/io/micrometer/kairos/KairosConfig.java +++ b/implementations/micrometer-registry-kairos/src/main/java/io/micrometer/kairos/KairosConfig.java @@ -1,5 +1,5 @@ /** - * Copyright 2017 Pivotal Software, Inc. + * Copyright 2018 Pivotal Software, Inc. *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package io.micrometer.kairos; import io.micrometer.core.instrument.step.StepRegistryConfig; +import io.micrometer.core.lang.Nullable; /** * @author Anton Ilinchik @@ -37,35 +38,30 @@ default String prefix() { } /** - * The host to send the metrics to - * Default is "http://localhost:8080" + * The URI to send the metrics to. * - * @return host + * @return uri */ - default String host() { - String v = get(prefix() + ".host"); + default String uri() { + String v = get(prefix() + ".uri"); return v == null ? "http://localhost:8080/api/v1/datapoints" : v; } /** - * The Basic Authentication username. - * Default is: "" (= do not perform Basic Authentication) - * - * @return username for Basic Authentication + * @return Authenticate requests with this user. By default is {@code null}, and the registry will not + * attempt to present credentials to KairosDB. */ + @Nullable default String userName() { - String v = get(prefix() + ".userName"); - return v == null ? "" : v; + return get(prefix() + ".userName"); } /** - * The Basic Authentication password. - * Default is: "" (= do not perform Basic Authentication) - * - * @return password for Basic Authentication + * @return Authenticate requests with this password. By default is {@code null}, and the registry will not + * attempt to present credentials to KairosDB. */ + @Nullable default String password() { - String v = get(prefix() + ".password"); - return v == null ? "" : v; + return get(prefix() + ".password"); } } diff --git a/implementations/micrometer-registry-kairos/src/main/java/io/micrometer/kairos/KairosMeterRegistry.java b/implementations/micrometer-registry-kairos/src/main/java/io/micrometer/kairos/KairosMeterRegistry.java index 99cfde573c..effd3676ed 100644 --- a/implementations/micrometer-registry-kairos/src/main/java/io/micrometer/kairos/KairosMeterRegistry.java +++ b/implementations/micrometer-registry-kairos/src/main/java/io/micrometer/kairos/KairosMeterRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright 2017 Pivotal Software, Inc. + * Copyright 2018 Pivotal Software, Inc. *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,34 +15,16 @@ */ package io.micrometer.kairos; -import io.micrometer.core.instrument.Clock; -import io.micrometer.core.instrument.Counter; -import io.micrometer.core.instrument.DistributionSummary; -import io.micrometer.core.instrument.FunctionCounter; -import io.micrometer.core.instrument.FunctionTimer; -import io.micrometer.core.instrument.Gauge; -import io.micrometer.core.instrument.LongTaskTimer; -import io.micrometer.core.instrument.Meter; -import io.micrometer.core.instrument.Tag; -import io.micrometer.core.instrument.TimeGauge; -import io.micrometer.core.instrument.Timer; +import io.micrometer.core.instrument.*; import io.micrometer.core.instrument.step.StepMeterRegistry; -import io.micrometer.core.instrument.util.HttpHeader; -import io.micrometer.core.instrument.util.HttpMethod; -import io.micrometer.core.instrument.util.MediaType; import io.micrometer.core.instrument.util.MeterPartition; -import io.micrometer.core.instrument.util.StringUtils; -import io.micrometer.core.lang.Nullable; +import io.micrometer.core.ipc.http.HttpClient; +import io.micrometer.core.ipc.http.HttpUrlConnectionClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.OutputStream; -import java.net.HttpURLConnection; import java.net.InetAddress; -import java.net.URL; import java.net.UnknownHostException; -import java.nio.charset.StandardCharsets; -import java.util.Base64; import java.util.List; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; @@ -51,117 +33,58 @@ import java.util.stream.Stream; import java.util.stream.StreamSupport; -import static java.util.Objects.requireNonNull; +import static io.micrometer.core.instrument.Meter.Type.match; /** * @author Anton Ilinchik */ public class KairosMeterRegistry extends StepMeterRegistry { - private final Logger logger = LoggerFactory.getLogger(KairosMeterRegistry.class); - private final KairosConfig config; - - public KairosMeterRegistry(KairosConfig config) { - this(config, Clock.SYSTEM); - } + private final HttpClient httpClient; public KairosMeterRegistry(KairosConfig config, Clock clock) { - this(config, clock, Executors.defaultThreadFactory()); + this(config, clock, Executors.defaultThreadFactory(), new HttpUrlConnectionClient(config.connectTimeout(), config.readTimeout())); } - public KairosMeterRegistry(KairosConfig config, Clock clock, ThreadFactory threadFactory) { + private KairosMeterRegistry(KairosConfig config, Clock clock, ThreadFactory threadFactory, HttpClient httpClient) { super(config, clock); - requireNonNull(config, "config must not be null"); - requireNonNull(threadFactory, "threadFactory must not be null"); + + this.config().namingConvention(new KairosNamingConvention()); this.config = config; - config().namingConvention(new KairosNamingConvention()); - start(threadFactory); + this.httpClient = httpClient; + + if (config.enabled()) + start(threadFactory); } @Override protected void publish() { for (List batch : MeterPartition.partition(this, config.batchSize())) { - long wallTime = config().clock().wallTime(); - String payload = - batch.stream().flatMap(m -> { - if (m instanceof Timer) { - return writeTimer((Timer) m, wallTime); - } - if (m instanceof Counter) { - return writeCounter((Counter) m, wallTime); - } - if (m instanceof LongTaskTimer) { - return writeLongTaskTimer((LongTaskTimer) m, wallTime); - } - if (m instanceof Gauge) { - return writeGauge((Gauge) m, wallTime); - } - if (m instanceof TimeGauge) { - return writeTimeGauge((TimeGauge) m, wallTime); - } - if (m instanceof FunctionTimer) { - return writeFunctionTimer((FunctionTimer) m, wallTime); - } - if (m instanceof FunctionCounter) { - return writeFunctionCounter((FunctionCounter) m, wallTime); - } - if (m instanceof DistributionSummary) { - return writeSummary((DistributionSummary) m, wallTime); - } - return writeCustomMetric(m, wallTime); - }).collect(Collectors.joining(", ")); - - sendToKairos(String.format("[%s]", payload)); - } - } - - private void sendToKairos(String bulkPayload) { - HttpURLConnection con = null; - - try { - URL templateUrl = new URL(config.host()); - con = (HttpURLConnection) templateUrl.openConnection(); - con.setConnectTimeout((int) config.connectTimeout().toMillis()); - con.setReadTimeout((int) config.readTimeout().toMillis()); - con.setRequestMethod(HttpMethod.POST); - con.setRequestProperty(HttpHeader.CONTENT_TYPE, MediaType.APPLICATION_JSON); - con.setDoOutput(true); - - if (StringUtils.isNotBlank(config.userName()) && StringUtils.isNotBlank(config.password())) { - byte[] authBinary = (config.userName() + ":" + config.password()).getBytes(StandardCharsets.UTF_8); - String authEncoded = Base64.getEncoder().encodeToString(authBinary); - con.setRequestProperty(HttpHeader.AUTHORIZATION, "Basic " + authEncoded); - } - logger.trace("Sending payload to KairosDB:"); - logger.trace(bulkPayload); - - try (OutputStream os = con.getOutputStream()) { - os.write(bulkPayload.getBytes(StandardCharsets.UTF_8)); - os.flush(); - } - - int status = con.getResponseCode(); - - if (status >= 200 && status < 300) { - logger.trace("successfully sent events to KairosDB"); - } else { - logger.error("failed to send metrics, status: {} message: {}", status, con.getResponseMessage()); - } - } catch (Throwable e) { - logger.warn("failed to send metrics", e); - } finally { - quietlyCloseUrlConnection(con); - } - } - - private void quietlyCloseUrlConnection(@Nullable HttpURLConnection con) { - try { - if (con != null) { - con.disconnect(); + try { + httpClient.post(config.uri()) + .withBasicAuthentication(config.userName(), config.password()) + .withJsonContent( + batch.stream().flatMap(m -> match(m, + this::writeGauge, + this::writeCounter, + this::writeTimer, + this::writeSummary, + this::writeLongTaskTimer, + this::writeTimeGauge, + this::writeFunctionCounter, + this::writeFunctionTimer, + this::writeCustomMetric) + ).collect(Collectors.joining(",", "[", "]")) + ) + .print() + .send() + .onSuccess(response -> logger.debug("successfully sent {} metrics to kairos.", batch.size())) + .onError(response -> logger.error("failed to send metrics to kairos: {}", response.body())); + } catch (Throwable t) { + logger.warn("failed to send metrics to kairos", t); } - } catch (Exception ignore) { } } @@ -205,72 +128,77 @@ String build() { } } - Stream writeSummary(DistributionSummary summary, Long wallTime) { + Stream writeSummary(DistributionSummary summary) { + long wallTime = config().clock().wallTime(); return Stream.of( - writeMetric(idWithSuffix(summary.getId(), "count"), wallTime, summary.count()), - writeMetric(idWithSuffix(summary.getId(), "mean"), wallTime, summary.mean()), - writeMetric(idWithSuffix(summary.getId(), "sum"), wallTime, summary.totalAmount()), - writeMetric(idWithSuffix(summary.getId(), "max"), wallTime, summary.max()) + writeMetric(idWithSuffix(summary.getId(), "count"), wallTime, summary.count()), + writeMetric(idWithSuffix(summary.getId(), "avg"), wallTime, summary.mean()), + writeMetric(idWithSuffix(summary.getId(), "sum"), wallTime, summary.totalAmount()), + writeMetric(idWithSuffix(summary.getId(), "max"), wallTime, summary.max()) ); } - Stream writeFunctionTimer(FunctionTimer timer, Long wallTime) { + Stream writeFunctionTimer(FunctionTimer timer) { + long wallTime = config().clock().wallTime(); return Stream.of( - writeMetric(idWithSuffix(timer.getId(), "count"), wallTime, timer.count()), - writeMetric(idWithSuffix(timer.getId(), "mean"), wallTime, timer.mean(getBaseTimeUnit())), - writeMetric(idWithSuffix(timer.getId(), "sum"), wallTime, timer.totalTime(getBaseTimeUnit())) + writeMetric(idWithSuffix(timer.getId(), "count"), wallTime, timer.count()), + writeMetric(idWithSuffix(timer.getId(), "avg"), wallTime, timer.mean(getBaseTimeUnit())), + writeMetric(idWithSuffix(timer.getId(), "sum"), wallTime, timer.totalTime(getBaseTimeUnit())) ); } - Stream writeTimer(Timer timer, Long wallTime) { + Stream writeTimer(Timer timer) { + long wallTime = config().clock().wallTime(); return Stream.of( - writeMetric(idWithSuffix(timer.getId(), "count"), wallTime, timer.count()), - writeMetric(idWithSuffix(timer.getId(), "max"), wallTime, timer.max(getBaseTimeUnit())), - writeMetric(idWithSuffix(timer.getId(), "mean"), wallTime, timer.mean(getBaseTimeUnit())), - writeMetric(idWithSuffix(timer.getId(), "sum"), wallTime, timer.totalTime(getBaseTimeUnit())) + writeMetric(idWithSuffix(timer.getId(), "count"), wallTime, timer.count()), + writeMetric(idWithSuffix(timer.getId(), "max"), wallTime, timer.max(getBaseTimeUnit())), + writeMetric(idWithSuffix(timer.getId(), "avg"), wallTime, timer.mean(getBaseTimeUnit())), + writeMetric(idWithSuffix(timer.getId(), "sum"), wallTime, timer.totalTime(getBaseTimeUnit())) ); } - Stream writeFunctionCounter(FunctionCounter counter, Long wallTime) { - return Stream.of(writeMetric(counter.getId(), wallTime, counter.count())); + Stream writeFunctionCounter(FunctionCounter counter) { + return Stream.of(writeMetric(counter.getId(), config().clock().wallTime(), counter.count())); } - Stream writeCounter(Counter counter, Long wallTime) { - return Stream.of(writeMetric(counter.getId(), wallTime, counter.count())); + Stream writeCounter(Counter counter) { + return Stream.of(writeMetric(counter.getId(), config().clock().wallTime(), counter.count())); } - Stream writeGauge(Gauge gauge, Long wallTime) { + Stream writeGauge(Gauge gauge) { Double value = gauge.value(); - return value.isNaN() ? Stream.empty() : Stream.of(writeMetric(gauge.getId(), wallTime, value)); + return value.isNaN() ? Stream.empty() : Stream.of(writeMetric(gauge.getId(), config().clock().wallTime(), value)); } - Stream writeTimeGauge(TimeGauge timeGauge, Long wallTime) { + Stream writeTimeGauge(TimeGauge timeGauge) { Double value = timeGauge.value(getBaseTimeUnit()); - return value.isNaN() ? Stream.empty() : Stream.of(writeMetric(timeGauge.getId(), wallTime, value)); + return value.isNaN() ? Stream.empty() : Stream.of(writeMetric(timeGauge.getId(), config().clock().wallTime(), value)); } - Stream writeLongTaskTimer(LongTaskTimer timer, long wallTime) { + Stream writeLongTaskTimer(LongTaskTimer timer) { + long wallTime = config().clock().wallTime(); return Stream.of( - writeMetric(idWithSuffix(timer.getId(), "activeTasks"), wallTime, timer.activeTasks()), - writeMetric(idWithSuffix(timer.getId(), "duration"), wallTime, timer.duration(getBaseTimeUnit())) + writeMetric(idWithSuffix(timer.getId(), "activeTasks"), wallTime, timer.activeTasks()), + writeMetric(idWithSuffix(timer.getId(), "duration"), wallTime, timer.duration(getBaseTimeUnit())) ); } - private Stream writeCustomMetric(final Meter meter, Long wallTime) { + private Stream writeCustomMetric(final Meter meter) { + long wallTime = config().clock().wallTime(); return StreamSupport.stream(meter.measure().spliterator(), false) - .map(ms -> new KairosMetricBuilder() - .field("name", ms.getStatistic().getTagValueRepresentation()) - .datapoints(wallTime, ms.getValue()) - .tags(getConventionTags(meter.getId())) - .build()); + .map(ms -> new KairosMetricBuilder() + .field("name", ms.getStatistic().getTagValueRepresentation()) + .datapoints(wallTime, ms.getValue()) + .tags(getConventionTags(meter.getId())) + .build()); } - String writeMetric(Meter.Id id, Long wallTime, Number value) { + String writeMetric(Meter.Id id, long wallTime, Number value) { return new KairosMetricBuilder() - .field("name", getConventionName(id)) - .datapoints(wallTime, value) - .tags(getConventionTags(id)) - .build(); + .field("name", getConventionName(id)) + .datapoints(wallTime, value) + .tags(getConventionTags(id)) + .build(); } private Meter.Id idWithSuffix(final Meter.Id id, final String suffix) { @@ -281,4 +209,40 @@ private Meter.Id idWithSuffix(final Meter.Id id, final String suffix) { protected TimeUnit getBaseTimeUnit() { return TimeUnit.MILLISECONDS; } + + public static Builder builder(KairosConfig config) { + return new Builder(config); + } + + public static class Builder { + private final KairosConfig config; + + private Clock clock = Clock.SYSTEM; + private ThreadFactory threadFactory = Executors.defaultThreadFactory(); + private HttpClient httpClient; + + public Builder(KairosConfig config) { + this.config = config; + this.httpClient = new HttpUrlConnectionClient(config.connectTimeout(), config.readTimeout()); + } + + public Builder clock(Clock clock) { + this.clock = clock; + return this; + } + + public Builder threadFactory(ThreadFactory threadFactory) { + this.threadFactory = threadFactory; + return this; + } + + public Builder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + public KairosMeterRegistry build() { + return new KairosMeterRegistry(config, clock, threadFactory, httpClient); + } + } } diff --git a/implementations/micrometer-registry-kairos/src/main/java/io/micrometer/kairos/KairosNamingConvention.java b/implementations/micrometer-registry-kairos/src/main/java/io/micrometer/kairos/KairosNamingConvention.java index 237a0e74ff..7851278b75 100644 --- a/implementations/micrometer-registry-kairos/src/main/java/io/micrometer/kairos/KairosNamingConvention.java +++ b/implementations/micrometer-registry-kairos/src/main/java/io/micrometer/kairos/KairosNamingConvention.java @@ -1,5 +1,5 @@ /** - * Copyright 2017 Pivotal Software, Inc. + * Copyright 2018 Pivotal Software, Inc. *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ import io.micrometer.core.instrument.Meter; import io.micrometer.core.instrument.config.NamingConvention; import io.micrometer.core.instrument.util.StringEscapeUtils; +import io.micrometer.core.lang.Nullable; import java.util.regex.Pattern; @@ -25,8 +26,7 @@ * @author Anton Ilinchik */ public class KairosNamingConvention implements NamingConvention { - - private static final Pattern blacklistedChars = Pattern.compile("[{}():,=\\[\\]]"); + private static final Pattern BLACKLISTED_CHARS = Pattern.compile("[{}():,=\\[\\]]"); private final NamingConvention delegate; @@ -40,22 +40,21 @@ public KairosNamingConvention(NamingConvention delegate) { private String format(String name) { String normalized = StringEscapeUtils.escapeJson(name); - return blacklistedChars.matcher(normalized).replaceAll("_"); + return BLACKLISTED_CHARS.matcher(normalized).replaceAll("_"); } @Override - public String name(String name, Meter.Type type, String baseUnit) { - return delegate.name(format(name), type, baseUnit); + public String name(String name, Meter.Type type, @Nullable String baseUnit) { + return format(delegate.name(name, type, baseUnit)); } @Override public String tagKey(String key) { - return format(key); + return format(delegate.tagKey(key)); } @Override public String tagValue(String value) { - return format(value); + return format(delegate.tagValue(value)); } - } diff --git a/implementations/micrometer-registry-kairos/src/main/java/io/micrometer/kairos/package-info.java b/implementations/micrometer-registry-kairos/src/main/java/io/micrometer/kairos/package-info.java index d918fd2eea..f956c0978d 100644 --- a/implementations/micrometer-registry-kairos/src/main/java/io/micrometer/kairos/package-info.java +++ b/implementations/micrometer-registry-kairos/src/main/java/io/micrometer/kairos/package-info.java @@ -1,5 +1,5 @@ /** - * Copyright 2017 Pivotal Software, Inc. + * Copyright 2018 Pivotal Software, Inc. *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,4 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +@NonNullApi +@NonNullFields package io.micrometer.kairos; + +import io.micrometer.core.lang.NonNullApi; +import io.micrometer.core.lang.NonNullFields; \ No newline at end of file diff --git a/implementations/micrometer-registry-kairos/src/test/java/io/micrometer/kairos/KairosNamingConventionTest.java b/implementations/micrometer-registry-kairos/src/test/java/io/micrometer/kairos/KairosNamingConventionTest.java index 475749e768..e373308c62 100644 --- a/implementations/micrometer-registry-kairos/src/test/java/io/micrometer/kairos/KairosNamingConventionTest.java +++ b/implementations/micrometer-registry-kairos/src/test/java/io/micrometer/kairos/KairosNamingConventionTest.java @@ -24,12 +24,10 @@ * @author Anton Ilinchik */ class KairosNamingConventionTest { - private KairosNamingConvention convention = new KairosNamingConvention(); @Test - void dotNotationIsConvertedToSnakeCase() { + void defaultToSnakeCase() { assertThat(convention.name("gauge.size", Meter.Type.GAUGE)).isEqualTo("gauge_size"); } - } \ No newline at end of file diff --git a/micrometer-spring-legacy/src/main/java/io/micrometer/spring/autoconfigure/export/kairos/KairosMetricsExportAutoConfiguration.java b/micrometer-spring-legacy/src/main/java/io/micrometer/spring/autoconfigure/export/kairos/KairosMetricsExportAutoConfiguration.java index e904ee906b..0456422e4b 100644 --- a/micrometer-spring-legacy/src/main/java/io/micrometer/spring/autoconfigure/export/kairos/KairosMetricsExportAutoConfiguration.java +++ b/micrometer-spring-legacy/src/main/java/io/micrometer/spring/autoconfigure/export/kairos/KairosMetricsExportAutoConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright 2017 Pivotal Software, Inc. + * Copyright 2018 Pivotal Software, Inc. *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/micrometer-spring-legacy/src/main/java/io/micrometer/spring/autoconfigure/export/kairos/KairosProperties.java b/micrometer-spring-legacy/src/main/java/io/micrometer/spring/autoconfigure/export/kairos/KairosProperties.java index 0ab9bdf3d6..c9ff53e39e 100644 --- a/micrometer-spring-legacy/src/main/java/io/micrometer/spring/autoconfigure/export/kairos/KairosProperties.java +++ b/micrometer-spring-legacy/src/main/java/io/micrometer/spring/autoconfigure/export/kairos/KairosProperties.java @@ -1,5 +1,5 @@ /** - * Copyright 2017 Pivotal Software, Inc. + * Copyright 2018 Pivotal Software, Inc. *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,9 +27,9 @@ public class KairosProperties extends StepRegistryProperties { /** - * The host to send the metrics to + * URI to ship metrics to. */ - private String host; + private String uri; /** * The Basic Authentication username. @@ -41,12 +41,12 @@ public class KairosProperties extends StepRegistryProperties { */ private String password; - public String getHost() { - return host; + public String getUri() { + return uri; } - public void setHost(String host) { - this.host = host; + public void setUri(String uri) { + this.uri = uri; } public String getUserName() { diff --git a/micrometer-spring-legacy/src/main/java/io/micrometer/spring/autoconfigure/export/kairos/KairosPropertiesConfigAdapter.java b/micrometer-spring-legacy/src/main/java/io/micrometer/spring/autoconfigure/export/kairos/KairosPropertiesConfigAdapter.java index 83fb8a83de..496dcb1f30 100644 --- a/micrometer-spring-legacy/src/main/java/io/micrometer/spring/autoconfigure/export/kairos/KairosPropertiesConfigAdapter.java +++ b/micrometer-spring-legacy/src/main/java/io/micrometer/spring/autoconfigure/export/kairos/KairosPropertiesConfigAdapter.java @@ -1,5 +1,5 @@ /** - * Copyright 2017 Pivotal Software, Inc. + * Copyright 2018 Pivotal Software, Inc. *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,8 +30,8 @@ public KairosPropertiesConfigAdapter(KairosProperties properties) { } @Override - public String host() { - return get(KairosProperties::getHost, KairosConfig.super::host); + public String uri() { + return get(KairosProperties::getUri, KairosConfig.super::uri); } @Override diff --git a/samples/micrometer-samples-core/src/main/java/io/micrometer/core/samples/utils/SampleConfig.java b/samples/micrometer-samples-core/src/main/java/io/micrometer/core/samples/utils/SampleConfig.java index ba74bb9307..fde10e233c 100644 --- a/samples/micrometer-samples-core/src/main/java/io/micrometer/core/samples/utils/SampleConfig.java +++ b/samples/micrometer-samples-core/src/main/java/io/micrometer/core/samples/utils/SampleConfig.java @@ -22,6 +22,6 @@ public class SampleConfig { public static MeterRegistry myMonitoringSystem() { // Pick a monitoring system here to use in your samples. - return SampleRegistries.atlas(); + return SampleRegistries.kairos(); } } diff --git a/samples/micrometer-samples-core/src/main/java/io/micrometer/core/samples/utils/SampleRegistries.java b/samples/micrometer-samples-core/src/main/java/io/micrometer/core/samples/utils/SampleRegistries.java index 19feba075a..911e98bd89 100644 --- a/samples/micrometer-samples-core/src/main/java/io/micrometer/core/samples/utils/SampleRegistries.java +++ b/samples/micrometer-samples-core/src/main/java/io/micrometer/core/samples/utils/SampleRegistries.java @@ -41,6 +41,8 @@ import io.micrometer.influx.InfluxMeterRegistry; import io.micrometer.jmx.JmxConfig; import io.micrometer.jmx.JmxMeterRegistry; +import io.micrometer.kairos.KairosConfig; +import io.micrometer.kairos.KairosMeterRegistry; import io.micrometer.newrelic.NewRelicConfig; import io.micrometer.newrelic.NewRelicMeterRegistry; import io.micrometer.prometheus.PrometheusConfig; @@ -66,7 +68,9 @@ public static MeterRegistry pickOne() { public static AppOpticsMeterRegistry appOptics(String apiToken) { return new AppOpticsMeterRegistry(new AppOpticsConfig() { @Override - public String token() { return apiToken; } + public String token() { + return apiToken; + } @Override public Duration step() { @@ -436,4 +440,23 @@ public String apiToken() { } }, Clock.SYSTEM); } + + public static KairosMeterRegistry kairos() { + return new KairosMeterRegistry(new KairosConfig() { + @Override + public String get(String key) { + return null; + } + + @Override + public String uri() { + return "http://localhost:8083/api/v1/datapoints"; + } + + @Override + public Duration step() { + return Duration.ofSeconds(10); + } + }, Clock.SYSTEM); + } } diff --git a/scripts/cassandra.sh b/scripts/cassandra.sh new file mode 100755 index 0000000000..0a1bf4c90d --- /dev/null +++ b/scripts/cassandra.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +docker run --name my_cassandra -e "CASSANDRA_START_RPC=true" cassandra \ No newline at end of file diff --git a/scripts/kairosdb.sh b/scripts/kairosdb.sh new file mode 100755 index 0000000000..faf1a0e648 --- /dev/null +++ b/scripts/kairosdb.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +docker run --link my_cassandra:cassandra -e "CASSANDRA_HOST_LIST=cassandra:9160" -p 8083:8083 jimtonic/kairosdb