diff --git a/benchmarks/pom.xml b/benchmarks/pom.xml index 829e9b623..162e468b5 100644 --- a/benchmarks/pom.xml +++ b/benchmarks/pom.xml @@ -35,6 +35,7 @@ 1.8 2.2.0.RC1 5.8.0 + 3.11.0 @@ -116,7 +117,7 @@ com.squareup.okhttp3 okhttp - 3.11.0 + ${okhttp.version} provided @@ -158,6 +159,7 @@ + spring-snapshots @@ -170,6 +172,18 @@ false + + + jfrog-snapshots + JFrog Snapshots + https://oss.jfrog.org/oss-snapshot-local/ + + true + + + false + + spring-milestones Spring Milestones @@ -187,6 +201,35 @@ + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/libs-snapshot-local + + true + + + false + + + + spring-milestones + Spring Milestones + https://repo.spring.io/libs-milestone-local + + false + + + + spring-releases + Spring Releases + https://repo.spring.io/libs-release-local + + false + + + @@ -203,7 +246,7 @@ org.springframework.boot spring-boot-maven-plugin - 1.3.3.RELEASE + ${spring-boot.version} diff --git a/pom.xml b/pom.xml index f8f02110a..cb1ee2969 100644 --- a/pom.xml +++ b/pom.xml @@ -255,6 +255,7 @@ 2.2.0.BUILD-SNAPSHOT 2.2.0.BUILD-SNAPSHOT + 5.8.0 2.1.7.RELEASE 2.2.0.BUILD-SNAPSHOT diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/rpc/TraceRpcAutoConfigurationIntegrationTests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/rpc/TraceRpcAutoConfigurationIntegrationTests.java new file mode 100644 index 000000000..d5d9dbbe7 --- /dev/null +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/rpc/TraceRpcAutoConfigurationIntegrationTests.java @@ -0,0 +1,76 @@ +/* + * Copyright 2013-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.sleuth.instrument.rpc; + +import brave.rpc.RpcRequest; +import brave.rpc.RpcRuleSampler; +import brave.sampler.Matcher; +import brave.sampler.RateLimitingSampler; +import brave.sampler.Sampler; +import brave.sampler.SamplerFunction; +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.cloud.sleuth.util.ArrayListSpanReporter; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.test.context.junit4.SpringRunner; + +import static brave.rpc.RpcRequestMatchers.methodEquals; +import static brave.rpc.RpcRequestMatchers.serviceEquals; +import static brave.sampler.Matchers.and; +import static org.assertj.core.api.BDDAssertions.then; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = TraceRpcAutoConfigurationIntegrationTests.Config.class, webEnvironment = SpringBootTest.WebEnvironment.NONE) +public class TraceRpcAutoConfigurationIntegrationTests { + + @Autowired + @RpcServerSampler + SamplerFunction sampler; + + @Test + public void should_inject_rpc_sampler() { + then(this.sampler).isNotNull(); + } + + @EnableAutoConfiguration + @Configuration + public static class Config { + + @Bean + ArrayListSpanReporter reporter() { + return new ArrayListSpanReporter(); + } + + // tag::custom_rpc_server_sampler[] + @Bean(name = RpcServerSampler.NAME) + SamplerFunction myRpcSampler() { + Matcher userAuth = and(serviceEquals("users.UserService"), + methodEquals("GetUserToken")); + return RpcRuleSampler.newBuilder() + .putRule(serviceEquals("grpc.health.v1.Health"), Sampler.NEVER_SAMPLE) + .putRule(userAuth, RateLimitingSampler.create(100)).build(); + } + // end::custom_rpc_server_sampler[] + + } + +}