Skip to content

Commit 8d18e5f

Browse files
committed
Merge branch '2.7.x'
2 parents 52d7424 + b8b9035 commit 8d18e5f

File tree

9 files changed

+40
-30
lines changed

9 files changed

+40
-30
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsRegistrarConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -72,7 +72,7 @@ private void bindCacheManagerToRegistry(String beanName, CacheManager cacheManag
7272
}
7373

7474
private void bindCacheToRegistry(String beanName, Cache cache) {
75-
Tag cacheManagerTag = Tag.of("cacheManager", getCacheManagerName(beanName));
75+
Tag cacheManagerTag = Tag.of("cache.manager", getCacheManagerName(beanName));
7676
this.cacheMetricsRegistrar.bindCacheToRegistry(cache, cacheManagerTag);
7777
}
7878

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsAutoConfigurationTests.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ void autoConfiguredCache2kIsInstrumented() {
4444
this.contextRunner.withPropertyValues("spring.cache.type=cache2k", "spring.cache.cache-names=cache1,cache2")
4545
.run((context) -> {
4646
MeterRegistry registry = context.getBean(MeterRegistry.class);
47-
registry.get("cache.gets").tags("name", "cache1").tags("cacheManager", "cacheManager").meter();
48-
registry.get("cache.gets").tags("name", "cache2").tags("cacheManager", "cacheManager").meter();
47+
registry.get("cache.gets").tags("name", "cache1").tags("cache.manager", "cacheManager").meter();
48+
registry.get("cache.gets").tags("name", "cache2").tags("cache.manager", "cacheManager").meter();
4949
});
5050
}
5151

@@ -54,8 +54,8 @@ void autoConfiguredCacheManagerIsInstrumented() {
5454
this.contextRunner.withPropertyValues("spring.cache.type=caffeine", "spring.cache.cache-names=cache1,cache2")
5555
.run((context) -> {
5656
MeterRegistry registry = context.getBean(MeterRegistry.class);
57-
registry.get("cache.gets").tags("name", "cache1").tags("cacheManager", "cacheManager").meter();
58-
registry.get("cache.gets").tags("name", "cache2").tags("cacheManager", "cacheManager").meter();
57+
registry.get("cache.gets").tags("name", "cache1").tags("cache.manager", "cacheManager").meter();
58+
registry.get("cache.gets").tags("name", "cache2").tags("cache.manager", "cacheManager").meter();
5959
});
6060
}
6161

@@ -64,9 +64,9 @@ void autoConfiguredNonSupportedCacheManagerIsIgnored() {
6464
this.contextRunner.withPropertyValues("spring.cache.type=simple", "spring.cache.cache-names=cache1,cache2")
6565
.run((context) -> {
6666
MeterRegistry registry = context.getBean(MeterRegistry.class);
67-
assertThat(registry.find("cache.gets").tags("name", "cache1").tags("cacheManager", "cacheManager")
67+
assertThat(registry.find("cache.gets").tags("name", "cache1").tags("cache.manager", "cacheManager")
6868
.meter()).isNull();
69-
assertThat(registry.find("cache.gets").tags("name", "cache2").tags("cacheManager", "cacheManager")
69+
assertThat(registry.find("cache.gets").tags("name", "cache2").tags("cache.manager", "cacheManager")
7070
.meter()).isNull();
7171
});
7272
}
@@ -77,7 +77,7 @@ void cacheInstrumentationCanBeDisabled() {
7777
"spring.cache.cache-names=cache1").run((context) -> {
7878
MeterRegistry registry = context.getBean(MeterRegistry.class);
7979
assertThat(registry.find("cache.requests").tags("name", "cache1")
80-
.tags("cacheManager", "cacheManager").meter()).isNull();
80+
.tags("cache.manager", "cacheManager").meter()).isNull();
8181
});
8282
}
8383

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/startup/StartupTimeMetricsListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -123,7 +123,7 @@ private void registerGauge(String name, String description, Duration timeTaken,
123123

124124
private Iterable<Tag> createTagsFrom(SpringApplication springApplication) {
125125
Class<?> mainClass = springApplication.getMainApplicationClass();
126-
return (mainClass != null) ? this.tags.and("main-application-class", mainClass.getName()) : this.tags;
126+
return (mainClass != null) ? this.tags.and("main.application.class", mainClass.getName()) : this.tags;
127127
}
128128

129129
}

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTags.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -105,17 +105,17 @@ private static String getStatusMessage(ClientHttpResponse response) {
105105
}
106106

107107
/**
108-
* Create a {@code clientName} {@code Tag} derived from the {@link URI#getHost host}
108+
* Create a {@code client.name} {@code Tag} derived from the {@link URI#getHost host}
109109
* of the {@link HttpRequest#getURI() URI} of the given {@code request}.
110110
* @param request the request
111-
* @return the clientName tag
111+
* @return the client.name tag
112112
*/
113113
public static Tag clientName(HttpRequest request) {
114114
String host = request.getURI().getHost();
115115
if (host == null) {
116116
host = "none";
117117
}
118-
return Tag.of("clientName", host);
118+
return Tag.of("client.name", host);
119119
}
120120

121121
/**

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTags.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -45,7 +45,7 @@ public final class WebClientExchangeTags {
4545

4646
private static final Pattern PATTERN_BEFORE_PATH = Pattern.compile("^https?://[^/]+/");
4747

48-
private static final Tag CLIENT_NAME_NONE = Tag.of("clientName", "none");
48+
private static final Tag CLIENT_NAME_NONE = Tag.of("client.name", "none");
4949

5050
private WebClientExchangeTags() {
5151
}
@@ -95,18 +95,18 @@ public static Tag status(ClientResponse response, Throwable throwable) {
9595
}
9696

9797
/**
98-
* Create a {@code clientName} {@code Tag} derived from the
98+
* Create a {@code client.name} {@code Tag} derived from the
9999
* {@link java.net.URI#getHost host} of the {@link ClientRequest#url() URL} of the
100100
* given {@code request}.
101101
* @param request the request
102-
* @return the clientName tag
102+
* @return the client.name tag
103103
*/
104104
public static Tag clientName(ClientRequest request) {
105105
String host = request.url().getHost();
106106
if (host == null) {
107107
return CLIENT_NAME_NONE;
108108
}
109-
return Tag.of("clientName", host);
109+
return Tag.of("client.name", host);
110110
}
111111

112112
/**

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/startup/StartupTimeMetricsListenerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private void assertMetricExistsWithValue(String metricName, long expectedValueIn
118118
private void assertMetricExistsWithCustomTagsAndValue(String metricName, Tags expectedCustomTags,
119119
Long expectedValueInMillis) {
120120
assertThat(this.registry.find(metricName)
121-
.tags(Tags.concat(expectedCustomTags, "main-application-class", TestMainApplication.class.getName()))
121+
.tags(Tags.concat(expectedCustomTags, "main.application.class", TestMainApplication.class.getName()))
122122
.timeGauge()).isNotNull().extracting((m) -> m.value(TimeUnit.MILLISECONDS))
123123
.isEqualTo(expectedValueInMillis.doubleValue());
124124
}

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTagsTests.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,11 +17,13 @@
1717
package org.springframework.boot.actuate.metrics.web.client;
1818

1919
import java.io.IOException;
20+
import java.net.URI;
2021

2122
import io.micrometer.core.instrument.Tag;
2223
import org.junit.jupiter.api.Test;
2324

2425
import org.springframework.http.HttpStatus;
26+
import org.springframework.http.client.ClientHttpRequest;
2527
import org.springframework.http.client.ClientHttpResponse;
2628
import org.springframework.mock.http.client.MockClientHttpResponse;
2729

@@ -102,4 +104,12 @@ void outcomeTagIsUnknownWhenResponseStatusIsInUnknownSeries() throws IOException
102104
assertThat(tag.getValue()).isEqualTo("UNKNOWN");
103105
}
104106

107+
@Test
108+
void clientNameTagIsHostOfRequestUri() throws IOException {
109+
ClientHttpRequest request = mock(ClientHttpRequest.class);
110+
given(request.getURI()).willReturn(URI.create("https://example.org"));
111+
Tag tag = RestTemplateExchangeTags.clientName(request);
112+
assertThat(tag).isEqualTo(Tag.of("client.name", "example.org"));
113+
}
114+
105115
}

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/DefaultWebClientExchangeTagsProviderTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -61,7 +61,7 @@ void setup() {
6161
void tagsShouldBePopulated() {
6262
Iterable<Tag> tags = this.tagsProvider.tags(this.request, this.response, null);
6363
assertThat(tags).containsExactlyInAnyOrder(Tag.of("method", "GET"), Tag.of("uri", "/projects/{project}"),
64-
Tag.of("clientName", "example.org"), Tag.of("status", "200"), Tag.of("outcome", "SUCCESS"));
64+
Tag.of("client.name", "example.org"), Tag.of("status", "200"), Tag.of("outcome", "SUCCESS"));
6565
}
6666

6767
@Test
@@ -70,28 +70,28 @@ void tagsWhenNoUriTemplateShouldProvideUriPath() {
7070
.create(HttpMethod.GET, URI.create("https://example.org/projects/spring-boot")).build();
7171
Iterable<Tag> tags = this.tagsProvider.tags(request, this.response, null);
7272
assertThat(tags).containsExactlyInAnyOrder(Tag.of("method", "GET"), Tag.of("uri", "/projects/spring-boot"),
73-
Tag.of("clientName", "example.org"), Tag.of("status", "200"), Tag.of("outcome", "SUCCESS"));
73+
Tag.of("client.name", "example.org"), Tag.of("status", "200"), Tag.of("outcome", "SUCCESS"));
7474
}
7575

7676
@Test
7777
void tagsWhenIoExceptionShouldReturnIoErrorStatus() {
7878
Iterable<Tag> tags = this.tagsProvider.tags(this.request, null, new IOException());
7979
assertThat(tags).containsExactlyInAnyOrder(Tag.of("method", "GET"), Tag.of("uri", "/projects/{project}"),
80-
Tag.of("clientName", "example.org"), Tag.of("status", "IO_ERROR"), Tag.of("outcome", "UNKNOWN"));
80+
Tag.of("client.name", "example.org"), Tag.of("status", "IO_ERROR"), Tag.of("outcome", "UNKNOWN"));
8181
}
8282

8383
@Test
8484
void tagsWhenExceptionShouldReturnClientErrorStatus() {
8585
Iterable<Tag> tags = this.tagsProvider.tags(this.request, null, new IllegalArgumentException());
8686
assertThat(tags).containsExactlyInAnyOrder(Tag.of("method", "GET"), Tag.of("uri", "/projects/{project}"),
87-
Tag.of("clientName", "example.org"), Tag.of("status", "CLIENT_ERROR"), Tag.of("outcome", "UNKNOWN"));
87+
Tag.of("client.name", "example.org"), Tag.of("status", "CLIENT_ERROR"), Tag.of("outcome", "UNKNOWN"));
8888
}
8989

9090
@Test
9191
void tagsWhenCancelledRequestShouldReturnClientErrorStatus() {
9292
Iterable<Tag> tags = this.tagsProvider.tags(this.request, null, null);
9393
assertThat(tags).containsExactlyInAnyOrder(Tag.of("method", "GET"), Tag.of("uri", "/projects/{project}"),
94-
Tag.of("clientName", "example.org"), Tag.of("status", "CLIENT_ERROR"), Tag.of("outcome", "UNKNOWN"));
94+
Tag.of("client.name", "example.org"), Tag.of("status", "CLIENT_ERROR"), Tag.of("outcome", "UNKNOWN"));
9595
}
9696

9797
}

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/WebClientExchangeTagsTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -88,7 +88,7 @@ void uriWhenTemplateIsMissingShouldReturnPathWithQueryParams() {
8888

8989
@Test
9090
void clientName() {
91-
assertThat(WebClientExchangeTags.clientName(this.request)).isEqualTo(Tag.of("clientName", "example.org"));
91+
assertThat(WebClientExchangeTags.clientName(this.request)).isEqualTo(Tag.of("client.name", "example.org"));
9292
}
9393

9494
@Test

0 commit comments

Comments
 (0)