pull/272/head
Phillip Webb 11 years ago
parent 76b15c4446
commit e545e5aa32

@ -72,14 +72,6 @@ public class MetricFilterAutoConfiguration {
@Order(Ordered.HIGHEST_PRECEDENCE)
private final class MetricsFilter extends OncePerRequestFilter {
/*
* (non-Javadoc)
*
* @see
* org.springframework.web.filter.OncePerRequestFilter#doFilterInternal(javax.
* servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
* javax.servlet.FilterChain)
*/
@Override
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response, FilterChain chain) throws ServletException,

@ -42,7 +42,6 @@ public class PrefixMetricGroupExporter extends AbstractMetricExporter {
/**
* Create a new exporter for metrics to a writer based on an empty prefix for the
* metric names.
*
* @param reader a reader as the source of metrics
* @param writer the writer to send the metrics to
*/
@ -53,7 +52,6 @@ public class PrefixMetricGroupExporter extends AbstractMetricExporter {
/**
* Create a new exporter for metrics to a writer based on a prefix for the metric
* names.
*
* @param reader a reader as the source of metrics
* @param writer the writer to send the metrics to
* @param prefix the prefix for metrics to export

@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2014 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.
@ -17,26 +17,28 @@
package org.springframework.boot.actuate.metrics.reader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.springframework.boot.actuate.metrics.Metric;
/**
* Composite implementation of {@link MetricReader}.
*
* @author Dave Syer
*/
public class CompositeMetricReader implements MetricReader {
private List<MetricReader> delegates = Collections.emptyList();
private final List<MetricReader> readers = new ArrayList<MetricReader>();
public void setDelegates(Collection<MetricReader> delegates) {
this.delegates = new ArrayList<MetricReader>(delegates);
public CompositeMetricReader(MetricReader... readers) {
for (MetricReader reader : readers) {
this.readers.add(reader);
}
}
@Override
public Metric<?> findOne(String metricName) {
for (MetricReader delegate : this.delegates) {
for (MetricReader delegate : this.readers) {
Metric<?> value = delegate.findOne(metricName);
if (value != null) {
return value;
@ -48,7 +50,7 @@ public class CompositeMetricReader implements MetricReader {
@Override
public Iterable<Metric<?>> findAll() {
List<Metric<?>> values = new ArrayList<Metric<?>>((int) count());
for (MetricReader delegate : this.delegates) {
for (MetricReader delegate : this.readers) {
Iterable<Metric<?>> all = delegate.findAll();
for (Metric<?> value : all) {
values.add(value);
@ -60,7 +62,7 @@ public class CompositeMetricReader implements MetricReader {
@Override
public long count() {
long count = 0;
for (MetricReader delegate : this.delegates) {
for (MetricReader delegate : this.readers) {
count += delegate.count();
}

@ -28,7 +28,6 @@ public interface MetricReader {
/**
* Find an instance of the metric with the given name (usually the latest recorded
* value).
*
* @param metricName the name of the metric to find
* @return a metric value or null if there are none with that name
*/
@ -36,14 +35,12 @@ public interface MetricReader {
/**
* Find all the metrics known to this reader.
*
* @return all instances of metrics known to this reader
*/
Iterable<Metric<?>> findAll();
/**
* The number of metrics known to this reader.
*
* @return the number of metrics
*/
long count();

@ -27,7 +27,6 @@ public interface PrefixMetricReader {
/**
* Find all metrics whose name starts with the given prefix.
*
* @param prefix the prefix for metric names
* @return all metrics with names starting with the prefix
*/

@ -31,7 +31,6 @@ public interface MultiMetricRepository extends PrefixMetricReader {
/**
* Save some metric values and associate them with a group name.
*
* @param group the name of the group
* @param values the metric values to save
*/
@ -40,14 +39,12 @@ public interface MultiMetricRepository extends PrefixMetricReader {
/**
* Rest the values of all metrics in the group. Implementations may choose to discard
* the old values.
*
* @param group reset the whole group
*/
void reset(String group);
/**
* The names of all the groups known to this repository
*
* @return all available group names
*/
Iterable<String> groups();

@ -64,7 +64,6 @@ public class RedisMetricRepository implements MetricRepository {
/**
* The prefix for all metrics keys.
*
* @param prefix the prefix to set for all metrics keys
*/
public void setPrefix(String prefix) {
@ -79,7 +78,6 @@ public class RedisMetricRepository implements MetricRepository {
* zset under this key. Defaults to "keys.spring.metrics". REad operations, especially
* {@link #findAll()} and {@link #count()}, will be much more efficient if the key is
* unique to the {@link #setPrefix(String) prefix} of this repository.
*
* @param key the key to set
*/
public void setKey(String key) {

@ -46,11 +46,8 @@ public final class RichGauge {
private double alpha;
/**
* Creates an "empty" gauge.
*
* The average, max and min will be zero, but this initial value will not be included
* after the first value has been set on the gauge.
*
* Creates an "empty" gauge. The average, max and min will be zero, but this initial
* value will not be included after the first value has been set on the gauge.
* @param name the name under which the gauge will be stored.
*/
public RichGauge(String name) {

@ -25,7 +25,6 @@ public interface RichGaugeReader {
/**
* Find a single instance of a rich gauge by name.
*
* @param name the name of the gauge
* @return a rich gauge value
*/
@ -33,7 +32,6 @@ public interface RichGaugeReader {
/**
* Find all instances of rich gauge known to this reader.
*
* @return all instances known to this reader
*/
Iterable<RichGauge> findAll();

@ -28,14 +28,12 @@ public interface MetricWriter {
/**
* Increment the value of a metric (or decrement if the delta is negative). The name
* of the delta is the name of the metric to increment.
*
* @param delta the amount to increment by
*/
void increment(Delta<?> delta);
/**
* Set the value of a metric.
*
* @param value
*/
void set(Metric<?> value);
@ -43,7 +41,6 @@ public interface MetricWriter {
/**
* Reset the value of a metric, usually to zero value. Implementations can discard the
* old values if desired, but may choose not to.
*
* @param metricName the name to reset
*/
void reset(String metricName);

@ -375,22 +375,25 @@ public class SpringApplication {
}
protected void handleError(ConfigurableApplicationContext context,
ApplicationEventMulticaster multicaster, Throwable ex, String... args) {
ApplicationEventMulticaster multicaster, Throwable exception, String... args) {
try {
multicaster.multicastEvent(new SpringApplicationErrorEvent(this, context,
args, ex));
args, exception));
}
catch (Exception e) {
catch (Exception ex) {
// We don't want to fail here and mask the original exception
if (this.log.isDebugEnabled()) {
this.log.error("Error handling failed", e);
this.log.error("Error handling failed", ex);
}
else {
this.log.warn("Error handling failed (" + e.getMessage() + ")");
this.log.warn("Error handling failed (" + ex.getMessage() == null ? "no error message"
: ex.getMessage() + ")");
}
}
if (context != null) {
context.close();
finally {
if (context != null) {
context.close();
}
}
}
@ -524,7 +527,6 @@ public class SpringApplication {
* @see #setApplicationContextClass(Class)
*/
protected ConfigurableApplicationContext createApplicationContext() {
Class<?> contextClass = this.applicationContextClass;
if (contextClass == null) {
try {
@ -538,9 +540,7 @@ public class SpringApplication {
+ "please specify an ApplicationContextClass", ex);
}
}
return (ConfigurableApplicationContext) BeanUtils.instantiate(contextClass);
}
/**

Loading…
Cancel
Save