Change micrometer properties to use adapters
Update configuration property classes used with micrometer so that they no longer directly implement `Config` interfaces. Properties are now adapted to Config implementations independently. See gh-9970
This commit is contained in:
parent
86926bf0e5
commit
e59d70ea03
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2012-2017 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.autoconfigure.metrics.export;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for properties to config adapters.
|
||||||
|
*
|
||||||
|
* @param <T> The properties type
|
||||||
|
* @param <C> The config type
|
||||||
|
* @author Phillip Webb
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
|
public class PropertiesConfigAdapter<T, C> {
|
||||||
|
|
||||||
|
private T properties;
|
||||||
|
|
||||||
|
private C defaults;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new {@link PropertiesConfigAdapter} instance.
|
||||||
|
* @param properties the source properties
|
||||||
|
* @param defaults a config implementation providing default values
|
||||||
|
*/
|
||||||
|
public PropertiesConfigAdapter(T properties, C defaults) {
|
||||||
|
Assert.notNull(properties, "Properties must not be null");
|
||||||
|
Assert.notNull(defaults, "Defaults must not be null");
|
||||||
|
this.properties = properties;
|
||||||
|
this.defaults = defaults;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value from the properties or use a fallback from the {@code defaults}.
|
||||||
|
* @param getter the getter for the properties
|
||||||
|
* @param fallback the fallback method from the {@code defaults}
|
||||||
|
* @param <V> the value type
|
||||||
|
* @return the property or fallback value
|
||||||
|
*/
|
||||||
|
protected final <V> V get(Function<T, V> getter, Function<C, V> fallback) {
|
||||||
|
V value = getter.apply(this.properties);
|
||||||
|
return (value != null ? value : fallback.apply(this.defaults));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2012-2017 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.boot.actuate.autoconfigure.metrics.export;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base {@link ConfigurationProperties} class for configuring a metrics registry.
|
|
||||||
*
|
|
||||||
* @author Jon Schneider
|
|
||||||
* @author Andy Wilkinson
|
|
||||||
* @since 2.0.0
|
|
||||||
*/
|
|
||||||
public abstract class RegistryProperties {
|
|
||||||
|
|
||||||
private final Properties properties = new Properties();
|
|
||||||
|
|
||||||
protected abstract String prefix();
|
|
||||||
|
|
||||||
public String get(String key) {
|
|
||||||
return this.properties.getProperty(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void set(String key, Object value) {
|
|
||||||
this.properties.put(prefix() + "." + key, value.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -18,41 +18,93 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
import io.micrometer.core.instrument.spectator.step.StepRegistryConfig;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specialization of {@link RegistryProperties} for configuring a metrics registry that
|
* Base class for properties that configure a metrics registry that pushes aggregated
|
||||||
* pushes aggregated metrics on a regular interval.
|
* metrics on a regular interval.
|
||||||
*
|
*
|
||||||
* @author Jon Schneider
|
* @author Jon Schneider
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
public abstract class StepRegistryProperties extends RegistryProperties
|
public abstract class StepRegistryProperties {
|
||||||
implements StepRegistryConfig {
|
|
||||||
|
/**
|
||||||
|
* The step size (reporting frequency) to use.
|
||||||
|
*/
|
||||||
|
private Duration step = Duration.ofMinutes(1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable publishing to the backend.
|
||||||
|
*/
|
||||||
|
private Boolean enabled = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The connection timeout for requests to the backend.
|
||||||
|
*/
|
||||||
|
private Duration connectTimeout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The read timeout for requests to the backend.
|
||||||
|
*/
|
||||||
|
private Duration readTimeout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of threads to use with the metrics publishing scheduler.
|
||||||
|
*/
|
||||||
|
private Integer numThreads;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of measurements per request to use for the backend. If more measurements
|
||||||
|
* are found, then multiple requests will be made.
|
||||||
|
*/
|
||||||
|
private Integer batchSize;
|
||||||
|
|
||||||
|
public Duration getStep() {
|
||||||
|
return this.step;
|
||||||
|
}
|
||||||
|
|
||||||
public void setStep(Duration step) {
|
public void setStep(Duration step) {
|
||||||
set("step", step);
|
this.step = step;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getEnabled() {
|
||||||
|
return this.enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabled(Boolean enabled) {
|
public void setEnabled(Boolean enabled) {
|
||||||
set("enabled", enabled);
|
this.enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBatchSize(Integer batchSize) {
|
public Duration getConnectTimeout() {
|
||||||
set("batchSize", batchSize);
|
return this.connectTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConnectTimeout(Duration connectTimeout) {
|
public void setConnectTimeout(Duration connectTimeout) {
|
||||||
set("connectTimeout", connectTimeout);
|
this.connectTimeout = connectTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Duration getReadTimeout() {
|
||||||
|
return this.readTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReadTimeout(Duration readTimeout) {
|
public void setReadTimeout(Duration readTimeout) {
|
||||||
set("readTimeout", readTimeout);
|
this.readTimeout = readTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getNumThreads() {
|
||||||
|
return this.numThreads;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNumThreads(Integer numThreads) {
|
public void setNumThreads(Integer numThreads) {
|
||||||
set("numThreads", numThreads);
|
this.numThreads = numThreads;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getBatchSize() {
|
||||||
|
return this.batchSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBatchSize(Integer batchSize) {
|
||||||
|
this.batchSize = batchSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2012-2017 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.autoconfigure.metrics.export;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
import io.micrometer.core.instrument.spectator.step.StepRegistryConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for {@link StepRegistryProperties} to {@link StepRegistryConfig} adapters.
|
||||||
|
*
|
||||||
|
* @param <T> The properties type
|
||||||
|
* @param <C> The config type
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Phillip Webb
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
|
public abstract class StepRegistryPropertiesConfigAdapter<T extends StepRegistryProperties, C extends StepRegistryConfig>
|
||||||
|
extends PropertiesConfigAdapter<T, C> implements StepRegistryConfig {
|
||||||
|
|
||||||
|
public StepRegistryPropertiesConfigAdapter(T properties, C defaults) {
|
||||||
|
super(properties, defaults);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String prefix() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String get(String k) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Duration step() {
|
||||||
|
return get(T::getStep, C::step);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean enabled() {
|
||||||
|
return get(T::getEnabled, C::enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Duration connectTimeout() {
|
||||||
|
return get(T::getConnectTimeout, C::connectTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Duration readTimeout() {
|
||||||
|
return get(T::getReadTimeout, C::readTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int numThreads() {
|
||||||
|
return get(T::getNumThreads, C::numThreads);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int batchSize() {
|
||||||
|
return get(T::getBatchSize, C::batchSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -43,10 +43,16 @@ import org.springframework.context.annotation.Import;
|
||||||
@EnableConfigurationProperties(AtlasProperties.class)
|
@EnableConfigurationProperties(AtlasProperties.class)
|
||||||
public class AtlasExportConfiguration {
|
public class AtlasExportConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean(AtlasConfig.class)
|
||||||
|
public AtlasConfig atlasConfig(AtlasProperties atlasProperties) {
|
||||||
|
return new AtlasPropertiesConfigAdapter(atlasProperties);
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(value = "spring.metrics.atlas.enabled", matchIfMissing = true)
|
@ConditionalOnProperty(value = "spring.metrics.atlas.enabled", matchIfMissing = true)
|
||||||
public MetricsExporter atlasExporter(AtlasConfig config, Clock clock) {
|
public MetricsExporter atlasExporter(AtlasConfig atlasConfig, Clock clock) {
|
||||||
return () -> new AtlasMeterRegistry(config, clock);
|
return () -> new AtlasMeterRegistry(atlasConfig, clock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,7 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.atlas;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
import com.netflix.spectator.atlas.AtlasConfig;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.StepRegistryProperties;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.RegistryProperties;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -30,63 +28,97 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
* @author Jon Schneider
|
* @author Jon Schneider
|
||||||
*/
|
*/
|
||||||
@ConfigurationProperties(prefix = "spring.metrics.atlas")
|
@ConfigurationProperties(prefix = "spring.metrics.atlas")
|
||||||
public class AtlasProperties extends RegistryProperties implements AtlasConfig {
|
public class AtlasProperties extends StepRegistryProperties {
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
protected String prefix() {
|
* The URI for the Atlas backend.
|
||||||
return "spring.metrics.atlas";
|
*/
|
||||||
}
|
private String uri;
|
||||||
|
|
||||||
public void setStep(Duration step) {
|
/**
|
||||||
set("step", step);
|
* The TTL for meters that do not have any activity. After this period the meter will
|
||||||
}
|
* be considered expired and will not get reported.
|
||||||
|
*/
|
||||||
|
private Duration meterTimeToLive;
|
||||||
|
|
||||||
public void setMeterTTL(Duration meterTTL) {
|
/**
|
||||||
set("meterTTL", meterTTL);
|
* Enable streaming to Atlas LWC.
|
||||||
}
|
*/
|
||||||
|
private Boolean lwcEnabled;
|
||||||
|
|
||||||
public void setEnabled(Boolean enabled) {
|
/**
|
||||||
set("enabled", enabled);
|
* The frequency for refreshing config settings from the LWC service.
|
||||||
}
|
*/
|
||||||
|
private Duration configRefreshFrequency;
|
||||||
|
|
||||||
public void setNumThreads(Integer numThreads) {
|
/**
|
||||||
set("numThreads", numThreads);
|
* The TTL for subscriptions from the LWC service.
|
||||||
|
*/
|
||||||
|
private Duration configTimeToLive;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The URI for the Atlas LWC endpoint to retrieve current subscriptions.
|
||||||
|
*/
|
||||||
|
private String configUri;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The URI for the Atlas LWC endpoint to evaluate the data for a subscription.
|
||||||
|
*/
|
||||||
|
private String evalUri;
|
||||||
|
|
||||||
|
public String getUri() {
|
||||||
|
return this.uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUri(String uri) {
|
public void setUri(String uri) {
|
||||||
set("uri", uri);
|
this.uri = uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLwcEnabled(boolean lwcEnabled) {
|
public Duration getMeterTimeToLive() {
|
||||||
set("lwcEnabled", lwcEnabled);
|
return this.meterTimeToLive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMeterTimeToLive(Duration meterTimeToLive) {
|
||||||
|
this.meterTimeToLive = meterTimeToLive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getLwcEnabled() {
|
||||||
|
return this.lwcEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLwcEnabled(Boolean lwcEnabled) {
|
||||||
|
this.lwcEnabled = lwcEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Duration getConfigRefreshFrequency() {
|
||||||
|
return this.configRefreshFrequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConfigRefreshFrequency(Duration configRefreshFrequency) {
|
public void setConfigRefreshFrequency(Duration configRefreshFrequency) {
|
||||||
set("configRefreshFrequency", configRefreshFrequency);
|
this.configRefreshFrequency = configRefreshFrequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConfigTTL(Duration configTTL) {
|
public Duration getConfigTimeToLive() {
|
||||||
set("configTTL", configTTL);
|
return this.configTimeToLive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfigTimeToLive(Duration configTimeToLive) {
|
||||||
|
this.configTimeToLive = configTimeToLive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConfigUri() {
|
||||||
|
return this.configUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConfigUri(String configUri) {
|
public void setConfigUri(String configUri) {
|
||||||
set("configUri", configUri);
|
this.configUri = configUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEvalUri() {
|
||||||
|
return this.evalUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEvalUri(String evalUri) {
|
public void setEvalUri(String evalUri) {
|
||||||
set("evalUri", evalUri);
|
this.evalUri = evalUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConnectTimeout(Duration connectTimeout) {
|
|
||||||
set("connectTimeout", connectTimeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReadTimeout(Duration readTimeout) {
|
|
||||||
set("readTimeout", readTimeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBatchSize(Integer batchSize) {
|
|
||||||
set("batchSize", batchSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,111 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2012-2017 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.atlas;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
import com.netflix.spectator.atlas.AtlasConfig;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.PropertiesConfigAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adapter to convert {@link AtlasProperties} to an {@link AtlasConfig}.
|
||||||
|
*
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Phillip Webb
|
||||||
|
*/
|
||||||
|
class AtlasPropertiesConfigAdapter extends
|
||||||
|
PropertiesConfigAdapter<AtlasProperties, AtlasConfig> implements AtlasConfig {
|
||||||
|
|
||||||
|
private static final AtlasConfig DEFAUTLS = (k) -> null;
|
||||||
|
|
||||||
|
AtlasPropertiesConfigAdapter(AtlasProperties properties) {
|
||||||
|
super(properties, DEFAUTLS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String get(String key) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Duration step() {
|
||||||
|
return get(AtlasProperties::getStep, AtlasConfig::step);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean enabled() {
|
||||||
|
return get(AtlasProperties::getEnabled, AtlasConfig::enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Duration connectTimeout() {
|
||||||
|
return get(AtlasProperties::getConnectTimeout, AtlasConfig::connectTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Duration readTimeout() {
|
||||||
|
return get(AtlasProperties::getReadTimeout, AtlasConfig::readTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int numThreads() {
|
||||||
|
return get(AtlasProperties::getNumThreads, AtlasConfig::numThreads);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int batchSize() {
|
||||||
|
return get(AtlasProperties::getBatchSize, AtlasConfig::batchSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String uri() {
|
||||||
|
return get(AtlasProperties::getUri, AtlasConfig::uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Duration meterTTL() {
|
||||||
|
return get(AtlasProperties::getMeterTimeToLive, AtlasConfig::meterTTL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean lwcEnabled() {
|
||||||
|
return get(AtlasProperties::getLwcEnabled, AtlasConfig::lwcEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Duration configRefreshFrequency() {
|
||||||
|
return get(AtlasProperties::getConfigRefreshFrequency,
|
||||||
|
AtlasConfig::configRefreshFrequency);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Duration configTTL() {
|
||||||
|
return get(AtlasProperties::getConfigTimeToLive, AtlasConfig::configTTL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String configUri() {
|
||||||
|
return get(AtlasProperties::getConfigUri, AtlasConfig::configUri);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String evalUri() {
|
||||||
|
return get(AtlasProperties::getEvalUri, AtlasConfig::evalUri);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -38,14 +38,21 @@ import org.springframework.context.annotation.Import;
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnClass(DatadogMeterRegistry.class)
|
@ConditionalOnClass(DatadogMeterRegistry.class)
|
||||||
|
@ConditionalOnProperty("spring.metrics.datadog.api-key")
|
||||||
@Import(StringToDurationConverter.class)
|
@Import(StringToDurationConverter.class)
|
||||||
@EnableConfigurationProperties(DatadogProperties.class)
|
@EnableConfigurationProperties(DatadogProperties.class)
|
||||||
public class DatadogExportConfiguration {
|
public class DatadogExportConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
public DatadogConfig datadogConfig(DatadogProperties datadogProperties) {
|
||||||
|
return new DatadogPropertiesConfigAdapter(datadogProperties);
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(value = "spring.metrics.datadog.enabled", matchIfMissing = true)
|
@ConditionalOnProperty(value = "spring.metrics.datadog.enabled", matchIfMissing = true)
|
||||||
public MetricsExporter datadogExporter(DatadogConfig config, Clock clock) {
|
public MetricsExporter datadogExporter(DatadogConfig datadogConfig, Clock clock) {
|
||||||
return () -> new DatadogMeterRegistry(config, clock);
|
return () -> new DatadogMeterRegistry(datadogConfig, clock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.datadog;
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.datadog;
|
||||||
|
|
||||||
import io.micrometer.datadog.DatadogConfig;
|
import java.time.Duration;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.StepRegistryProperties;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.StepRegistryProperties;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
@ -28,23 +28,63 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
@ConfigurationProperties(prefix = "spring.metrics.datadog")
|
@ConfigurationProperties(prefix = "spring.metrics.datadog")
|
||||||
public class DatadogProperties extends StepRegistryProperties implements DatadogConfig {
|
public class DatadogProperties extends StepRegistryProperties {
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public String prefix() {
|
* Your API key, found in your account settings at datadoghq. This property is
|
||||||
return "spring.metrics.datadog";
|
* required.
|
||||||
}
|
*/
|
||||||
|
private String apiKey;
|
||||||
|
|
||||||
public DatadogProperties() {
|
/**
|
||||||
set("apiKey", "dummyKey"); // FIXME otherwise tests fail
|
* The tag that will be mapped to "host" when shipping metrics to datadog, or
|
||||||
|
* {@code null} if host should be omitted on publishing.
|
||||||
|
*/
|
||||||
|
private String hostTag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The bucket filter clamping the bucket domain of timer percentiles histograms to
|
||||||
|
* some max value. This is used to limit the number of buckets shipped to Prometheus
|
||||||
|
* to save on storage.
|
||||||
|
*/
|
||||||
|
private Duration timerPercentilesMax = Duration.ofMinutes(2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The bucket filter clamping the bucket domain of timer percentiles histograms to
|
||||||
|
* some min value. This is used to limit the number of buckets shipped to Prometheus
|
||||||
|
* to save on storage.
|
||||||
|
*/
|
||||||
|
private Duration timerPercentilesMin = Duration.ofMillis(10);
|
||||||
|
|
||||||
|
public String getApiKey() {
|
||||||
|
return this.apiKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setApiKey(String apiKey) {
|
public void setApiKey(String apiKey) {
|
||||||
set("apiKey", apiKey);
|
this.apiKey = apiKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHostTag(String hostTag) {
|
public String getHostTag() {
|
||||||
set("hostTag", hostTag);
|
return this.hostTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setHostKey(String hostKey) {
|
||||||
|
this.hostTag = hostKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Duration getTimerPercentilesMax() {
|
||||||
|
return this.timerPercentilesMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimerPercentilesMax(Duration timerPercentilesMax) {
|
||||||
|
this.timerPercentilesMax = timerPercentilesMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Duration getTimerPercentilesMin() {
|
||||||
|
return this.timerPercentilesMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimerPercentilesMin(Duration timerPercentilesMin) {
|
||||||
|
this.timerPercentilesMin = timerPercentilesMin;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2012-2017 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.datadog;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
import io.micrometer.datadog.DatadogConfig;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.StepRegistryPropertiesConfigAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adapter to convert {@link DatadogProperties} to a {@link DatadogConfig}.
|
||||||
|
*
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Phillip Webb
|
||||||
|
*/
|
||||||
|
class DatadogPropertiesConfigAdapter
|
||||||
|
extends StepRegistryPropertiesConfigAdapter<DatadogProperties, DatadogConfig>
|
||||||
|
implements DatadogConfig {
|
||||||
|
|
||||||
|
private static final DatadogConfig DEFAULTS = (k) -> null;
|
||||||
|
|
||||||
|
DatadogPropertiesConfigAdapter(DatadogProperties properties) {
|
||||||
|
super(properties, DEFAULTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apiKey() {
|
||||||
|
return get(DatadogProperties::getApiKey, DatadogConfig::apiKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String hostTag() {
|
||||||
|
return get(DatadogProperties::getHostTag, DatadogConfig::hostTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Duration timerPercentilesMax() {
|
||||||
|
return get(DatadogProperties::getTimerPercentilesMax,
|
||||||
|
DatadogConfig::timerPercentilesMax);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Duration timerPercentilesMin() {
|
||||||
|
return get(DatadogProperties::getTimerPercentilesMin,
|
||||||
|
DatadogConfig::timerPercentilesMin);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -43,11 +43,17 @@ import org.springframework.context.annotation.Import;
|
||||||
@EnableConfigurationProperties(GangliaProperties.class)
|
@EnableConfigurationProperties(GangliaProperties.class)
|
||||||
public class GangliaExportConfiguration {
|
public class GangliaExportConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
public GangliaConfig gangliaConfig(GangliaProperties gangliaProperties) {
|
||||||
|
return new GangliaPropertiesConfigAdapter(gangliaProperties);
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(value = "spring.metrics.ganglia.enabled", matchIfMissing = true)
|
@ConditionalOnProperty(value = "spring.metrics.ganglia.enabled", matchIfMissing = true)
|
||||||
public MetricsExporter gangliaExporter(GangliaConfig config,
|
public MetricsExporter gangliaExporter(GangliaConfig gangliaConfig,
|
||||||
HierarchicalNameMapper nameMapper, Clock clock) {
|
HierarchicalNameMapper nameMapper, Clock clock) {
|
||||||
return () -> new GangliaMeterRegistry(config, nameMapper, clock);
|
return () -> new GangliaMeterRegistry(gangliaConfig, nameMapper, clock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,7 @@ import java.time.Duration;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import info.ganglia.gmetric4j.gmetric.GMetric;
|
import info.ganglia.gmetric4j.gmetric.GMetric;
|
||||||
import io.micrometer.ganglia.GangliaConfig;
|
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.RegistryProperties;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -32,47 +30,123 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
@ConfigurationProperties(prefix = "spring.metrics.ganglia")
|
@ConfigurationProperties(prefix = "spring.metrics.ganglia")
|
||||||
public class GangliaProperties extends RegistryProperties implements GangliaConfig {
|
public class GangliaProperties {
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public String prefix() {
|
* Enable publishing to the backend.
|
||||||
return "spring.metrics.ganglia";
|
*/
|
||||||
}
|
private Boolean enabled = true;
|
||||||
|
|
||||||
public void setStep(Duration step) {
|
/**
|
||||||
set("step", step);
|
* The step size (reporting frequency) to use.
|
||||||
}
|
*/
|
||||||
|
private Duration step = Duration.ofMinutes(1);
|
||||||
|
|
||||||
public void setRateUnits(TimeUnit rateUnits) {
|
/**
|
||||||
set("rateUnits", rateUnits);
|
* The base time unit used to report rates.
|
||||||
}
|
*/
|
||||||
|
private TimeUnit rateUnits;
|
||||||
|
|
||||||
public void setDurationUnits(TimeUnit durationUnits) {
|
/**
|
||||||
set("durationUnits", durationUnits);
|
* The base time unit used to report durations.
|
||||||
}
|
*/
|
||||||
|
private TimeUnit durationUnits;
|
||||||
|
|
||||||
public void setProtocolVersion(String protocolVersion) {
|
/**
|
||||||
set("protocolVersion", protocolVersion);
|
* Ganglia protocol version. Must be either 3.1 or 3.0.
|
||||||
}
|
*/
|
||||||
|
private String protocolVersion;
|
||||||
|
|
||||||
public void setAddressingMode(GMetric.UDPAddressingMode addressingMode) {
|
/**
|
||||||
set("addressingMode", addressingMode);
|
* The UDP addressing mode, either unicast or multicast.
|
||||||
}
|
*/
|
||||||
|
private GMetric.UDPAddressingMode addressingMode;
|
||||||
|
|
||||||
public void setTtl(Integer ttl) {
|
/**
|
||||||
set("ttl", ttl);
|
* The TTL for metrics on Ganglia.
|
||||||
}
|
*/
|
||||||
|
private Integer timeToLive;
|
||||||
|
|
||||||
public void setHost(String host) {
|
/**
|
||||||
set("host", host);
|
* Ganglia host used for publishing.
|
||||||
}
|
*/
|
||||||
|
private String host;
|
||||||
|
|
||||||
public void setPort(Integer port) {
|
/**
|
||||||
set("port", port);
|
* Ganglia port used for publishing.
|
||||||
|
*/
|
||||||
|
private Integer port;
|
||||||
|
|
||||||
|
public Boolean getEnabled() {
|
||||||
|
return this.enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabled(Boolean enabled) {
|
public void setEnabled(Boolean enabled) {
|
||||||
set("enabled", enabled);
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Duration getStep() {
|
||||||
|
return this.step;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStep(Duration step) {
|
||||||
|
this.step = step;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimeUnit getRateUnits() {
|
||||||
|
return this.rateUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRateUnits(TimeUnit rateUnits) {
|
||||||
|
this.rateUnits = rateUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimeUnit getDurationUnits() {
|
||||||
|
return this.durationUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDurationUnits(TimeUnit durationUnits) {
|
||||||
|
this.durationUnits = durationUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProtocolVersion() {
|
||||||
|
return this.protocolVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProtocolVersion(String protocolVersion) {
|
||||||
|
this.protocolVersion = protocolVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMetric.UDPAddressingMode getAddressingMode() {
|
||||||
|
return this.addressingMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddressingMode(GMetric.UDPAddressingMode addressingMode) {
|
||||||
|
this.addressingMode = addressingMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getTimeToLive() {
|
||||||
|
return this.timeToLive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeToLive(Integer timeToLive) {
|
||||||
|
this.timeToLive = timeToLive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHost() {
|
||||||
|
return this.host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHost(String host) {
|
||||||
|
this.host = host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPort() {
|
||||||
|
return this.port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPort(Integer port) {
|
||||||
|
this.port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2012-2017 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.ganglia;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import info.ganglia.gmetric4j.gmetric.GMetric;
|
||||||
|
import io.micrometer.ganglia.GangliaConfig;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.PropertiesConfigAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adapter to convert {@link GangliaProperties} to a {@link GangliaConfig}.
|
||||||
|
*
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Phillip Webb
|
||||||
|
*/
|
||||||
|
class GangliaPropertiesConfigAdapter
|
||||||
|
extends PropertiesConfigAdapter<GangliaProperties, GangliaConfig>
|
||||||
|
implements GangliaConfig {
|
||||||
|
|
||||||
|
private static final GangliaConfig DEFAULTS = (k) -> null;
|
||||||
|
|
||||||
|
GangliaPropertiesConfigAdapter(GangliaProperties properties) {
|
||||||
|
super(properties, DEFAULTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String get(String k) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean enabled() {
|
||||||
|
return get(GangliaProperties::getEnabled, GangliaConfig::enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Duration step() {
|
||||||
|
return get(GangliaProperties::getStep, GangliaConfig::step);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TimeUnit rateUnits() {
|
||||||
|
return get(GangliaProperties::getRateUnits, GangliaConfig::rateUnits);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TimeUnit durationUnits() {
|
||||||
|
return get(GangliaProperties::getDurationUnits, GangliaConfig::durationUnits);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String protocolVersion() {
|
||||||
|
return get(GangliaProperties::getProtocolVersion, GangliaConfig::protocolVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GMetric.UDPAddressingMode addressingMode() {
|
||||||
|
return get(GangliaProperties::getAddressingMode, GangliaConfig::addressingMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int ttl() {
|
||||||
|
return get(GangliaProperties::getTimeToLive, GangliaConfig::ttl);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String host() {
|
||||||
|
return get(GangliaProperties::getHost, GangliaConfig::host);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int port() {
|
||||||
|
return get(GangliaProperties::getPort, GangliaConfig::port);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -43,11 +43,17 @@ import org.springframework.context.annotation.Import;
|
||||||
@EnableConfigurationProperties(GraphiteProperties.class)
|
@EnableConfigurationProperties(GraphiteProperties.class)
|
||||||
public class GraphiteExportConfiguration {
|
public class GraphiteExportConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
public GraphiteConfig graphiteConfig(GraphiteProperties graphiteProperties) {
|
||||||
|
return new GraphitePropertiesConfigAdapter(graphiteProperties);
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(value = "spring.metrics.graphite.enabled", matchIfMissing = true)
|
@ConditionalOnProperty(value = "spring.metrics.graphite.enabled", matchIfMissing = true)
|
||||||
public MetricsExporter graphiteExporter(GraphiteConfig config,
|
public MetricsExporter graphiteExporter(GraphiteConfig graphiteConfig,
|
||||||
HierarchicalNameMapper nameMapper, Clock clock) {
|
HierarchicalNameMapper nameMapper, Clock clock) {
|
||||||
return () -> new GraphiteMeterRegistry(config, nameMapper, clock);
|
return () -> new GraphiteMeterRegistry(graphiteConfig, nameMapper, clock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,6 @@ package org.springframework.boot.actuate.autoconfigure.metrics.export.graphite;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import io.micrometer.graphite.GraphiteConfig;
|
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.RegistryProperties;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -31,35 +28,82 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
@ConfigurationProperties(prefix = "spring.metrics.graphite")
|
@ConfigurationProperties(prefix = "spring.metrics.graphite")
|
||||||
public class GraphiteProperties extends RegistryProperties implements GraphiteConfig {
|
public class GraphiteProperties {
|
||||||
|
/**
|
||||||
|
* Enable publishing to the backend.
|
||||||
|
*/
|
||||||
|
private Boolean enabled = true;
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public String prefix() {
|
* The step size (reporting frequency) to use.
|
||||||
return "spring.metrics.graphite";
|
*/
|
||||||
}
|
private Duration step = Duration.ofMinutes(1);
|
||||||
|
|
||||||
public void setStep(Duration step) {
|
/**
|
||||||
set("step", step);
|
* The base time unit used to report rates.
|
||||||
}
|
*/
|
||||||
|
private TimeUnit rateUnits;
|
||||||
|
|
||||||
public void setRateUnits(TimeUnit rateUnits) {
|
/**
|
||||||
set("rateUnits", rateUnits);
|
* The base time unit used to report durations.
|
||||||
}
|
*/
|
||||||
|
private TimeUnit durationUnits;
|
||||||
|
|
||||||
public void setDurationUnits(TimeUnit durationUnits) {
|
/**
|
||||||
set("durationUnits", durationUnits);
|
* Graphite host used for publishing.
|
||||||
}
|
*/
|
||||||
|
private String host;
|
||||||
|
|
||||||
public void setHost(String host) {
|
/**
|
||||||
set("host", host);
|
* Graphite port used for publishing.
|
||||||
}
|
*/
|
||||||
|
private Integer port;
|
||||||
|
|
||||||
public void setPort(Integer port) {
|
public Boolean getEnabled() {
|
||||||
set("port", port);
|
return this.enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabled(Boolean enabled) {
|
public void setEnabled(Boolean enabled) {
|
||||||
set("enabled", enabled);
|
this.enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Duration getStep() {
|
||||||
|
return this.step;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStep(Duration step) {
|
||||||
|
this.step = step;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimeUnit getRateUnits() {
|
||||||
|
return this.rateUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRateUnits(TimeUnit rateUnits) {
|
||||||
|
this.rateUnits = rateUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimeUnit getDurationUnits() {
|
||||||
|
return this.durationUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDurationUnits(TimeUnit durationUnits) {
|
||||||
|
this.durationUnits = durationUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHost() {
|
||||||
|
return this.host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHost(String host) {
|
||||||
|
this.host = host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPort() {
|
||||||
|
return this.port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPort(Integer port) {
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2012-2017 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.graphite;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import io.micrometer.graphite.GraphiteConfig;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.PropertiesConfigAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adapter to convert {@link GraphiteProperties} to a {@link GraphiteConfig}.
|
||||||
|
*
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Phillip Webb
|
||||||
|
*/
|
||||||
|
class GraphitePropertiesConfigAdapter
|
||||||
|
extends PropertiesConfigAdapter<GraphiteProperties, GraphiteConfig>
|
||||||
|
implements GraphiteConfig {
|
||||||
|
|
||||||
|
private static final GraphiteConfig DEFAULTS = (k) -> null;
|
||||||
|
|
||||||
|
GraphitePropertiesConfigAdapter(GraphiteProperties properties) {
|
||||||
|
super(properties, DEFAULTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String get(String k) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean enabled() {
|
||||||
|
return get(GraphiteProperties::getEnabled, GraphiteConfig::enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Duration step() {
|
||||||
|
return get(GraphiteProperties::getStep, GraphiteConfig::step);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TimeUnit rateUnits() {
|
||||||
|
return get(GraphiteProperties::getRateUnits, GraphiteConfig::rateUnits);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TimeUnit durationUnits() {
|
||||||
|
return get(GraphiteProperties::getDurationUnits, GraphiteConfig::durationUnits);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String host() {
|
||||||
|
return get(GraphiteProperties::getHost, GraphiteConfig::host);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int port() {
|
||||||
|
return get(GraphiteProperties::getPort, GraphiteConfig::port);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -42,10 +42,16 @@ import org.springframework.context.annotation.Import;
|
||||||
@EnableConfigurationProperties(InfluxProperties.class)
|
@EnableConfigurationProperties(InfluxProperties.class)
|
||||||
public class InfluxExportConfiguration {
|
public class InfluxExportConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean(InfluxConfig.class)
|
||||||
|
public InfluxConfig influxConfig(InfluxProperties influxProperties) {
|
||||||
|
return new InfluxPropertiesConfigAdapter(influxProperties);
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(value = "spring.metrics.influx.enabled", matchIfMissing = true)
|
@ConditionalOnProperty(value = "spring.metrics.influx.enabled", matchIfMissing = true)
|
||||||
public MetricsExporter influxExporter(InfluxConfig config, Clock clock) {
|
public MetricsExporter influxExporter(InfluxConfig influxConfig, Clock clock) {
|
||||||
return () -> new InfluxMeterRegistry(config, clock);
|
return () -> new InfluxMeterRegistry(influxConfig, clock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,8 @@
|
||||||
|
|
||||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.influx;
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.influx;
|
||||||
|
|
||||||
import io.micrometer.influx.InfluxConfig;
|
import java.time.Duration;
|
||||||
|
|
||||||
import io.micrometer.influx.InfluxConsistency;
|
import io.micrometer.influx.InfluxConsistency;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.StepRegistryProperties;
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.StepRegistryProperties;
|
||||||
|
|
@ -29,39 +30,127 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
@ConfigurationProperties(prefix = "spring.metrics.influx")
|
@ConfigurationProperties(prefix = "spring.metrics.influx")
|
||||||
public class InfluxProperties extends StepRegistryProperties implements InfluxConfig {
|
public class InfluxProperties extends StepRegistryProperties {
|
||||||
|
/**
|
||||||
|
* The tag that will be mapped to "host" when shipping metrics to Influx, or
|
||||||
|
* {@code null} if host should be omitted on publishing.
|
||||||
|
*/
|
||||||
|
private String db;
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public String prefix() {
|
* The write consistency for each point.
|
||||||
return "spring.metrics.influx";
|
*/
|
||||||
|
private InfluxConsistency consistency;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authenticate requests with this user. If not specified, the registry will not
|
||||||
|
* attempt to present credentials to Influx.
|
||||||
|
*/
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authenticate requests with this password.
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Influx writes to the DEFAULT retention policy if one is not specified.
|
||||||
|
*/
|
||||||
|
private String retentionPolicy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The URI for the Influx backend.
|
||||||
|
*/
|
||||||
|
private String uri;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable GZIP compression of metrics batches published to Influx.
|
||||||
|
*/
|
||||||
|
private Boolean compressed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The bucket filter clamping the bucket domain of timer percentiles histograms to
|
||||||
|
* some max value. This is used to limit the number of buckets shipped to Prometheus
|
||||||
|
* to save on storage.
|
||||||
|
*/
|
||||||
|
private Duration timerPercentilesMax = Duration.ofMinutes(2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The bucket filter clamping the bucket domain of timer percentiles histograms to
|
||||||
|
* some min value. This is used to limit the number of buckets shipped to Prometheus
|
||||||
|
* to save on storage.
|
||||||
|
*/
|
||||||
|
private Duration timerPercentilesMin = Duration.ofMillis(10);
|
||||||
|
|
||||||
|
public String getDb() {
|
||||||
|
return this.db;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDb(String db) {
|
public void setDb(String db) {
|
||||||
set("db", db);
|
this.db = db;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InfluxConsistency getConsistency() {
|
||||||
|
return this.consistency;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConsistency(InfluxConsistency consistency) {
|
public void setConsistency(InfluxConsistency consistency) {
|
||||||
set("consistency", consistency);
|
this.consistency = consistency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserName() {
|
||||||
|
return this.userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserName(String userName) {
|
public void setUserName(String userName) {
|
||||||
set("userName", userName);
|
this.userName = userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return this.password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPassword(String password) {
|
public void setPassword(String password) {
|
||||||
set("password", password);
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRetentionPolicy() {
|
||||||
|
return this.retentionPolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRetentionPolicy(String retentionPolicy) {
|
public void setRetentionPolicy(String retentionPolicy) {
|
||||||
set("retentionPolicy", retentionPolicy);
|
this.retentionPolicy = retentionPolicy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUri() {
|
||||||
|
return this.uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUri(String uri) {
|
public void setUri(String uri) {
|
||||||
set("uri", uri);
|
this.uri = uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getCompressed() {
|
||||||
|
return this.compressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCompressed(Boolean compressed) {
|
public void setCompressed(Boolean compressed) {
|
||||||
set("compressed", compressed);
|
this.compressed = compressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Duration getTimerPercentilesMax() {
|
||||||
|
return this.timerPercentilesMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimerPercentilesMax(Duration timerPercentilesMax) {
|
||||||
|
this.timerPercentilesMax = timerPercentilesMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Duration getTimerPercentilesMin() {
|
||||||
|
return this.timerPercentilesMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimerPercentilesMin(Duration timerPercentilesMin) {
|
||||||
|
this.timerPercentilesMin = timerPercentilesMin;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2012-2017 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.influx;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
import io.micrometer.influx.InfluxConfig;
|
||||||
|
import io.micrometer.influx.InfluxConsistency;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.StepRegistryPropertiesConfigAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adapter to convert {@link InfluxProperties} to an {@link InfluxConfig}.
|
||||||
|
*
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Phillip Webb
|
||||||
|
*/
|
||||||
|
class InfluxPropertiesConfigAdapter
|
||||||
|
extends StepRegistryPropertiesConfigAdapter<InfluxProperties, InfluxConfig>
|
||||||
|
implements InfluxConfig {
|
||||||
|
|
||||||
|
private static final InfluxConfig DEFAULTS = (k) -> null;
|
||||||
|
|
||||||
|
InfluxPropertiesConfigAdapter(InfluxProperties properties) {
|
||||||
|
super(properties, DEFAULTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String db() {
|
||||||
|
return get(InfluxProperties::getDb, InfluxConfig::db);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InfluxConsistency consistency() {
|
||||||
|
return get(InfluxProperties::getConsistency, InfluxConfig::consistency);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String userName() {
|
||||||
|
return get(InfluxProperties::getUserName, InfluxConfig::userName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String password() {
|
||||||
|
return get(InfluxProperties::getPassword, InfluxConfig::password);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String retentionPolicy() {
|
||||||
|
return get(InfluxProperties::getRetentionPolicy, InfluxConfig::retentionPolicy);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String uri() {
|
||||||
|
return get(InfluxProperties::getUri, InfluxConfig::uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean compressed() {
|
||||||
|
return get(InfluxProperties::getCompressed, InfluxConfig::compressed);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Duration timerPercentilesMax() {
|
||||||
|
return get(InfluxProperties::getTimerPercentilesMax,
|
||||||
|
InfluxConfig::timerPercentilesMax);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Duration timerPercentilesMin() {
|
||||||
|
return get(InfluxProperties::getTimerPercentilesMin,
|
||||||
|
InfluxConfig::timerPercentilesMin);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -42,11 +42,18 @@ import org.springframework.context.annotation.Configuration;
|
||||||
@EnableConfigurationProperties(PrometheusProperties.class)
|
@EnableConfigurationProperties(PrometheusProperties.class)
|
||||||
public class PrometheusExportConfiguration {
|
public class PrometheusExportConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
public PrometheusConfig prometheusConfig(PrometheusProperties prometheusProperties) {
|
||||||
|
return new PrometheusPropertiesConfigAdapter(prometheusProperties);
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(value = "spring.metrics.prometheus.enabled", matchIfMissing = true)
|
@ConditionalOnProperty(value = "spring.metrics.prometheus.enabled", matchIfMissing = true)
|
||||||
public MetricsExporter prometheusExporter(PrometheusConfig config,
|
public MetricsExporter prometheusExporter(PrometheusConfig prometheusConfig,
|
||||||
CollectorRegistry collectorRegistry, Clock clock) {
|
CollectorRegistry collectorRegistry, Clock clock) {
|
||||||
return () -> new PrometheusMeterRegistry(config, collectorRegistry, clock);
|
return () -> new PrometheusMeterRegistry(prometheusConfig, collectorRegistry,
|
||||||
|
clock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,8 @@
|
||||||
|
|
||||||
package org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus;
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus;
|
||||||
|
|
||||||
import io.micrometer.prometheus.PrometheusConfig;
|
import java.time.Duration;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.RegistryProperties;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -28,25 +27,63 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
@ConfigurationProperties(prefix = "spring.metrics.prometheus")
|
@ConfigurationProperties(prefix = "spring.metrics.prometheus")
|
||||||
public class PrometheusProperties extends RegistryProperties implements PrometheusConfig {
|
public class PrometheusProperties {
|
||||||
|
|
||||||
private boolean enabled = true;
|
/**
|
||||||
|
* Enable publishing to Prometheus.
|
||||||
|
*/
|
||||||
|
private Boolean enabled = true;
|
||||||
|
|
||||||
public boolean isEnabled() {
|
/**
|
||||||
|
* Enable publishing descriptions as part of the scrape payload to Prometheus. Turn
|
||||||
|
* this off to minimize the amount of data sent on each scrape.
|
||||||
|
*/
|
||||||
|
private Boolean descriptions = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The bucket filter clamping the bucket domain of timer percentiles histograms to
|
||||||
|
* some max value. This is used to limit the number of buckets shipped to Prometheus
|
||||||
|
* to save on storage.
|
||||||
|
*/
|
||||||
|
private Duration timerPercentilesMax = Duration.ofMinutes(2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The bucket filter clamping the bucket domain of timer percentiles histograms to
|
||||||
|
* some min value. This is used to limit the number of buckets shipped to Prometheus
|
||||||
|
* to save on storage.
|
||||||
|
*/
|
||||||
|
private Duration timerPercentilesMin = Duration.ofMillis(10);
|
||||||
|
|
||||||
|
public Boolean getEnabled() {
|
||||||
return this.enabled;
|
return this.enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabled(boolean enabled) {
|
public void setEnabled(Boolean enabled) {
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescriptions(Boolean descriptions) {
|
public Boolean getDescriptions() {
|
||||||
set("descriptions", descriptions);
|
return this.descriptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setDescriptions(Boolean descriptions) {
|
||||||
public String prefix() {
|
this.descriptions = descriptions;
|
||||||
return "spring.metrics.prometheus";
|
}
|
||||||
|
|
||||||
|
public Duration getTimerPercentilesMax() {
|
||||||
|
return this.timerPercentilesMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimerPercentilesMax(Duration timerPercentilesMax) {
|
||||||
|
this.timerPercentilesMax = timerPercentilesMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Duration getTimerPercentilesMin() {
|
||||||
|
return this.timerPercentilesMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimerPercentilesMin(Duration timerPercentilesMin) {
|
||||||
|
this.timerPercentilesMin = timerPercentilesMin;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2012-2017 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
import io.micrometer.prometheus.PrometheusConfig;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.PropertiesConfigAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adapter to convert {@link PrometheusProperties} to a {@link PrometheusConfig}.
|
||||||
|
*
|
||||||
|
* @author Jon Schneider
|
||||||
|
* @author Phillip Webb
|
||||||
|
*/
|
||||||
|
class PrometheusPropertiesConfigAdapter
|
||||||
|
extends PropertiesConfigAdapter<PrometheusProperties, PrometheusConfig>
|
||||||
|
implements PrometheusConfig {
|
||||||
|
|
||||||
|
private static final PrometheusConfig DEFAULTS = (key) -> null;
|
||||||
|
|
||||||
|
PrometheusPropertiesConfigAdapter(PrometheusProperties properties) {
|
||||||
|
super(properties, DEFAULTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String get(String key) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean descriptions() {
|
||||||
|
return get(PrometheusProperties::getDescriptions, PrometheusConfig::descriptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Duration timerPercentilesMin() {
|
||||||
|
return get(PrometheusProperties::getTimerPercentilesMin,
|
||||||
|
PrometheusConfig::timerPercentilesMin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Duration timerPercentilesMax() {
|
||||||
|
return get(PrometheusProperties::getTimerPercentilesMax,
|
||||||
|
PrometheusConfig::timerPercentilesMax);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue