You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Starting this application with the regular runtime involves a number of steps including classpath scanning, configuration class parsing, bean instantiation, and lifecycle callback handling.
60
60
Refresh for AOT processing only applies a subset of what happens with a xref:core/beans/introduction.adoc[regular `refresh`].
61
61
AOT processing can be triggered as follows:
62
62
63
-
include::code:AotProcessingSample[tag=aotcontext]
63
+
include-code::AotProcessingSample[tag=aotcontext]
64
64
65
65
In this mode, xref:core/beans/factory-extension.adoc#beans-factory-extension-factory-postprocessors[`BeanFactoryPostProcessor` implementations] are invoked as usual.
66
66
This includes configuration class parsing, import selectors, classpath scanning, etc.
@@ -217,7 +217,7 @@ A number of convenient annotations are also provided for common use cases.
217
217
Implementations of this interface can be registered using `@ImportRuntimeHints` on any Spring bean or `@Bean` factory method.
218
218
`RuntimeHintsRegistrar` implementations are detected and invoked at build time.
219
219
220
-
include::code:SpellCheckService[]
220
+
include-code::SpellCheckService[]
221
221
222
222
If at all possible, `@ImportRuntimeHints` should be used as close as possible to the component that requires the hints.
223
223
This way, if the component is not contributed to the `BeanFactory`, the hints won't be contributed either.
@@ -269,7 +269,7 @@ Spring Core also ships `RuntimeHintsPredicates`, a utility for checking that exi
269
269
This can be used in your own tests to validate that a `RuntimeHintsRegistrar` contains the expected results.
270
270
We can write a test for our `SpellCheckService` and ensure that we will be able to load a dictionary at runtime:
With `RuntimeHintsPredicates`, we can check for reflection, resource, serialization, or proxy generation hints.
275
275
This approach works well for unit tests but implies that the runtime behavior of a component is well known.
@@ -281,11 +281,11 @@ For more targeted discovery and testing, Spring Framework ships a dedicated modu
281
281
This module contains the RuntimeHints Agent, a Java agent that records all method invocations that are related to runtime hints and helps you to assert that a given `RuntimeHints` instance covers all recorded invocations.
282
282
Let's consider a piece of infrastructure for which we'd like to test the hints we're contributing during the AOT processing phase.
283
283
284
-
include::code:SampleReflection[]
284
+
include-code::SampleReflection[]
285
285
286
286
We can then write a unit test (no native compilation required) that checks our contributed hints:
287
287
288
-
include::code:SampleReflectionRuntimeHintsTests[]
288
+
include-code::SampleReflectionRuntimeHintsTests[]
289
289
290
290
If you forgot to contribute a hint, the test will fail and provide some details about the invocation:
Copy file name to clipboardExpand all lines: framework-docs/modules/ROOT/pages/integration/observability.adoc
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -66,16 +66,16 @@ Let's take the example of the Spring MVC "http.server.requests" metrics instrume
66
66
This observation is using a `ServerRequestObservationConvention` with a `ServerRequestObservationContext`; custom conventions can be configured on the Servlet filter.
67
67
If you would like to customize the metadata produced with the observation, you can extend the `DefaultServerRequestObservationConvention` for your requirements:
You can also achieve similar goals using a custom `ObservationFilter` - adding or removing key values for an observation.
76
76
Filters do not replace the default convention and are used as a post-processing component.
77
77
78
-
include::code:ServerRequestObservationFilter[]
78
+
include-code::ServerRequestObservationFilter[]
79
79
80
80
You can configure `ObservationFilter` instances on the `ObservationRegistry`.
81
81
@@ -95,7 +95,7 @@ This will only record an observation as an error if the `Exception` has not been
95
95
Typically, all exceptions handled by Spring MVC's `@ExceptionHandler` and xref:web/webmvc/mvc-ann-rest-exceptions.adoc[`ProblemDetail` support] will not be recorded with the observation.
96
96
You can, at any point during request processing, set the error field on the `ObservationContext` yourself:
97
97
98
-
include::code:UserController[]
98
+
include-code::UserController[]
99
99
100
100
By default, the following `KeyValues` are created:
101
101
@@ -128,7 +128,7 @@ This will only record an observation as an error if the `Exception` has not been
128
128
Typically, all exceptions handled by Spring WebFlux's `@ExceptionHandler` and xref:web/webflux/ann-rest-exceptions.adoc[`ProblemDetail` support] will not be recorded with the observation.
129
129
You can, at any point during request processing, set the error field on the `ObservationContext` yourself:
130
130
131
-
include::code:UserController[]
131
+
include-code::UserController[]
132
132
133
133
By default, the following `KeyValues` are created:
0 commit comments