Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
6771cc96
Commit
6771cc96
authored
Feb 13, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
d238a31d
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
50 additions
and
58 deletions
+50
-58
MissingRequiredConfigurationFailureAnalyzer.java
.../metrics/MissingRequiredConfigurationFailureAnalyzer.java
+1
-1
RabbitMetricsAutoConfiguration.java
...onfigure/metrics/amqp/RabbitMetricsAutoConfiguration.java
+2
-2
GangliaProperties.java
...toconfigure/metrics/export/ganglia/GangliaProperties.java
+1
-1
PrometheusProperties.java
...igure/metrics/export/prometheus/PrometheusProperties.java
+1
-1
DataSourcePoolMetricsAutoConfiguration.java
.../metrics/jdbc/DataSourcePoolMetricsAutoConfiguration.java
+2
-2
package-info.java
...ctuate/autoconfigure/metrics/web/tomcat/package-info.java
+1
-1
MongoHealthIndicatorAutoConfiguration.java
...onfigure/mongo/MongoHealthIndicatorAutoConfiguration.java
+1
-1
MongoHealthIndicatorConfiguration.java
...utoconfigure/mongo/MongoHealthIndicatorConfiguration.java
+1
-2
spring.factories
...utoconfigure/src/main/resources/META-INF/spring.factories
+2
-1
MissingRequiredConfigurationFailureAnalyzerTests.java
...ics/MissingRequiredConfigurationFailureAnalyzerTests.java
+1
-1
RabbitMetricsAutoConfigurationTests.java
...ure/metrics/amqp/RabbitMetricsAutoConfigurationTests.java
+1
-2
DataSourcePoolMetricsAutoConfigurationTests.java
...ics/jdbc/DataSourcePoolMetricsAutoConfigurationTests.java
+1
-2
MongoReactiveHealthIndicatorConfigurationTests.java
...mongo/MongoReactiveHealthIndicatorConfigurationTests.java
+5
-6
DataSourcePoolMetrics.java
...work/boot/actuate/metrics/jdbc/DataSourcePoolMetrics.java
+6
-5
RabbitMetricsTests.java
...amework/boot/actuate/metrics/amqp/RabbitMetricsTests.java
+1
-2
DataSourcePoolMetricsTests.java
...boot/actuate/metrics/jdbc/DataSourcePoolMetricsTests.java
+2
-2
MongoReactiveHealthIndicatorTest.java
.../boot/actuate/mongo/MongoReactiveHealthIndicatorTest.java
+8
-8
DefaultErrorWebExceptionHandler.java
...e/web/reactive/error/DefaultErrorWebExceptionHandler.java
+13
-18
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/
config/
MissingRequiredConfigurationFailureAnalyzer.java
→
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MissingRequiredConfigurationFailureAnalyzer.java
View file @
6771cc96
...
...
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
metrics
.
config
;
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
metrics
;
import
io.micrometer.core.instrument.config.MissingRequiredConfigurationException
;
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/amqp/RabbitMetricsAutoConfiguration.java
View file @
6771cc96
...
...
@@ -68,8 +68,8 @@ public class RabbitMetricsAutoConfiguration {
ConnectionFactory
rabbitConnectionFactory
=
connectionFactory
.
getRabbitConnectionFactory
();
String
connectionFactoryName
=
getConnectionFactoryName
(
beanName
);
new
RabbitMetrics
(
rabbitConnectionFactory
,
Tags
.
of
(
"name"
,
connectionFactoryName
))
.
bindTo
(
this
.
registry
);
new
RabbitMetrics
(
rabbitConnectionFactory
,
Tags
.
of
(
"name"
,
connectionFactoryName
))
.
bindTo
(
this
.
registry
);
}
/**
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/ganglia/GangliaProperties.java
View file @
6771cc96
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusProperties.java
View file @
6771cc96
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsAutoConfiguration.java
View file @
6771cc96
...
...
@@ -69,8 +69,8 @@ public class DataSourcePoolMetricsAutoConfiguration {
private
void
bindDataSourceToRegistry
(
String
beanName
,
DataSource
dataSource
)
{
String
dataSourceName
=
getDataSourceName
(
beanName
);
new
DataSourcePoolMetrics
(
dataSource
,
this
.
metadataProviders
,
dataSourceName
,
Collections
.
emptyList
()).
bindTo
(
this
.
registry
);
new
DataSourcePoolMetrics
(
dataSource
,
this
.
metadataProviders
,
dataSourceName
,
Collections
.
emptyList
()).
bindTo
(
this
.
registry
);
}
/**
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/tomcat/package-info.java
View file @
6771cc96
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/mongo/MongoHealthIndicatorAutoConfiguration.java
View file @
6771cc96
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/mongo/MongoHealthIndicatorConfiguration.java
View file @
6771cc96
...
...
@@ -41,8 +41,7 @@ class MongoHealthIndicatorConfiguration extends
private
final
Map
<
String
,
MongoTemplate
>
mongoTemplates
;
MongoHealthIndicatorConfiguration
(
Map
<
String
,
MongoTemplate
>
mongoTemplates
)
{
MongoHealthIndicatorConfiguration
(
Map
<
String
,
MongoTemplate
>
mongoTemplates
)
{
this
.
mongoTemplates
=
mongoTemplates
;
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/spring.factories
View file @
6771cc96
...
...
@@ -75,5 +75,6 @@ org.springframework.boot.actuate.autoconfigure.web.jersey.JerseyManagementChildC
org.springframework.boot.actuate.autoconfigure.web.reactive.ReactiveManagementChildContextConfiguration,\
org.springframework.boot.actuate.autoconfigure.web.servlet.ServletManagementChildContextConfiguration,\
org.springframework.boot.actuate.autoconfigure.web.servlet.WebMvcEndpointChildContextConfiguration
org.springframework.boot.diagnostics.FailureAnalyzer=\
org.springframework.boot.actuate.autoconfigure.metrics.
config.
MissingRequiredConfigurationFailureAnalyzer
org.springframework.boot.actuate.autoconfigure.metrics.MissingRequiredConfigurationFailureAnalyzer
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/
config/
MissingRequiredConfigurationFailureAnalyzerTests.java
→
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MissingRequiredConfigurationFailureAnalyzerTests.java
View file @
6771cc96
...
...
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
metrics
.
config
;
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
metrics
;
import
io.micrometer.core.instrument.Clock
;
import
io.micrometer.newrelic.NewRelicConfig
;
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/amqp/RabbitMetricsAutoConfigurationTests.java
View file @
6771cc96
...
...
@@ -47,8 +47,7 @@ public class RabbitMetricsAutoConfigurationTests {
@Test
public
void
rabbitmqNativeConnectionFactoryInstrumentationCanBeDisabled
()
{
this
.
contextRunner
.
withPropertyValues
(
"management.metrics.enable.rabbitmq=false"
)
this
.
contextRunner
.
withPropertyValues
(
"management.metrics.enable.rabbitmq=false"
)
.
run
((
context
)
->
{
MeterRegistry
registry
=
context
.
getBean
(
MeterRegistry
.
class
);
assertThat
(
registry
.
find
(
"rabbitmq.connections"
).
meter
()).
isNull
();
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsAutoConfigurationTests.java
View file @
6771cc96
...
...
@@ -88,8 +88,7 @@ public class DataSourcePoolMetricsAutoConfigurationTests {
context
.
getBean
(
"secondOne"
,
DataSource
.
class
).
getConnection
()
.
getMetaData
();
MeterRegistry
registry
=
context
.
getBean
(
MeterRegistry
.
class
);
registry
.
get
(
"jdbc.max.connections"
).
tags
(
"name"
,
"first"
)
.
meter
();
registry
.
get
(
"jdbc.max.connections"
).
tags
(
"name"
,
"first"
).
meter
();
registry
.
get
(
"jdbc.max.connections"
).
tags
(
"name"
,
"secondOne"
)
.
meter
();
});
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/mongo/MongoReactiveHealthIndicatorConfigurationTests.java
View file @
6771cc96
...
...
@@ -39,8 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public
class
MongoReactiveHealthIndicatorConfigurationTests
{
private
ApplicationContextRunner
contextRunner
=
new
ApplicationContextRunner
()
.
withConfiguration
(
AutoConfigurations
.
of
(
MongoAutoConfiguration
.
class
,
.
withConfiguration
(
AutoConfigurations
.
of
(
MongoAutoConfiguration
.
class
,
MongoDataAutoConfiguration
.
class
,
MongoReactiveAutoConfiguration
.
class
,
MongoReactiveDataAutoConfiguration
.
class
,
...
...
@@ -49,10 +48,10 @@ public class MongoReactiveHealthIndicatorConfigurationTests {
@Test
public
void
runShouldCreateIndicator
()
{
this
.
contextRunner
.
run
(
(
context
)
->
assertThat
(
context
)
.
hasSingleBean
(
MongoReactiveHealthIndicator
.
class
)
.
doesNotHaveBean
(
MongoHealthIndicator
.
class
)
.
doesNotHaveBean
(
ApplicationHealthIndicator
.
class
));
this
.
contextRunner
.
run
(
(
context
)
->
assertThat
(
context
)
.
hasSingleBean
(
MongoReactiveHealthIndicator
.
class
)
.
doesNotHaveBean
(
MongoHealthIndicator
.
class
)
.
doesNotHaveBean
(
ApplicationHealthIndicator
.
class
));
}
@Test
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/jdbc/DataSourcePoolMetrics.java
View file @
6771cc96
...
...
@@ -49,8 +49,8 @@ public class DataSourcePoolMetrics implements MeterBinder {
private
final
Iterable
<
Tag
>
tags
;
public
DataSourcePoolMetrics
(
DataSource
dataSource
,
Collection
<
DataSourcePoolMetadataProvider
>
metadataProviders
,
String
dataSourceName
,
Iterable
<
Tag
>
tags
)
{
Collection
<
DataSourcePoolMetadataProvider
>
metadataProviders
,
String
dataSourceName
,
Iterable
<
Tag
>
tags
)
{
this
(
dataSource
,
new
CompositeDataSourcePoolMetadataProvider
(
metadataProviders
),
dataSourceName
,
tags
);
}
...
...
@@ -75,9 +75,10 @@ public class DataSourcePoolMetrics implements MeterBinder {
}
}
private
<
N
extends
Number
>
void
bindPoolMetadata
(
MeterRegistry
registry
,
String
metricName
,
Function
<
DataSourcePoolMetadata
,
N
>
function
)
{
bindDataSource
(
registry
,
metricName
,
this
.
metadataProvider
.
getValueFunction
(
function
));
private
<
N
extends
Number
>
void
bindPoolMetadata
(
MeterRegistry
registry
,
String
metricName
,
Function
<
DataSourcePoolMetadata
,
N
>
function
)
{
bindDataSource
(
registry
,
metricName
,
this
.
metadataProvider
.
getValueFunction
(
function
));
}
private
<
N
extends
Number
>
void
bindDataSource
(
MeterRegistry
registry
,
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/amqp/RabbitMetricsTests.java
View file @
6771cc96
...
...
@@ -43,8 +43,7 @@ public class RabbitMetricsTests {
public
void
connectionFactoryWithTagsIsInstrumented
()
{
ConnectionFactory
connectionFactory
=
mock
(
ConnectionFactory
.
class
);
SimpleMeterRegistry
registry
=
new
SimpleMeterRegistry
();
new
RabbitMetrics
(
connectionFactory
,
Tags
.
of
(
"env"
,
"prod"
))
.
bindTo
(
registry
);
new
RabbitMetrics
(
connectionFactory
,
Tags
.
of
(
"env"
,
"prod"
)).
bindTo
(
registry
);
assertThat
(
registry
.
get
(
"rabbitmq.connections"
).
tags
(
"env"
,
"prod"
).
meter
())
.
isNotNull
();
assertThat
(
registry
.
find
(
"rabbitmq.connections"
).
tags
(
"env"
,
"dev"
).
meter
())
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/jdbc/DataSourcePoolMetricsTests.java
View file @
6771cc96
...
...
@@ -50,8 +50,8 @@ public class DataSourcePoolMetricsTests {
"metrics.use-global-registry=false"
)
.
run
((
context
)
->
{
context
.
getBean
(
DataSource
.
class
).
getConnection
().
getMetaData
();
context
.
getBean
(
MeterRegistry
.
class
)
.
get
(
"jdbc.max.connections"
).
meter
();
context
.
getBean
(
MeterRegistry
.
class
)
.
get
(
"jdbc.max.connections"
)
.
meter
();
});
}
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/mongo/MongoReactiveHealthIndicatorTest.java
View file @
6771cc96
...
...
@@ -42,10 +42,10 @@ public class MongoReactiveHealthIndicatorTest {
Document
buildInfo
=
mock
(
Document
.
class
);
given
(
buildInfo
.
getString
(
"version"
)).
willReturn
(
"2.6.4"
);
ReactiveMongoTemplate
reactiveMongoTemplate
=
mock
(
ReactiveMongoTemplate
.
class
);
given
(
reactiveMongoTemplate
.
executeCommand
(
"{ buildInfo: 1 }"
))
.
willReturn
(
Mono
.
just
(
buildInfo
));
MongoReactiveHealthIndicator
mongoReactiveHealthIndicator
=
new
MongoReactiveHealthIndicator
(
reactiveMongoTemplate
);
given
(
reactiveMongoTemplate
.
executeCommand
(
"{ buildInfo: 1 }"
))
.
willReturn
(
Mono
.
just
(
buildInfo
));
MongoReactiveHealthIndicator
mongoReactiveHealthIndicator
=
new
MongoReactiveHealthIndicator
(
reactiveMongoTemplate
);
Mono
<
Health
>
health
=
mongoReactiveHealthIndicator
.
health
();
StepVerifier
.
create
(
health
).
consumeNextWith
((
h
)
->
{
assertThat
(
h
.
getStatus
()).
isEqualTo
(
Status
.
UP
);
...
...
@@ -57,10 +57,10 @@ public class MongoReactiveHealthIndicatorTest {
@Test
public
void
testMongoIsDown
()
{
ReactiveMongoTemplate
reactiveMongoTemplate
=
mock
(
ReactiveMongoTemplate
.
class
);
given
(
reactiveMongoTemplate
.
executeCommand
(
"{ buildInfo: 1 }"
))
.
willThrow
(
new
MongoException
(
"Connection failed"
));
MongoReactiveHealthIndicator
mongoReactiveHealthIndicator
=
new
MongoReactiveHealthIndicator
(
reactiveMongoTemplate
);
given
(
reactiveMongoTemplate
.
executeCommand
(
"{ buildInfo: 1 }"
))
.
willThrow
(
new
MongoException
(
"Connection failed"
));
MongoReactiveHealthIndicator
mongoReactiveHealthIndicator
=
new
MongoReactiveHealthIndicator
(
reactiveMongoTemplate
);
Mono
<
Health
>
health
=
mongoReactiveHealthIndicator
.
health
();
StepVerifier
.
create
(
health
).
consumeNextWith
((
h
)
->
{
assertThat
(
h
.
getStatus
()).
isEqualTo
(
Status
.
DOWN
);
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java
View file @
6771cc96
...
...
@@ -20,6 +20,7 @@ import java.util.Collections;
import
java.util.EnumMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.BiConsumer
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
...
...
@@ -189,29 +190,23 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa
}
/**
* Log the original exception if handling it results in a Server Error or a Bad
Request
* (Client Error with 400 status code) one.
* Log the original exception if handling it results in a Server Error or a Bad
*
Request
(Client Error with 400 status code) one.
* @param request the source request
* @param errorStatus the HTTP error status
*/
protected
void
logError
(
ServerRequest
request
,
HttpStatus
errorStatus
)
{
if
(
errorStatus
.
is5xxServerError
())
{
Throwable
ex
=
getError
(
request
);
if
(
ex
instanceof
ResponseStatusException
)
{
logger
.
error
(
buildMessage
(
request
,
ex
));
}
else
{
logger
.
error
(
buildMessage
(
request
,
null
),
ex
);
}
Throwable
ex
=
getError
(
request
);
log
(
request
,
ex
,
(
errorStatus
.
is5xxServerError
()
?
logger:
:
error
:
logger:
:
warn
)
);
}
private
void
log
(
ServerRequest
request
,
Throwable
ex
,
BiConsumer
<
Object
,
Throwable
>
logger
)
{
if
(
ex
instanceof
ResponseStatusException
)
{
logger
.
accept
(
buildMessage
(
request
,
ex
),
null
);
}
else
if
(
errorStatus
==
HttpStatus
.
BAD_REQUEST
)
{
Throwable
ex
=
getError
(
request
);
if
(
ex
instanceof
ResponseStatusException
)
{
logger
.
warn
(
buildMessage
(
request
,
ex
));
}
else
{
logger
.
warn
(
buildMessage
(
request
,
null
),
ex
);
}
else
{
logger
.
accept
(
buildMessage
(
request
,
null
),
ex
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment