First attempt to add GRPC instrumentation (#1139)

* Adding preliminary GRPC instrumentation to Sleuth

fixes #305
This commit is contained in:
Tyler Van Gorder
2018-12-04 13:22:03 -08:00
committed by Marcin Grzejszczak
parent a1832f6dd7
commit 415a7a6a2c
16 changed files with 2148 additions and 0 deletions

View File

@@ -1210,6 +1210,44 @@ You can disable it by setting `spring.sleuth.feign.processor.enabled` to `false`
If you set it to `false`, Spring Cloud Sleuth does not instrument any of your custom Feign components.
However, all the default instrumentation is still there.
=== gRPC
Spring Cloud Sleuth provides instrumentation for https://grpc.io/[gRPC] through `TraceGrpcAutoConfiguration`. You can disable it entirely by setting `spring.sleuth.grpc.enabled` to `false`.
==== Dependencies
IMPORTANT: The gRPC integration relies on two external libraries to instrument clients and servers and both of those libraries must be on the class path to enable the instrumentation.
Maven:
```
<dependency>
<groupId>io.github.lognet</groupId>
<artifactId>grpc-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-instrumentation-grpc</artifactId>
</dependency>
```
Gradle:
```
compile("io.github.lognet:grpc-spring-boot-starter")
compile("io.zipkin.brave:brave-instrumentation-grpc")
```
==== Server Instrumentation
Spring Cloud Sleuth leverages grpc-spring-boot-starter to register Brave's gRPC server interceptor with all services annotated with `@GRpcService`.
==== Client Instrumentation
gRPC clients leverage a `ManagedChannelBuilder` to construct a `ManagedChannel` used to communicate to the gRPC server. The native `ManagedChannelBuilder` provides static methods as entry points for construction of `ManagedChannel` instances, however, this mechanism is outside the influence of the Spring application context.
IMPORTANT: Spring Cloud Sleuth provides a `SpringAwareManagedChannelBuilder` that can be customized through the Spring application context and injected by gRPC clients. *This builder must be used when creating `ManagedChannel` instances.*
Sleuth creates a `TracingManagedChannelBuilderCustomizer` which inject Brave's client interceptor into the `SpringAwareManagedChannelBuilder`.
=== Asynchronous Communication
==== `@Async` Annotated methods

View File

@@ -233,6 +233,17 @@
<artifactId>spring-jms</artifactId>
<optional>true</optional>
</dependency>
<!-- GRPC Optional Dependencies -->
<dependency>
<groupId>io.github.lognet</groupId>
<artifactId>grpc-spring-boot-starter</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-instrumentation-grpc</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure-processor</artifactId>
@@ -311,6 +322,13 @@
<artifactId>activemq-ra</artifactId>
<scope>test</scope>
</dependency>
<!-- This forces the guava version to 20 within the test scope, which is required by GRPC -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>20.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>

View File

@@ -0,0 +1,31 @@
/*
* Copyright 2018 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
*
* http://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.grpc;
import io.grpc.ManagedChannelBuilder;
/**
* Callback interface that can be implemented by beans wishing to further customize the
* {@link io.grpc.ManagedChannelBuilder} via the {@link SpringAwareManagedChannelBuilder}.
*
* @author tyler.vangorder
*/
public interface GrpcManagedChannelBuilderCustomizer {
void customize(ManagedChannelBuilder<?> managedChannelBuilder);
}

View File

@@ -0,0 +1,76 @@
/*
* Copyright 2013-2018 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
*
* http://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.grpc;
import java.util.List;
import java.util.Optional;
import io.grpc.ManagedChannelBuilder;
import io.grpc.inprocess.InProcessChannelBuilder;
/**
* This is a Spring-aware managed channel builder that wraps the static entry points of
* gRPC's ManagedChannelBuilder to allow the configuration of the builder to be influenced
* by the Spring Context. All GrpcManagedChannelBuilderCustomizer instances included in
* the application context will have the opportunity to customize the builder.
*
* NOTE: There is nothing "Sleuth-specific" about this, however, there is currently not a
* good spring abstraction for client-side gRPC. Ideally, this could be moved up into
* grpc-spring-boot-starter or a new project could be created
* "spring-grpc"/"spring-cloud-grpc"?
*
* @author tyler.vangorder
*/
public class SpringAwareManagedChannelBuilder {
private List<GrpcManagedChannelBuilderCustomizer> customizers;
public SpringAwareManagedChannelBuilder(
Optional<List<GrpcManagedChannelBuilderCustomizer>> customizers) {
this.customizers = customizers.orElse(null);
}
public ManagedChannelBuilder<?> forAddress(String name, int port) {
ManagedChannelBuilder<?> builder = ManagedChannelBuilder.forAddress(name, port);
if (this.customizers != null) {
this.customizers.stream()
.forEach(customizer -> customizer.customize(builder));
}
return builder;
}
public ManagedChannelBuilder<?> forTarget(String target) {
ManagedChannelBuilder<?> builder = ManagedChannelBuilder.forTarget(target);
if (this.customizers != null) {
this.customizers.stream()
.forEach(customizer -> customizer.customize(builder));
}
return builder;
}
public ManagedChannelBuilder<?> inProcessChannelBuilder(String serverName) {
ManagedChannelBuilder<?> builder = InProcessChannelBuilder.forName(serverName);
if (this.customizers != null) {
this.customizers.stream()
.forEach(customizer -> customizer.customize(builder));
}
return builder;
}
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright 2013-2018 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
*
* http://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.grpc;
import java.util.List;
import java.util.Optional;
import brave.Tracing;
import brave.grpc.GrpcTracing;
import io.grpc.ServerInterceptor;
import org.lognet.springboot.grpc.GRpcGlobalInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
/**
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration
* Auto-configuration} enables span information propagation when using GRPC.
*
* This configuration is only enabled when both grpc-spring-boot-starter and
* brave-instrumentation-grpc are on the classpath.
*
* @author tyler.vangorder
*/
@ConditionalOnClass({ GrpcTracing.class, GRpcGlobalInterceptor.class })
@ConditionalOnProperty(value = "spring.sleuth.grpc.enabled", matchIfMissing = true)
@ConditionalOnBean(Tracing.class)
public class TraceGrpcAutoConfiguration {
@Bean
public GrpcTracing grpcTracing(Tracing tracing) {
return GrpcTracing.create(tracing);
}
// Register a global interceptor for both the server
@Bean
@GRpcGlobalInterceptor
ServerInterceptor grpcServerBraveInterceptor(GrpcTracing grpcTracing) {
return grpcTracing.newServerInterceptor();
}
// This is wrapper around gRPC's managed channel builder that is spring-aware
@Bean
@ConditionalOnMissingBean(SpringAwareManagedChannelBuilder.class)
public SpringAwareManagedChannelBuilder managedChannelBuilder(
Optional<List<GrpcManagedChannelBuilderCustomizer>> customizers) {
return new SpringAwareManagedChannelBuilder(customizers);
}
@Bean
GrpcManagedChannelBuilderCustomizer tracingManagedChannelBuilderCustomizer(
GrpcTracing grpcTracing) {
return new TracingManagedChannelBuilderCustomizer(grpcTracing);
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright 2018 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
*
* http://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.grpc;
import brave.grpc.GrpcTracing;
import io.grpc.ManagedChannelBuilder;
/**
* @author tyler.vangorder
*/
public class TracingManagedChannelBuilderCustomizer
implements GrpcManagedChannelBuilderCustomizer {
GrpcTracing grpcTracing;
public TracingManagedChannelBuilderCustomizer(GrpcTracing grpcTracing) {
this.grpcTracing = grpcTracing;
}
/**
* Add brave's client interceptor to the builder.
*/
@Override
public void customize(ManagedChannelBuilder<?> managedChannelBuilder) {
managedChannelBuilder.intercept(this.grpcTracing.newClientInterceptor());
}
}

View File

@@ -46,5 +46,11 @@
"type": "java.lang.Boolean",
"description": "Enable span information propagation when using Zuul.",
"defaultValue": true
},
{
"name": "spring.sleuth.grpc.enabled",
"type": "java.lang.Boolean",
"description": "Enable span information propagation when using GRPC.",
"defaultValue": true
}
]}

View File

@@ -18,6 +18,7 @@ org.springframework.cloud.sleuth.instrument.rxjava.RxJavaAutoConfiguration,\
org.springframework.cloud.sleuth.instrument.reactor.TraceReactorAutoConfiguration,\
org.springframework.cloud.sleuth.instrument.web.TraceWebFluxAutoConfiguration,\
org.springframework.cloud.sleuth.instrument.zuul.TraceZuulAutoConfiguration,\
org.springframework.cloud.sleuth.instrument.grpc.TraceGrpcAutoConfiguration,\
org.springframework.cloud.sleuth.instrument.messaging.TraceMessagingAutoConfiguration,\
org.springframework.cloud.sleuth.instrument.messaging.TraceSpringIntegrationAutoConfiguration,\
org.springframework.cloud.sleuth.instrument.messaging.websocket.TraceWebSocketAutoConfiguration,\

View File

@@ -0,0 +1,208 @@
/*
* Copyright 2018 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
*
* http://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.grpc;
import java.util.List;
import java.util.concurrent.TimeUnit;
import brave.sampler.Sampler;
import io.grpc.ClientInterceptor;
import io.grpc.ManagedChannel;
import io.grpc.ServerBuilder;
import io.grpc.stub.StreamObserver;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.lognet.springboot.grpc.GRpcServerBuilderConfigurer;
import org.lognet.springboot.grpc.GRpcService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import zipkin2.Span;
import zipkin2.reporter.Reporter;
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.instrument.grpc.stubs.HelloReply;
import org.springframework.cloud.sleuth.instrument.grpc.stubs.HelloRequest;
import org.springframework.cloud.sleuth.instrument.grpc.stubs.HelloServiceGrpc;
import org.springframework.cloud.sleuth.instrument.grpc.stubs.HelloServiceGrpc.HelloServiceBlockingStub;
import org.springframework.cloud.sleuth.instrument.grpc.stubs.HelloServiceGrpc.HelloServiceImplBase;
import org.springframework.cloud.sleuth.util.ArrayListSpanReporter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.util.ReflectionTestUtils;
import static org.assertj.core.api.Assertions.assertThat;
/**
* This integration testing class starts an in-process gRPC server and calls that server
* via the client.
*
* This class uses stubs and skeletons that were generated originally by the gRPC maven
* plugin and copied into a "stubs" sub-package.
*
* @author tyler.vangorder
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = GrpcTracingIntegrationTests.TestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.NONE, properties = {
"grpc.enabled=false", "grpc.inProcessServerName=testServer" })
@DirtiesContext
public class GrpcTracingIntegrationTests {
@Autowired
SpringAwareManagedChannelBuilder clientManagedChannelBuilder;
@Autowired
ArrayListSpanReporter reporter;
@Before
public void beforeTest() {
this.reporter.clear();
}
@After
public void afterTest() {
this.reporter.clear();
}
@Test
public void integrationTest() throws Exception {
ManagedChannel inProcessManagedChannel = this.clientManagedChannelBuilder
.inProcessChannelBuilder("testServer").directExecutor().build();
HelloServiceGrpcClient client = new HelloServiceGrpcClient(
inProcessManagedChannel);
assertThat(client.sayHello("Testy McTest Face"))
.isEqualTo("Hello Testy McTest Face");
List<Span> spans = this.reporter.getSpans();
assertThat(spans).hasSize(2);
assertThat(spans.get(0).kind()).isEqualTo(Span.Kind.SERVER);
assertThat(spans.get(1).kind()).isEqualTo(Span.Kind.CLIENT);
// ManagedChannel does not implement Closeable...
inProcessManagedChannel.shutdownNow();
}
@Test
public void channelBuilderFromAddress() {
// Simple test to make sure the interceptor is added to the builder.
this.clientManagedChannelBuilder.forAddress("test", 1234);
@SuppressWarnings("unchecked")
List<ClientInterceptor> clientInterceptors = (List<ClientInterceptor>) ReflectionTestUtils
.getField(this.clientManagedChannelBuilder, "customizers");
assertThat(clientInterceptors).hasSize(1);
}
@Test
public void channelBuilderFromTarget() {
// Simple test to make sure the interceptor is added to the builder.
this.clientManagedChannelBuilder.forTarget("test");
@SuppressWarnings("unchecked")
List<ClientInterceptor> clientInterceptors = (List<ClientInterceptor>) ReflectionTestUtils
.getField(this.clientManagedChannelBuilder, "customizers");
assertThat(clientInterceptors).hasSize(1);
}
@Configuration
@EnableAutoConfiguration
@Import(HelloGrpcService.class)
public static class TestConfiguration {
@Bean
Sampler alwaysSampler() {
return Sampler.ALWAYS_SAMPLE;
}
@Bean
Reporter<zipkin2.Span> reporter() {
return new ArrayListSpanReporter();
}
@Bean
GRpcServerBuilderConfigurer serverBuilderConfigurer() {
return new TestGrpcConfig();
}
}
public static class TestGrpcConfig extends GRpcServerBuilderConfigurer {
@Override
public void configure(ServerBuilder<?> serverBuilder) {
serverBuilder.directExecutor();
}
}
@GRpcService
public static class HelloGrpcService extends HelloServiceImplBase {
private Logger logger = LoggerFactory.getLogger(HelloGrpcService.class);
@Override
public void sayHello(HelloRequest request,
StreamObserver<HelloReply> responseObserver) {
String message = "Hello " + request.getName();
this.logger.debug("In the grpc server stub.");
HelloReply reply = HelloReply.newBuilder().setMessage(message).build();
responseObserver.onNext(reply);
responseObserver.onCompleted();
}
}
public static interface HelloServiceClient {
String sayHello(String name) throws Exception;
}
public static class HelloServiceGrpcClient implements HelloServiceClient {
private ManagedChannel managedChannel;
public HelloServiceGrpcClient(ManagedChannel managedChannel) {
this.managedChannel = managedChannel;
}
/*
* (non-Javadoc)
*
* @see sample.HelloServiceClient#sayHello(java.lang.String)
*/
@Override
public String sayHello(String name) throws Exception {
HelloServiceBlockingStub stub = HelloServiceGrpc
.newBlockingStub(this.managedChannel)
.withDeadlineAfter(3, TimeUnit.SECONDS);
HelloReply reply = stub
.sayHello(HelloRequest.newBuilder().setName(name).build());
return reply.getMessage();
}
}
}

View File

@@ -0,0 +1,588 @@
/*
* Copyright 2018 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
*
* http://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.grpc.stubs;
/**
* <pre>
* The response message containing the greetings
* </pre>
*
* Protobuf type {@code HelloReply}
*/
public final class HelloReply extends com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:HelloReply)
HelloReplyOrBuilder {
private static final long serialVersionUID = 0L;
// Use HelloReply.newBuilder() to construct.
private HelloReply(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private HelloReply() {
this.message_ = "";
}
@java.lang.Override
public final com.google.protobuf.UnknownFieldSet getUnknownFields() {
return this.unknownFields;
}
private HelloReply(com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
this();
if (extensionRegistry == null) {
throw new java.lang.NullPointerException();
}
int mutable_bitField0_ = 0;
com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet
.newBuilder();
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
default: {
if (!parseUnknownFieldProto3(input, unknownFields, extensionRegistry,
tag)) {
done = true;
}
break;
}
case 10: {
java.lang.String s = input.readStringRequireUtf8();
this.message_ = s;
break;
}
}
}
}
catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
}
catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(e)
.setUnfinishedMessage(this);
}
finally {
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
}
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return HelloServiceOuterClass.internal_static_sample_grpc_HelloReply_descriptor;
}
@Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() {
return HelloServiceOuterClass.internal_static_sample_grpc_HelloReply_fieldAccessorTable
.ensureFieldAccessorsInitialized(HelloReply.class,
HelloReply.Builder.class);
}
public static final int MESSAGE_FIELD_NUMBER = 1;
private volatile java.lang.Object message_;
/**
* <code>string message = 1;</code>
*/
@Override
public java.lang.String getMessage() {
java.lang.Object ref = this.message_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
}
else {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
this.message_ = s;
return s;
}
}
/**
* <code>string message = 1;</code>
*/
@Override
public com.google.protobuf.ByteString getMessageBytes() {
java.lang.Object ref = this.message_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b = com.google.protobuf.ByteString
.copyFromUtf8((java.lang.String) ref);
this.message_ = b;
return b;
}
else {
return (com.google.protobuf.ByteString) ref;
}
}
private byte memoizedIsInitialized = -1;
@Override
public final boolean isInitialized() {
byte isInitialized = this.memoizedIsInitialized;
if (isInitialized == 1) {
return true;
}
if (isInitialized == 0) {
return false;
}
this.memoizedIsInitialized = 1;
return true;
}
@Override
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (!getMessageBytes().isEmpty()) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, this.message_);
}
this.unknownFields.writeTo(output);
}
@Override
public int getSerializedSize() {
int size = this.memoizedSize;
if (size != -1) {
return size;
}
size = 0;
if (!getMessageBytes().isEmpty()) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1,
this.message_);
}
size += this.unknownFields.getSerializedSize();
this.memoizedSize = size;
return size;
}
@java.lang.Override
public boolean equals(final java.lang.Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof HelloReply)) {
return super.equals(obj);
}
HelloReply other = (HelloReply) obj;
boolean result = true;
result = result && getMessage().equals(other.getMessage());
result = result && this.unknownFields.equals(other.unknownFields);
return result;
}
@java.lang.Override
public int hashCode() {
if (this.memoizedHashCode != 0) {
return this.memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
hash = (37 * hash) + MESSAGE_FIELD_NUMBER;
hash = (53 * hash) + getMessage().hashCode();
hash = (29 * hash) + this.unknownFields.hashCode();
this.memoizedHashCode = hash;
return hash;
}
public static HelloReply parseFrom(java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static HelloReply parseFrom(java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static HelloReply parseFrom(com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static HelloReply parseFrom(com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static HelloReply parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static HelloReply parseFrom(byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static HelloReply parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static HelloReply parseFrom(java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input,
extensionRegistry);
}
public static HelloReply parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static HelloReply parseDelimitedFrom(java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
}
public static HelloReply parseFrom(com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static HelloReply parseFrom(com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input,
extensionRegistry);
}
@Override
public Builder newBuilderForType() {
return newBuilder();
}
public static Builder newBuilder() {
return DEFAULT_INSTANCE.toBuilder();
}
public static Builder newBuilder(HelloReply prototype) {
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}
@Override
public Builder toBuilder() {
return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this);
}
@java.lang.Override
protected Builder newBuilderForType(
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
/**
* <pre>
* The response message containing the greetings
* </pre>
*
* Protobuf type {@code HelloReply}
*/
public static final class Builder
extends com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:HelloReply)
HelloReplyOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return HelloServiceOuterClass.internal_static_sample_grpc_HelloReply_descriptor;
}
@Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() {
return HelloServiceOuterClass.internal_static_sample_grpc_HelloReply_fieldAccessorTable
.ensureFieldAccessorsInitialized(HelloReply.class,
HelloReply.Builder.class);
}
// Construct using HelloReply.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
}
}
@Override
public Builder clear() {
super.clear();
this.message_ = "";
return this;
}
@Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return HelloServiceOuterClass.internal_static_sample_grpc_HelloReply_descriptor;
}
@Override
public HelloReply getDefaultInstanceForType() {
return HelloReply.getDefaultInstance();
}
@Override
public HelloReply build() {
HelloReply result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@Override
public HelloReply buildPartial() {
HelloReply result = new HelloReply(this);
result.message_ = this.message_;
onBuilt();
return result;
}
@Override
public Builder clone() {
return super.clone();
}
@Override
public Builder setField(com.google.protobuf.Descriptors.FieldDescriptor field,
java.lang.Object value) {
return super.setField(field, value);
}
@Override
public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) {
return super.clearField(field);
}
@Override
public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) {
return super.clearOneof(oneof);
}
@Override
public Builder setRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field, int index,
java.lang.Object value) {
return super.setRepeatedField(field, index, value);
}
@Override
public Builder addRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
java.lang.Object value) {
return super.addRepeatedField(field, value);
}
@Override
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof HelloReply) {
return mergeFrom((HelloReply) other);
}
else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(HelloReply other) {
if (other == HelloReply.getDefaultInstance()) {
return this;
}
if (!other.getMessage().isEmpty()) {
this.message_ = other.message_;
onChanged();
}
this.mergeUnknownFields(other.unknownFields);
onChanged();
return this;
}
@Override
public final boolean isInitialized() {
return true;
}
@Override
public Builder mergeFrom(com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
HelloReply parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
}
catch (com.google.protobuf.InvalidProtocolBufferException e) {
parsedMessage = (HelloReply) e.getUnfinishedMessage();
throw e.unwrapIOException();
}
finally {
if (parsedMessage != null) {
mergeFrom(parsedMessage);
}
}
return this;
}
private java.lang.Object message_ = "";
/**
* <code>string message = 1;</code>
*/
@Override
public java.lang.String getMessage() {
java.lang.Object ref = this.message_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
this.message_ = s;
return s;
}
else {
return (java.lang.String) ref;
}
}
/**
* <code>string message = 1;</code>
*/
@Override
public com.google.protobuf.ByteString getMessageBytes() {
java.lang.Object ref = this.message_;
if (ref instanceof String) {
com.google.protobuf.ByteString b = com.google.protobuf.ByteString
.copyFromUtf8((java.lang.String) ref);
this.message_ = b;
return b;
}
else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <code>string message = 1;</code>
*/
public Builder setMessage(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
this.message_ = value;
onChanged();
return this;
}
/**
* <code>string message = 1;</code>
*/
public Builder clearMessage() {
this.message_ = getDefaultInstance().getMessage();
onChanged();
return this;
}
/**
* <code>string message = 1;</code>
*/
public Builder setMessageBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
this.message_ = value;
onChanged();
return this;
}
@Override
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFieldsProto3(unknownFields);
}
@Override
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.mergeUnknownFields(unknownFields);
}
// @@protoc_insertion_point(builder_scope:HelloReply)
}
// @@protoc_insertion_point(class_scope:HelloReply)
private static final HelloReply DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new HelloReply();
}
public static HelloReply getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<HelloReply> PARSER = new com.google.protobuf.AbstractParser<HelloReply>() {
@Override
public HelloReply parsePartialFrom(com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new HelloReply(input, extensionRegistry);
}
};
public static com.google.protobuf.Parser<HelloReply> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<HelloReply> getParserForType() {
return PARSER;
}
@Override
public HelloReply getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2018 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
*
* http://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.grpc.stubs;
public interface HelloReplyOrBuilder extends
// @@protoc_insertion_point(interface_extends:sample.grpc.HelloReply)
com.google.protobuf.MessageOrBuilder {
/**
* <code>string message = 1;</code>
*/
java.lang.String getMessage();
/**
* <code>string message = 1;</code>
*/
com.google.protobuf.ByteString getMessageBytes();
}

View File

@@ -0,0 +1,588 @@
/*
* Copyright 2018 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
*
* http://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.grpc.stubs;
/**
* <pre>
* The request message containing the user's name.
* </pre>
*
* Protobuf type {@code HelloRequest}
*/
public final class HelloRequest extends com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:HelloRequest)
HelloRequestOrBuilder {
private static final long serialVersionUID = 0L;
// Use HelloRequest.newBuilder() to construct.
private HelloRequest(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private HelloRequest() {
this.name_ = "";
}
@java.lang.Override
public final com.google.protobuf.UnknownFieldSet getUnknownFields() {
return this.unknownFields;
}
private HelloRequest(com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
this();
if (extensionRegistry == null) {
throw new java.lang.NullPointerException();
}
int mutable_bitField0_ = 0;
com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet
.newBuilder();
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
default: {
if (!parseUnknownFieldProto3(input, unknownFields, extensionRegistry,
tag)) {
done = true;
}
break;
}
case 10: {
java.lang.String s = input.readStringRequireUtf8();
this.name_ = s;
break;
}
}
}
}
catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
}
catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(e)
.setUnfinishedMessage(this);
}
finally {
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
}
}
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return HelloServiceOuterClass.internal_static_sample_grpc_HelloRequest_descriptor;
}
@Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() {
return HelloServiceOuterClass.internal_static_sample_grpc_HelloRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(HelloRequest.class,
HelloRequest.Builder.class);
}
public static final int NAME_FIELD_NUMBER = 1;
private volatile java.lang.Object name_;
/**
* <code>string name = 1;</code>
*/
@Override
public java.lang.String getName() {
java.lang.Object ref = this.name_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
}
else {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
this.name_ = s;
return s;
}
}
/**
* <code>string name = 1;</code>
*/
@Override
public com.google.protobuf.ByteString getNameBytes() {
java.lang.Object ref = this.name_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b = com.google.protobuf.ByteString
.copyFromUtf8((java.lang.String) ref);
this.name_ = b;
return b;
}
else {
return (com.google.protobuf.ByteString) ref;
}
}
private byte memoizedIsInitialized = -1;
@Override
public final boolean isInitialized() {
byte isInitialized = this.memoizedIsInitialized;
if (isInitialized == 1) {
return true;
}
if (isInitialized == 0) {
return false;
}
this.memoizedIsInitialized = 1;
return true;
}
@Override
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (!getNameBytes().isEmpty()) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, this.name_);
}
this.unknownFields.writeTo(output);
}
@Override
public int getSerializedSize() {
int size = this.memoizedSize;
if (size != -1) {
return size;
}
size = 0;
if (!getNameBytes().isEmpty()) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1,
this.name_);
}
size += this.unknownFields.getSerializedSize();
this.memoizedSize = size;
return size;
}
@java.lang.Override
public boolean equals(final java.lang.Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof HelloRequest)) {
return super.equals(obj);
}
HelloRequest other = (HelloRequest) obj;
boolean result = true;
result = result && getName().equals(other.getName());
result = result && this.unknownFields.equals(other.unknownFields);
return result;
}
@java.lang.Override
public int hashCode() {
if (this.memoizedHashCode != 0) {
return this.memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
hash = (37 * hash) + NAME_FIELD_NUMBER;
hash = (53 * hash) + getName().hashCode();
hash = (29 * hash) + this.unknownFields.hashCode();
this.memoizedHashCode = hash;
return hash;
}
public static HelloRequest parseFrom(java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static HelloRequest parseFrom(java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static HelloRequest parseFrom(com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static HelloRequest parseFrom(com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static HelloRequest parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static HelloRequest parseFrom(byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static HelloRequest parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static HelloRequest parseFrom(java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input,
extensionRegistry);
}
public static HelloRequest parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static HelloRequest parseDelimitedFrom(java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
}
public static HelloRequest parseFrom(com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
}
public static HelloRequest parseFrom(com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input,
extensionRegistry);
}
@Override
public Builder newBuilderForType() {
return newBuilder();
}
public static Builder newBuilder() {
return DEFAULT_INSTANCE.toBuilder();
}
public static Builder newBuilder(HelloRequest prototype) {
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}
@Override
public Builder toBuilder() {
return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this);
}
@java.lang.Override
protected Builder newBuilderForType(
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
/**
* <pre>
* The request message containing the user's name.
* </pre>
*
* Protobuf type {@code HelloRequest}
*/
public static final class Builder
extends com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:HelloRequest)
HelloRequestOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
return HelloServiceOuterClass.internal_static_sample_grpc_HelloRequest_descriptor;
}
@Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() {
return HelloServiceOuterClass.internal_static_sample_grpc_HelloRequest_fieldAccessorTable
.ensureFieldAccessorsInitialized(HelloRequest.class,
HelloRequest.Builder.class);
}
// Construct using HelloRequest.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {
}
}
@Override
public Builder clear() {
super.clear();
this.name_ = "";
return this;
}
@Override
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
return HelloServiceOuterClass.internal_static_sample_grpc_HelloRequest_descriptor;
}
@Override
public HelloRequest getDefaultInstanceForType() {
return HelloRequest.getDefaultInstance();
}
@Override
public HelloRequest build() {
HelloRequest result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@Override
public HelloRequest buildPartial() {
HelloRequest result = new HelloRequest(this);
result.name_ = this.name_;
onBuilt();
return result;
}
@Override
public Builder clone() {
return super.clone();
}
@Override
public Builder setField(com.google.protobuf.Descriptors.FieldDescriptor field,
java.lang.Object value) {
return super.setField(field, value);
}
@Override
public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) {
return super.clearField(field);
}
@Override
public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) {
return super.clearOneof(oneof);
}
@Override
public Builder setRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field, int index,
java.lang.Object value) {
return super.setRepeatedField(field, index, value);
}
@Override
public Builder addRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
java.lang.Object value) {
return super.addRepeatedField(field, value);
}
@Override
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof HelloRequest) {
return mergeFrom((HelloRequest) other);
}
else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(HelloRequest other) {
if (other == HelloRequest.getDefaultInstance()) {
return this;
}
if (!other.getName().isEmpty()) {
this.name_ = other.name_;
onChanged();
}
this.mergeUnknownFields(other.unknownFields);
onChanged();
return this;
}
@Override
public final boolean isInitialized() {
return true;
}
@Override
public Builder mergeFrom(com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
HelloRequest parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
}
catch (com.google.protobuf.InvalidProtocolBufferException e) {
parsedMessage = (HelloRequest) e.getUnfinishedMessage();
throw e.unwrapIOException();
}
finally {
if (parsedMessage != null) {
mergeFrom(parsedMessage);
}
}
return this;
}
private java.lang.Object name_ = "";
/**
* <code>string name = 1;</code>
*/
@Override
public java.lang.String getName() {
java.lang.Object ref = this.name_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
this.name_ = s;
return s;
}
else {
return (java.lang.String) ref;
}
}
/**
* <code>string name = 1;</code>
*/
@Override
public com.google.protobuf.ByteString getNameBytes() {
java.lang.Object ref = this.name_;
if (ref instanceof String) {
com.google.protobuf.ByteString b = com.google.protobuf.ByteString
.copyFromUtf8((java.lang.String) ref);
this.name_ = b;
return b;
}
else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <code>string name = 1;</code>
*/
public Builder setName(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
this.name_ = value;
onChanged();
return this;
}
/**
* <code>string name = 1;</code>
*/
public Builder clearName() {
this.name_ = getDefaultInstance().getName();
onChanged();
return this;
}
/**
* <code>string name = 1;</code>
*/
public Builder setNameBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
this.name_ = value;
onChanged();
return this;
}
@Override
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFieldsProto3(unknownFields);
}
@Override
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.mergeUnknownFields(unknownFields);
}
// @@protoc_insertion_point(builder_scope:HelloRequest)
}
// @@protoc_insertion_point(class_scope:HelloRequest)
private static final HelloRequest DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new HelloRequest();
}
public static HelloRequest getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<HelloRequest> PARSER = new com.google.protobuf.AbstractParser<HelloRequest>() {
@Override
public HelloRequest parsePartialFrom(com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new HelloRequest(input, extensionRegistry);
}
};
public static com.google.protobuf.Parser<HelloRequest> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<HelloRequest> getParserForType() {
return PARSER;
}
@Override
public HelloRequest getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2018 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
*
* http://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.grpc.stubs;
public interface HelloRequestOrBuilder extends
// @@protoc_insertion_point(interface_extends:sample.grpc.HelloRequest)
com.google.protobuf.MessageOrBuilder {
/**
* <code>string name = 1;</code>
*/
java.lang.String getName();
/**
* <code>string name = 1;</code>
*/
com.google.protobuf.ByteString getNameBytes();
}

View File

@@ -0,0 +1,331 @@
/*
* Copyright 2018 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
*
* http://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.grpc.stubs;
import static io.grpc.MethodDescriptor.generateFullMethodName;
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
/**
* <pre>
* The Hello service definition.
* </pre>
*/
@javax.annotation.Generated(value = "by gRPC proto compiler (version 1.15.1)", comments = "Source: HelloService.proto")
public final class HelloServiceGrpc {
private HelloServiceGrpc() {
}
public static final String SERVICE_NAME = "HelloService";
// Static method descriptors that strictly reflect the proto.
private static volatile io.grpc.MethodDescriptor<HelloRequest, HelloReply> getSayHelloMethod;
@io.grpc.stub.annotations.RpcMethod(fullMethodName = SERVICE_NAME + '/'
+ "SayHello", requestType = HelloRequest.class, responseType = HelloReply.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<HelloRequest, HelloReply> getSayHelloMethod() {
io.grpc.MethodDescriptor<HelloRequest, HelloReply> getSayHelloMethod;
if ((getSayHelloMethod = HelloServiceGrpc.getSayHelloMethod) == null) {
synchronized (HelloServiceGrpc.class) {
if ((getSayHelloMethod = HelloServiceGrpc.getSayHelloMethod) == null) {
HelloServiceGrpc.getSayHelloMethod = getSayHelloMethod = io.grpc.MethodDescriptor
.<HelloRequest, HelloReply>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(
generateFullMethodName("HelloService", "SayHello"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils
.marshaller(HelloRequest.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils
.marshaller(HelloReply.getDefaultInstance()))
.setSchemaDescriptor(
new HelloServiceMethodDescriptorSupplier("SayHello"))
.build();
}
}
}
return getSayHelloMethod;
}
/**
* Creates a new async stub that supports all call types for the service
*/
public static HelloServiceStub newStub(io.grpc.Channel channel) {
return new HelloServiceStub(channel);
}
/**
* Creates a new blocking-style stub that supports unary and streaming
* output calls on the service
*/
public static HelloServiceBlockingStub newBlockingStub(io.grpc.Channel channel) {
return new HelloServiceBlockingStub(channel);
}
/**
* Creates a new ListenableFuture-style stub that supports unary calls on
* the service
*/
public static HelloServiceFutureStub newFutureStub(io.grpc.Channel channel) {
return new HelloServiceFutureStub(channel);
}
/**
* <pre>
* The Hello service definition.
* </pre>
*/
public static abstract class HelloServiceImplBase implements io.grpc.BindableService {
/**
* <pre>
* Sends a greeting
* </pre>
*/
public void sayHello(HelloRequest request,
io.grpc.stub.StreamObserver<HelloReply> responseObserver) {
asyncUnimplementedUnaryCall(getSayHelloMethod(), responseObserver);
}
@java.lang.Override
public final io.grpc.ServerServiceDefinition bindService() {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
.addMethod(getSayHelloMethod(),
asyncUnaryCall(new MethodHandlers<HelloRequest, HelloReply>(
this, METHODID_SAY_HELLO)))
.build();
}
}
/**
* <pre>
* The Hello service definition.
* </pre>
*/
public static final class HelloServiceStub
extends io.grpc.stub.AbstractStub<HelloServiceStub> {
private HelloServiceStub(io.grpc.Channel channel) {
super(channel);
}
private HelloServiceStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected HelloServiceStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
return new HelloServiceStub(channel, callOptions);
}
/**
* <pre>
* Sends a greeting
* </pre>
*/
public void sayHello(HelloRequest request,
io.grpc.stub.StreamObserver<HelloReply> responseObserver) {
asyncUnaryCall(getChannel().newCall(getSayHelloMethod(), getCallOptions()),
request, responseObserver);
}
}
/**
* <pre>
* The Hello service definition.
* </pre>
*/
public static final class HelloServiceBlockingStub
extends io.grpc.stub.AbstractStub<HelloServiceBlockingStub> {
private HelloServiceBlockingStub(io.grpc.Channel channel) {
super(channel);
}
private HelloServiceBlockingStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected HelloServiceBlockingStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
return new HelloServiceBlockingStub(channel, callOptions);
}
/**
* <pre>
* Sends a greeting
* </pre>
*/
public HelloReply sayHello(HelloRequest request) {
return blockingUnaryCall(getChannel(), getSayHelloMethod(), getCallOptions(),
request);
}
}
/**
* <pre>
* The Hello service definition.
* </pre>
*/
public static final class HelloServiceFutureStub
extends io.grpc.stub.AbstractStub<HelloServiceFutureStub> {
private HelloServiceFutureStub(io.grpc.Channel channel) {
super(channel);
}
private HelloServiceFutureStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected HelloServiceFutureStub build(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
return new HelloServiceFutureStub(channel, callOptions);
}
/**
* <pre>
* Sends a greeting
* </pre>
*/
public com.google.common.util.concurrent.ListenableFuture<HelloReply> sayHello(
HelloRequest request) {
return futureUnaryCall(
getChannel().newCall(getSayHelloMethod(), getCallOptions()), request);
}
}
private static final int METHODID_SAY_HELLO = 0;
private static final class MethodHandlers<Req, Resp>
implements io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
private final HelloServiceImplBase serviceImpl;
private final int methodId;
MethodHandlers(HelloServiceImplBase serviceImpl, int methodId) {
this.serviceImpl = serviceImpl;
this.methodId = methodId;
}
@java.lang.Override
@java.lang.SuppressWarnings("unchecked")
public void invoke(Req request,
io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (this.methodId) {
case METHODID_SAY_HELLO:
this.serviceImpl.sayHello((HelloRequest) request,
(io.grpc.stub.StreamObserver<HelloReply>) responseObserver);
break;
default:
throw new AssertionError();
}
}
@java.lang.Override
@java.lang.SuppressWarnings("unchecked")
public io.grpc.stub.StreamObserver<Req> invoke(
io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (this.methodId) {
default:
throw new AssertionError();
}
}
}
private static abstract class HelloServiceBaseDescriptorSupplier
implements io.grpc.protobuf.ProtoFileDescriptorSupplier,
io.grpc.protobuf.ProtoServiceDescriptorSupplier {
HelloServiceBaseDescriptorSupplier() {
}
@java.lang.Override
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
return HelloServiceOuterClass.getDescriptor();
}
@java.lang.Override
public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
return getFileDescriptor().findServiceByName("HelloService");
}
}
private static final class HelloServiceFileDescriptorSupplier
extends HelloServiceBaseDescriptorSupplier {
HelloServiceFileDescriptorSupplier() {
}
}
private static final class HelloServiceMethodDescriptorSupplier
extends HelloServiceBaseDescriptorSupplier
implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
private final String methodName;
HelloServiceMethodDescriptorSupplier(String methodName) {
this.methodName = methodName;
}
@java.lang.Override
public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
return getServiceDescriptor().findMethodByName(this.methodName);
}
}
private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
public static io.grpc.ServiceDescriptor getServiceDescriptor() {
io.grpc.ServiceDescriptor result = serviceDescriptor;
if (result == null) {
synchronized (HelloServiceGrpc.class) {
result = serviceDescriptor;
if (result == null) {
serviceDescriptor = result = io.grpc.ServiceDescriptor
.newBuilder(SERVICE_NAME)
.setSchemaDescriptor(new HelloServiceFileDescriptorSupplier())
.addMethod(getSayHelloMethod()).build();
}
}
}
return result;
}
}

View File

@@ -0,0 +1,75 @@
/*
* Copyright 2018 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
*
* http://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.grpc.stubs;
public final class HelloServiceOuterClass {
private HelloServiceOuterClass() {
}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistryLite registry) {
}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry);
}
static final com.google.protobuf.Descriptors.Descriptor internal_static_sample_grpc_HelloRequest_descriptor;
static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_sample_grpc_HelloRequest_fieldAccessorTable;
static final com.google.protobuf.Descriptors.Descriptor internal_static_sample_grpc_HelloReply_descriptor;
static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_sample_grpc_HelloReply_fieldAccessorTable;
public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() {
return descriptor;
}
private static com.google.protobuf.Descriptors.FileDescriptor descriptor;
static {
java.lang.String[] descriptorData = {
"\n\022HelloService.proto\022\013sample.grpc\"\034\n\014Hel"
+ "loRequest\022\014\n\004name\030\001 \001(\t\"\035\n\nHelloReply\022\017\n"
+ "\007message\030\001 \001(\t2P\n\014HelloService\022@\n\010SayHel"
+ "lo\022\031.sample.grpc.HelloRequest\032\027.sample.g"
+ "rpc.HelloReply\"\000B\002P\001b\006proto3" };
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@Override
public com.google.protobuf.ExtensionRegistry assignDescriptors(
com.google.protobuf.Descriptors.FileDescriptor root) {
descriptor = root;
return null;
}
};
com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(
descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] {},
assigner);
internal_static_sample_grpc_HelloRequest_descriptor = getDescriptor()
.getMessageTypes().get(0);
internal_static_sample_grpc_HelloRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_sample_grpc_HelloRequest_descriptor,
new java.lang.String[] { "Name", });
internal_static_sample_grpc_HelloReply_descriptor = getDescriptor()
.getMessageTypes().get(1);
internal_static_sample_grpc_HelloReply_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_sample_grpc_HelloReply_descriptor,
new java.lang.String[] { "Message", });
}
// @@protoc_insertion_point(outer_class_scope)
}

View File

@@ -31,6 +31,7 @@
<description>Spring Cloud Sleuth Dependencies</description>
<properties>
<brave.opentracing.version>0.33.7</brave.opentracing.version>
<grpc.spring.boot.version>3.0.0</grpc.spring.boot.version>
</properties>
<dependencyManagement>
<dependencies>
@@ -75,6 +76,12 @@
<artifactId>brave-opentracing</artifactId>
<version>${brave.opentracing.version}</version>
</dependency>
<!-- GRPC -->
<dependency>
<groupId>io.github.lognet</groupId>
<artifactId>grpc-spring-boot-starter</artifactId>
<version>${grpc.spring.boot.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<profiles>