This commit is contained in:
Phillip Webb 2015-07-08 12:01:19 -07:00
parent 9cb2a09680
commit 5938c967a3
4 changed files with 51 additions and 47 deletions

View File

@ -45,6 +45,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.context.annotation.Conditional;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
@ -170,20 +171,22 @@ public class EndpointWebMvcManagementContextConfiguration {
}
private static class LogFileCondition extends SpringBootCondition {
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
String config = context.getEnvironment().resolvePlaceholders(
"${logging.file:}");
Environment environment = context.getEnvironment();
String config = environment.resolvePlaceholders("${logging.file:}");
if (StringUtils.hasText(config)) {
return ConditionOutcome.match("Found logging.file: " + config);
}
config = context.getEnvironment().resolvePlaceholders("${logging.path:}");
config = environment.resolvePlaceholders("${logging.path:}");
if (StringUtils.hasText(config)) {
return ConditionOutcome.match("Found logging.path: " + config);
}
return ConditionOutcome.noMatch("Found no log file configuration");
}
}
}

View File

@ -61,8 +61,8 @@ public class HealthEndpoint extends AbstractEndpoint<Health> {
}
/**
* Time to live for cached result. This is particularly useful to cache the
* result of this endpoint to prevent a DOS attack if it is accessed anonymously.
* Time to live for cached result. This is particularly useful to cache the result of
* this endpoint to prevent a DOS attack if it is accessed anonymously.
* @return time to live in milliseconds (default 1000)
*/
public long getTimeToLive() {

View File

@ -83,10 +83,6 @@ public class MetricExportProperties extends TriggerProperties {
return this.redis;
}
public void setRedis(Redis redis) {
this.redis = redis;
}
public Aggregate getAggregate() {
return this.aggregate;
}
@ -95,6 +91,10 @@ public class MetricExportProperties extends TriggerProperties {
this.aggregate = aggregate;
}
public void setRedis(Redis redis) {
this.redis = redis;
}
/**
* Find a matching trigger configuration.
* @param name the bean name to match
@ -109,6 +109,44 @@ public class MetricExportProperties extends TriggerProperties {
return this;
}
public static class Aggregate {
/**
* Prefix for global repository if active. Should be unique for this JVM, but most
* useful if it also has the form "a.b" where "a" is unique to this logical
* process (this application) and "b" is unique to this physical process. If you
* set spring.application.name elsewhere, then the default will be in the right
* form.
*/
private String prefix = "";
/**
* Pattern that tells the aggregator what to do with the keys from the source
* repository. The keys in the source repository are assumed to be period
* separated, and the pattern is in the same format, e.g. "d.d.k.d". Here "d"
* means "discard" and "k" means "keep" the key segment in the corresponding
* position in the source.
*/
private String keyPattern = "";
public String getPrefix() {
return this.prefix;
}
public void setPrefix(String prefix) {
this.prefix = prefix;
}
public String getKeyPattern() {
return this.keyPattern;
}
public void setKeyPattern(String keyPattern) {
this.keyPattern = keyPattern;
}
}
public static class Redis {
/**
@ -161,42 +199,4 @@ public class MetricExportProperties extends TriggerProperties {
}
public static class Aggregate {
/**
* Prefix for global repository if active. Should be unique for this JVM, but most
* useful if it also has the form "a.b" where "a" is unique to this logical
* process (this application) and "b" is unique to this physical process. If you
* set spring.application.name elsewhere, then the default will be in the right
* form.
*/
private String prefix = "";
/**
* Pattern that tells the aggregator what to do with the keys from the source
* repository. The keys in the source repository are assumed to be period
* separated, and the pattern is in the same format, e.g. "d.d.k.d". Here "d"
* means "discard" and "k" means "keep" the key segment in the corresponding
* position in the source.
*/
private String keyPattern = "";
public String getPrefix() {
return this.prefix;
}
public void setPrefix(String prefix) {
this.prefix = prefix;
}
public String getKeyPattern() {
return this.keyPattern;
}
public void setKeyPattern(String keyPattern) {
this.keyPattern = keyPattern;
}
}
}

View File

@ -52,4 +52,5 @@ public class AggregateMetricsConfiguration {
repository.setKeyPattern(this.export.getAggregate().getKeyPattern());
return repository;
}
}