Since Spring Boot 2.3.0 if you want to add additional tags to the default ones for some requests, a better approach is to add a @Bean of class WebMvcTagsContributor. This way your code doesn't have to worry about putting in the default tags.
Implemented in https://github.com/spring-projects/spring-boot/issues/20175
The code would look like this:
@Bean
public WebMvcTagsContributor webMvcTagsContributor() {
return new WebMvcTagsContributor() {
@Override
public Iterable<Tag> getTags(HttpServletRequest request, HttpServletResponse response, Object handler, Throwable exception) {
Tags tags = Tags.empty();
tags = tags.and(Tag.of("my_tag", "somevalue"));
return tags;
}
@Override
public Iterable<Tag> getLongRequestTags(HttpServletRequest request, Object handler) {
return null;
}
};
}