A Spring Boot starter for MVC related functionality. Supports RestTemplate and servlet (blocking calls). This starter is has a dependency on the base-starter.
Include the starter as a dependency
<dependency>
<groupId>no.skatteetaten.aurora.springboot</groupId>
<artifactId>aurora-spring-boot-mvc-starter</artifactId>
<version>${aurora.starters.version}</version>
</dependency>
Spring Sleuth is included by the base starter.
It is a distributed tracing solution for Spring Boot apps. Spring Sleuth will generate its own IDs, however it can be useful to see how these IDs related to the Korrelasjonsid
header.
By enabling the filter Korrelasjonsid
set will be included in the information sent to Grafana Tempo as a tag.
If Korrelasjonsid
is not set, this tag will simply be skipped.
Korrelasjonsid
, Meldingsid
and Klientid
is set on MDC if they are present in the incoming request.
Spring Sleuth is by default disabled for local development and enabled in OpenShift. You can override this by setting the following property:
spring.sleuth.otel.exporter.otlp.enabed = true
To set the url for the otel exporter:
spring.sleuth.otel.exporter.otlp.endpoint = <otlp-url>
The RestTemplate interceptor will add the Korrelasjonsid
, Meldingsid
and Klientid
headers to requests sent from the RestTemplate instance.
To use this functionality enabled it using the property, as shown below. It is disabled by default.
Inject it as a normal Spring bean using the RestTemplateBuilder
, where you can also add you own customization.
aurora.mvc.header.resttemplate.interceptor.enabled = true
The headers set are based on these values:
Korrelasjonsid
taken from theRequestKorrelasjon
class. If not found, it will generate a new ID.Medlindsid
will always generate a new ID.Klientid
set from the environment variable AURORA_KLIENTID or uses application name with version as fallback (using thespring.application.name
property andAPP_VERSION
env). TheUser-Agent
header will also be set to the same value.
The starter will add a graceful shutdown handler for Tomcat (without it Tomcat may terminate ongoing requests on SIGTERM)
Micrometer metrics collectors registered (provided by the base starter):
- RestTemplateMetrics
- TomcatMetrics