Polish "Disable metrics export in integration tests"

See gh-21658
This commit is contained in:
Stephane Nicoll
2020-07-17 16:57:51 +02:00
parent b1830da0da
commit 3530ac9b0c
54 changed files with 265 additions and 240 deletions

View File

@@ -1428,6 +1428,13 @@ For example, to disable Datadog:
management.metrics.export.datadog.enabled=false
----
You can also disable all registries unless stated otherwise by the registry-specific property, as shown in the following example:
[source,properties,indent=0,configprops]
----
management.metrics.export.defaults.enabled=false
----
Spring Boot will also add any auto-configured registries to the global static composite registry on the `Metrics` class unless you explicitly tell it not to:
[source,properties,indent=0,configprops]

View File

@@ -6638,6 +6638,14 @@ include::{test-examples}/jmx/SampleJmxTests.java[tag=test]
[[boot-features-testing-spring-boot-applications-metrics]]
==== Using Metrics
Regardless of your classpath, meter registries, except the in-memory backed, are not auto-configured when using `@SpringBootTest`.
If you need to export metrics to a different backend as part of an integration test, annotate it with `@AutoConfigureMetrics`.
[[boot-features-testing-spring-boot-applications-mocking-beans]]
==== Mocking and Spying Beans
When running tests, it is sometimes necessary to mock certain components within your application context.