Skip to content

Commit b0ceb98

Browse files
authored
Merge pull request #829 from dsyer/micrometer
Bump micrometer version to latest
2 parents 0646e66 + bc37749 commit b0ceb98

File tree

9 files changed

+121
-1
lines changed

9 files changed

+121
-1
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ bin/
2222
.settings/
2323
.factorypath
2424
.checkstyle
25+
26+
## VSCode
27+
.vscode/
28+
.devcontainer/

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ allprojects { project ->
187187
}
188188

189189
ext {
190+
// not explicitly needed in subprojects, as the BOM for Spring Boot sets this version
190191
micrometerVersion = dependencyManagement.importedProperties['micrometer.version']
191-
// not explicitly needed in subprojects, as the BOM for Sprint Boot sets this version
192192
springFrameworkVersion = dependencyManagement.importedProperties['spring-framework.version']
193193
springSecurityVersion = dependencyManagement.importedProperties['spring-security.version']
194194
springCloudCommonsVersion = dependencyManagement.importedProperties['spring-cloud-commons.version']

grpc-client-spring-boot-autoconfigure/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dependencies {
1616
api project(':grpc-common-spring-boot')
1717
api 'org.springframework.boot:spring-boot-starter'
1818
api 'jakarta.validation:jakarta.validation-api'
19+
optionalSupportImplementation "io.micrometer:micrometer-observation"
1920
optionalSupportImplementation 'org.springframework.boot:spring-boot-starter-actuator'
2021
optionalSupportImplementation 'org.springframework.cloud:spring-cloud-starter-consul-discovery'
2122
optionalSupportImplementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (c) 2016-2022 Michael Zhang <[email protected]>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5+
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7+
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
8+
*
9+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10+
* Software.
11+
*
12+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13+
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16+
*/
17+
18+
package net.devh.boot.grpc.client.autoconfigure;
19+
20+
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
21+
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
22+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
23+
import org.springframework.context.annotation.Configuration;
24+
import org.springframework.core.annotation.Order;
25+
26+
import io.grpc.ClientInterceptor;
27+
import io.micrometer.core.instrument.binder.grpc.ObservationGrpcClientInterceptor;
28+
import io.micrometer.observation.ObservationRegistry;
29+
import net.devh.boot.grpc.client.interceptor.GrpcGlobalClientInterceptor;
30+
import net.devh.boot.grpc.common.util.InterceptorOrder;
31+
32+
/**
33+
* The configuration used to configure micrometer tracing for grpc.
34+
*
35+
* @author Dave Syer ([email protected])
36+
*/
37+
@Configuration(proxyBeanMethods = false)
38+
@ConditionalOnProperty(value = "management.tracing.grpc.enabled", matchIfMissing = true)
39+
@AutoConfigureAfter(name = "org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration")
40+
@ConditionalOnBean(ObservationRegistry.class)
41+
public class GrpcClientMicrometerTraceAutoConfiguration {
42+
43+
/**
44+
* Configures a global client interceptor that applies micrometer tracing logic to the requests.
45+
*
46+
* @param observations The observation registry bean.
47+
* @return The tracing client interceptor bean.
48+
*/
49+
@GrpcGlobalClientInterceptor
50+
@Order(InterceptorOrder.ORDER_TRACING_METRICS + 1)
51+
ClientInterceptor globalObservationClientInterceptorConfigurer(final ObservationRegistry observations) {
52+
return new ObservationGrpcClientInterceptor(observations);
53+
}
54+
55+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
net.devh.boot.grpc.client.autoconfigure.GrpcClientAutoConfiguration
22
net.devh.boot.grpc.client.autoconfigure.GrpcClientMetricAutoConfiguration
33
net.devh.boot.grpc.client.autoconfigure.GrpcClientHealthAutoConfiguration
4+
net.devh.boot.grpc.client.autoconfigure.GrpcClientMicrometerTraceAutoConfiguration
45
net.devh.boot.grpc.client.autoconfigure.GrpcClientSecurityAutoConfiguration
56
net.devh.boot.grpc.client.autoconfigure.GrpcDiscoveryClientAutoConfiguration

grpc-server-spring-boot-autoconfigure/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dependencies {
1515

1616
api project(':grpc-common-spring-boot')
1717
api 'org.springframework.boot:spring-boot-starter'
18+
optionalSupportImplementation "io.micrometer:micrometer-observation"
1819
optionalSupportImplementation 'org.springframework.boot:spring-boot-starter-actuator'
1920
optionalSupportImplementation 'org.springframework.security:spring-security-core'
2021
optionalSupportImplementation 'org.springframework.cloud:spring-cloud-starter-consul-discovery'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (c) 2016-2022 Michael Zhang <[email protected]>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5+
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7+
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
8+
*
9+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10+
* Software.
11+
*
12+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13+
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16+
*/
17+
18+
package net.devh.boot.grpc.server.autoconfigure;
19+
20+
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
21+
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
22+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
23+
import org.springframework.context.annotation.Configuration;
24+
import org.springframework.core.annotation.Order;
25+
26+
import io.grpc.ServerInterceptor;
27+
import io.micrometer.core.instrument.binder.grpc.ObservationGrpcServerInterceptor;
28+
import io.micrometer.observation.ObservationRegistry;
29+
import net.devh.boot.grpc.common.util.InterceptorOrder;
30+
import net.devh.boot.grpc.server.interceptor.GrpcGlobalServerInterceptor;
31+
32+
/**
33+
* The configuration used to configure micrometer tracing for grpc.
34+
*
35+
* @author Dave Syer ([email protected])
36+
*/
37+
@Configuration(proxyBeanMethods = false)
38+
@ConditionalOnProperty(value = "management.tracing.grpc.enabled", matchIfMissing = true)
39+
@AutoConfigureAfter(name = "org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration")
40+
@ConditionalOnBean(ObservationRegistry.class)
41+
public class GrpcServerMicrometerTraceAutoConfiguration {
42+
43+
/**
44+
* Configures a global server interceptor that applies micrometer tracing logic to the requests.
45+
*
46+
* @param observations The observation registry.
47+
* @return The tracing server interceptor bean.
48+
*/
49+
@GrpcGlobalServerInterceptor
50+
@Order(InterceptorOrder.ORDER_TRACING_METRICS + 1)
51+
public ServerInterceptor globalObservationGrpcServerInterceptorConfigurer(final ObservationRegistry observations) {
52+
return new ObservationGrpcServerInterceptor(observations);
53+
}
54+
55+
}

grpc-server-spring-boot-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ net.devh.boot.grpc.server.autoconfigure.GrpcReflectionServiceAutoConfiguration
88
net.devh.boot.grpc.server.autoconfigure.GrpcServerAutoConfiguration
99
net.devh.boot.grpc.server.autoconfigure.GrpcServerFactoryAutoConfiguration
1010
net.devh.boot.grpc.server.autoconfigure.GrpcServerMetricAutoConfiguration
11+
net.devh.boot.grpc.server.autoconfigure.GrpcServerMicrometerTraceAutoConfiguration
1112
net.devh.boot.grpc.server.autoconfigure.GrpcServerSecurityAutoConfiguration

tests/src/test/java/net/devh/boot/grpc/test/interceptor/DefaultServerInterceptorTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
import io.grpc.ServerInterceptor;
3636
import io.micrometer.core.instrument.binder.grpc.MetricCollectingServerInterceptor;
37+
import io.micrometer.core.instrument.binder.grpc.ObservationGrpcServerInterceptor;
3738
import net.devh.boot.grpc.server.interceptor.GlobalServerInterceptorRegistry;
3839
import net.devh.boot.grpc.server.scope.GrpcRequestScope;
3940
import net.devh.boot.grpc.server.security.interceptors.AuthenticatingServerInterceptor;
@@ -63,6 +64,7 @@ void testOrderingOfTheDefaultInterceptors() {
6364
final List<ServerInterceptor> expected = new ArrayList<>();
6465
expected.add(this.applicationContext.getBean(GrpcRequestScope.class));
6566
expected.add(this.applicationContext.getBean(MetricCollectingServerInterceptor.class));
67+
expected.add(this.applicationContext.getBean(ObservationGrpcServerInterceptor.class));
6668
expected.add(this.applicationContext.getBean(ExceptionTranslatingServerInterceptor.class));
6769
expected.add(this.applicationContext.getBean(AuthenticatingServerInterceptor.class));
6870
expected.add(this.applicationContext.getBean(AuthorizationCheckingServerInterceptor.class));

0 commit comments

Comments
 (0)