Browse Source

Polish

pull/3452/head
Phillip Webb 11 years ago
parent
commit
5938c967a3
  1. 9
      spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfiguration.java
  2. 4
      spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/HealthEndpoint.java
  3. 84
      spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/export/MetricExportProperties.java
  4. 1
      spring-boot-samples/spring-boot-sample-metrics-redis/src/main/java/sample/metrics/redis/AggregateMetricsConfiguration.java

9
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfiguration.java

@ -45,6 +45,7 @@ import org.springframework.context.ApplicationContext; @@ -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 { @@ -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");
}
}
}

4
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/HealthEndpoint.java

@ -61,8 +61,8 @@ public class HealthEndpoint extends AbstractEndpoint<Health> { @@ -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() {

84
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/export/MetricExportProperties.java

@ -83,10 +83,6 @@ public class MetricExportProperties extends TriggerProperties { @@ -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 { @@ -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 { @@ -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 { @@ -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;
}
}
}

1
spring-boot-samples/spring-boot-sample-metrics-redis/src/main/java/sample/metrics/redis/AggregateMetricsConfiguration.java

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

Loading…
Cancel
Save