微服务全链路跟踪:jaeger集成grpc_grpc中使用jeager-程序员宅基地

技术标签: springcloud  微服务  springcloud技术分享  全链路  grpc  jaeger  

微服务全链路跟踪:grpc集成zipkin

微服务全链路跟踪:grpc集成jaeger

微服务全链路跟踪:springcloud集成jaeger

微服务全链路跟踪:jaeger集成istio,并兼容uber-trace-id与b3

微服务全链路跟踪:jaeger集成hystrix

微服务全链路跟踪:jaeger增加tag参数

码云地址:https://gitee.com/lpxs/lp-springcloud.git
有问题可以多沟通:[email protected]

本章节内容是基于springboot2集成net.devh.grpc的拓展

本章介绍grpc集成jaeger,本文主要参考jaeger官方文档进行扩展
https://github.com/opentracing-contrib/java-spring-cloud
https://github.com/opentracing-contrib/java-spring-jaeger

jaeger部署

这里就不列举jaeger代码或者容器部署了,网上很多

grpc工程目录

grpc-common grpc-client-starter grpc-server-starter
grpc-common
pom.xml依赖
      <dependencies>
     
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

    </dependencies>

相关实例

import io.opentracing.Span;

/**
 * An interface that defines how to get the current active span
 */
public interface ActiveSpanSource {
    

    /**
     * ActiveSpanSource implementation that always returns
     *  null as the active span
     */
    public static ActiveSpanSource NONE = new ActiveSpanSource() {
    
        @Override
        public Span getActiveSpan() {
    
            return null;
        }
    };
    
    /**
     * ActiveSpanSource implementation that returns the
     *  current span stored in the GRPC context under
     *  {@link OpenTracingContextKey}
     */
    public static ActiveSpanSource GRPC_CONTEXT = new ActiveSpanSource() {
    
        @Override 
        public Span getActiveSpan() {
    
            return OpenTracingContextKey.activeSpan();
        }
    };

    /**
     * @return the active span
     */
    public Span getActiveSpan();
}

import io.grpc.Context;
import io.opentracing.Span;

/**
 * A {@link Context} key for the current OpenTracing trace state.
 * 
 * Can be used to get the active span, or to set the active span for a scoped unit of work. 
 * See the <a href="../../../../../../README.rst">grpc-java OpenTracing docs</a> for use cases and examples.
 */
public class OpenTracingContextKey {
    
    
    public static final String KEY_NAME = "io.opentracing.active-span";
    private static final Context.Key<Span> key = Context.key(KEY_NAME);

    /**
     * @return the active span for the current request
     */ 
    public static Span activeSpan() {
    
        return key.get();
    }

    /**
     * @return the OpenTracing context key
     */
    public static Context.Key<Span> getKey() {
    
        return key;
    }
}
import io.grpc.MethodDescriptor;

/**
 * Interface that allows span operation names to be constructed from an RPC's 
 * method descriptor.
 */
public interface OperationNameConstructor {
    

    /**
     * Default span operation name constructor, that will return an RPC's method
     * name when constructOperationName is called.
     */ 
    public static OperationNameConstructor DEFAULT = new OperationNameConstructor() {
    
        @Override
        public <ReqT, RespT> String constructOperationName(MethodDescriptor<ReqT, RespT> method) {
    
            return method.getFullMethodName();
        }
    };

    /**
     * Constructs a span's operation name from the RPC's method.
     * @param method the rpc method to extract a name from 
     * @param <ReqT> the rpc request type
     * @param <RespT> the rpc response type
     * @return the operation name
     */
    public <ReqT, RespT> String constructOperationName(MethodDescriptor<ReqT, RespT> method);
}
grpc-server-starter
pom.xml依赖
   <dependencies>
        <!-- Spring Boot 配置处理 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>net.devh</groupId>
            <artifactId>grpc-server-spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>com.springcloud.grpc</groupId>
            <artifactId>grpc-common</artifactId>
        </dependency>
    </dependencies>
自动装配
import io.grpc.ClientInterceptor;
import io.grpc.ServerInterceptor;
import io.opentracing.Tracer;
import net.devh.boot.grpc.server.interceptor.GlobalServerInterceptorConfigurer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;


/**
 * @Auther: lipeng
 * @Date: 2019/1/3 19:34
 * @Description:
 */
@Configuration
public class GrpcOpenTracingConfig {
    

    @Autowired
    @Lazy
    private Tracer tracer;
    //grpc-spring-boot-starter provides @GrpcGlobalInterceptor to allow server-side interceptors to be registered with all
    //server stubs, we are just taking advantage of that to install the server-side gRPC tracer.
    @Bean
    ServerInterceptor grpcServerInterceptor() {
    
        return new ServerTracingInterceptor(tracer);
    }

    @Bean
    public GlobalServerInterceptorConfigurer globalInterceptorConfigurerAdapter(ServerInterceptor grpcServerInterceptor) {
    
        return registry -> registry.addServerInterceptors(grpcServerInterceptor);
    }
}

import com.google.common.collect.ImmutableMap;
import com.grpc.common.OpenTracingContextKey;
import com.grpc.common.OperationNameConstructor;
import io.grpc.BindableService;
import io.grpc.Context;
import io.grpc.Contexts;
import io.grpc.Metadata;
import io.grpc.ServerCall;
import io.grpc.ServerCallHandler;
import io.grpc.ServerInterceptor;
import io.grpc.ServerInterceptors;
import io.grpc.ServerServiceDefinition;
import io.grpc.ForwardingServerCallListener;

import io.opentracing.propagation.Format;
import io.opentracing.propagation.TextMapExtractAdapter;
import io.opentracing.Span;
import io.opentracing.SpanContext;
import io.opentracing.Tracer;

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * An intercepter that applies tracing via OpenTracing to all requests 
 * to the server.
 */
public class ServerTracingInterceptor implements ServerInterceptor {
    

    private final Tracer tracer;
    private final OperationNameConstructor operationNameConstructor;
    private final boolean streaming;
    private final boolean verbose;
    private final Set<ServerRequestAttribute> tracedAttributes;

    /**
     * @param tracer used to trace requests
     */
    public ServerTracingInterceptor(Tracer tracer) {
    
        this.tracer = tracer;
        this.operationNameConstructor = OperationNameConstructor.DEFAULT;
        this.streaming = false;
        this.verbose = false;
        this.tracedAttributes = new HashSet<ServerRequestAttribute>();
    }

    private ServerTracingInterceptor(Tracer tracer, OperationNameConstructor operationNameConstructor, boolean streaming,
        boolean verbose, Set<ServerRequestAttribute> tracedAttributes) {
    
        this.tracer = tracer;
        this.operationNameConstructor = operationNameConstructor;
        this.streaming = streaming;
        this.verbose = verbose;
        this.tracedAttributes = tracedAttributes;
    }

    /**
     * Add tracing to all requests made to this service.
     * @param serviceDef of the service to intercept
     * @return the serviceDef with a tracing interceptor
     */
    public ServerServiceDefinition intercept(ServerServiceDefinition serviceDef) {
    
        return ServerInterceptors.intercept(serviceDef, this);
    }

    /**
     * Add tracing to all requests made to this service.
     * @param bindableService to intercept
     * @return the serviceDef with a tracing interceptor
     */
    public ServerServiceDefinition intercept(BindableService bindableService) {
    
        return ServerInterceptors.intercept(bindableService, this);
    }
    
    @Override
    public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
        ServerCall<ReqT, RespT> call, 
        Metadata headers, 
        ServerCallHandler<ReqT, RespT> next
    ) {
    
        Map<String, String> headerMap = new HashMap<String, String>();
        for (String key : headers.keys()) {
    
            if (!key.endsWith(Metadata.BINARY_HEADER_SUFFIX)) {
    
                String value = headers.get(Metadata.Key.of(key, Metadata.ASCII_STRING_MARSHALLER));
                headerMap.put(key, value);
            }

        }

        final String operationName = operationNameConstructor.constructOperationName(call.getMethodDescriptor());
        final Span span = getSpanFromHeaders(headerMap, operationName);

        for (ServerRequestAttribute attr : this.tracedAttributes) {
    
            switch (attr) {
    
                case METHOD_TYPE:
                    span.setTag("grpc.method_type", call.getMethodDescriptor().getType().toString());
                    break;
                case METHOD_NAME:
                    span.setTag("grpc.method_name", call.getMethodDescriptor().getFullMethodName());
                    break;
                case CALL_ATTRIBUTES:
                    span.setTag("grpc.call_attributes", call.getAttributes().toString());
                    break;
                case HEADERS:
                    span.setTag("grpc.headers", headers.toString());
                    break;
            }
        }

        Context ctxWithSpan = Context.current().withValue(OpenTracingContextKey.getKey(), span);
        ServerCall.Listener<ReqT> listenerWithContext = Contexts
            .interceptCall(ctxWithSpan, call, headers, next);

        ServerCall.Listener<ReqT> tracingListenerWithContext = 
            new ForwardingServerCallListener.SimpleForwardingServerCallListener<ReqT>(listenerWithContext) {
    

            @Override
            public void onMessage(ReqT message) {
    
                if (streaming || verbose) {
     span.log(ImmutableMap.of("Message received", message)); }
                delegate().onMessage(message);
            }

            @Override 
            public void onHalfClose() {
    
                if (streaming) {
     span.log("Client finished sending messages"); }
                delegate().onHalfClose();
            }

            @Override
            public void onCancel() {
    
                span.log("Call cancelled");
                span.finish();
                delegate().onCancel();
            }

            @Override
            public void onComplete() {
    
                if (verbose) {
     span.log("Call completed"); }
                span.finish();
                delegate().onComplete();
            }
        };

        return tracingListenerWithContext; 
    }

    private Span getSpanFromHeaders(Map<String, String> headers, String operationName) {
    
        Span span;
        try {
    
            SpanContext parentSpanCtx = tracer.extract(Format.Builtin.HTTP_HEADERS, 
                new TextMapExtractAdapter(headers));
            if (parentSpanCtx == null) {
    
                span = tracer.buildSpan(operationName).startManual();
            } else {
    
                span = tracer.buildSpan(operationName).asChildOf(parentSpanCtx).startManual();
            }
        } catch (IllegalArgumentException iae){
    
            span = tracer.buildSpan(operationName)
                .withTag("Error", "Extract failed and an IllegalArgumentException was thrown")
                .startManual();
        }
        return span;  
    }

    /**
     * Builds the configuration of a ServerTracingInterceptor.
     */
    public static class Builder {
    
        private final Tracer tracer;
        private OperationNameConstructor operationNameConstructor;
        private boolean streaming;
        private boolean verbose;
        private Set<ServerRequestAttribute> tracedAttributes;

        /**
         * @param tracer to use for this intercepter
         * Creates a Builder with default configuration
         */
        public Builder(Tracer tracer) {
    
            this.tracer = tracer;
            this.operationNameConstructor = OperationNameConstructor.DEFAULT;
            this.streaming = false;
            this.verbose = false;
            this.tracedAttributes = new HashSet<ServerRequestAttribute>();
        }

        /**
         * @param operationNameConstructor for all spans created by this intercepter
         * @return this Builder with configured operation name
         */
        public Builder withOperationName(OperationNameConstructor operationNameConstructor) {
    
            this.operationNameConstructor = operationNameConstructor;
            return this;
        }

        /**
         * @param attributes to set as tags on server spans
         *  created by this intercepter
         * @return this Builder configured to trace request attributes
         */
        public Builder withTracedAttributes(ServerRequestAttribute... attributes) {
    
            this.tracedAttributes = new HashSet<ServerRequestAttribute>(Arrays.asList(attributes));
            return this;
        }

        /**
         * Logs streaming events to server spans.
         * @return this Builder configured to log streaming events
         */
        public Builder withStreaming() {
    
            this.streaming = true;
            return this;
        }

        /**
         * Logs all request life-cycle events to server spans.
         * @return this Builder configured to be verbose
         */
        public Builder withVerbosity() {
    
            this.verbose = true;
            return this;
        }

        /**
         * @return a ServerTracingInterceptor with this Builder's configuration
         */
        public ServerTracingInterceptor build() {
    
            return new ServerTracingInterceptor(this.tracer, this.operationNameConstructor, 
                this.streaming, this.verbose, this.tracedAttributes);
        }
    }

    public enum ServerRequestAttribute {
    
        HEADERS,
        METHOD_TYPE,
        METHOD_NAME,
        CALL_ATTRIBUTES
    }
}    
application.xml配置
opentracing:
  jaeger:
    udp-sender:
      host: 169.44.197.59
      port: 6831
    remote-reporter:
      flush-interval: 1000
      max-queue-size: 5000
    log-spans: false
    probabilistic-sampler:
      sampling-rate: 1

集成pom配置
<dependency>
            <groupId>com.springcloud.grpc</groupId>
            <artifactId>grpc-server-starter</artifactId>
            <version>1.0.0-SNAPSHOT</version>
        </dependency>
grpc-client-starter
pom.xml依赖
   <dependencies>
        <!-- Spring Boot 配置处理 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>net.devh</groupId>
            <artifactId>grpc-server-spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>com.springcloud.grpc</groupId>
            <artifactId>grpc-common</artifactId>
        </dependency>
    </dependencies>
自动装配
import io.grpc.ClientInterceptor;
import io.opentracing.Tracer;
import lombok.extern.slf4j.Slf4j;
import net.devh.boot.grpc.client.interceptor.GlobalClientInterceptorConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

/**
 * @Auther: lipeng
 * @Date: 2019/1/3 19:34
 * @Description:
 */
@Order(Ordered.LOWEST_PRECEDENCE)
@Configuration
@Slf4j
public class GrpcOpenTracingConfig {
    
    @Autowired
    @Lazy
    Tracer tracer;
    //We also create a client-side interceptor and put that in the context, this interceptor can then be injected into gRPC clients and
    //then applied to the managed channel.
    @Bean
    ClientInterceptor grpcClientInterceptor() {
    
        return new ClientTracingInterceptor(tracer);
    }

    @Bean
    public GlobalClientInterceptorConfigurer globalInterceptorConfigurerAdapter(ClientInterceptor grpcClientInterceptor) {
    
        return registry -> registry.addClientInterceptors(grpcClientInterceptor);
    }

}
import com.google.common.collect.ImmutableMap;
import com.grpc.common.ActiveSpanSource;
import com.grpc.common.OperationNameConstructor;
import io.grpc.*;
import io.opentracing.Span;
import io.opentracing.Tracer;
import io.opentracing.propagation.Format;
import io.opentracing.propagation.TextMap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.TimeUnit;

/** 
 * An intercepter that applies tracing via OpenTracing to all client requests. 
 */
@Slf4j
public class ClientTracingInterceptor implements ClientInterceptor {
    

    private final Tracer tracer;
    private final OperationNameConstructor operationNameConstructor;
    private final boolean streaming;
    private final boolean verbose;
    private final Set<ClientRequestAttribute> tracedAttributes;
    private final ActiveSpanSource activeSpanSource;

    /**
     * @param
     */
    public ClientTracingInterceptor(Tracer tracer) {
    
        this.tracer=tracer;
        this.operationNameConstructor = OperationNameConstructor.DEFAULT;
        this.streaming = false;
        this.verbose = false;
        this.tracedAttributes = new HashSet<ClientRequestAttribute>();
        this.activeSpanSource = ActiveSpanSource.GRPC_CONTEXT;
    }

    private ClientTracingInterceptor(Tracer tracer, OperationNameConstructor operationNameConstructor, boolean streaming,
        boolean verbose, Set<ClientRequestAttribute> tracedAttributes, ActiveSpanSource activeSpanSource) {
    
        this.tracer = tracer;
        this.operationNameConstructor = operationNameConstructor;
        this.streaming = streaming;
        this.verbose = verbose;
        this.tracedAttributes = tracedAttributes;
        this.activeSpanSource = activeSpanSource;
    }

    /**
     * Use this intercepter to trace all requests made by this client channel.
     * @param channel to be traced
     * @return intercepted channel
     */ 
    public Channel intercept(Channel channel) {
    
        return ClientInterceptors.intercept(channel, this);
    }

    @Override
    public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
        MethodDescriptor<ReqT, RespT> method, 
        CallOptions callOptions, 
        Channel next
    ) {
    
        final String operationName = operationNameConstructor.constructOperationName(method);

        Span activeSpan = this.activeSpanSource.getActiveSpan();
        final Span span = createSpanFromParent(activeSpan, operationName);

        for (ClientRequestAttribute attr : this.tracedAttributes) {
    
            switch (attr) {
    
                case ALL_CALL_OPTIONS:
                    span.setTag("grpc.call_options", callOptions.toString());
                    break;
                case AUTHORITY:
                    if (callOptions.getAuthority() == null) {
    
                        span.setTag("grpc.authority", "null");
                    } else {
    
                        span.setTag("grpc.authority", callOptions.getAuthority());                        
                    }
                    break;
                case COMPRESSOR:
                    if (callOptions.getCompressor() == null) {
    
                        span.setTag("grpc.compressor", "null");
                    } else {
    
                        span.setTag("grpc.compressor", callOptions.getCompressor());
                    }
                    break;
                case DEADLINE:
                    if (callOptions.getDeadline() == null) {
    
                        span.setTag("grpc.deadline_millis", "null");
                    } else {
    
                        span.setTag("grpc.deadline_millis", callOptions.getDeadline().timeRemaining(TimeUnit.MILLISECONDS));
                    }
                    break;
                case METHOD_NAME:
                    span.setTag("grpc.method_name", method.getFullMethodName());
                    break;
                case METHOD_TYPE:
                    if (method.getType() == null) {
    
                        span.setTag("grpc.method_type", "null");
                    } else {
    
                        span.setTag("grpc.method_type", method.getType().toString());
                    }
                    break;
                case HEADERS:
                	break;
            }
        }

        return new ForwardingClientCall.SimpleForwardingClientCall<ReqT, RespT>(next.newCall(method, callOptions)) {
    

            @Override
            public void start(Listener<RespT> responseListener, Metadata headers) {
    
                if (verbose) {
    
                    span.log("Started call");
                }
                if (tracedAttributes.contains(ClientRequestAttribute.HEADERS)) {
    
                    span.setTag("grpc.headers", headers.toString()); 
                }

                tracer.inject(span.context(), Format.Builtin.HTTP_HEADERS, new TextMap() {
    
                    @Override
                    public void put(String key, String value) {
    
                        Metadata.Key<String> headerKey = Metadata.Key.of(key, Metadata.ASCII_STRING_MARSHALLER);
                        headers.put(headerKey, value);
                    }
					@Override
					public Iterator<Entry<String, String>> iterator() {
    
						throw new UnsupportedOperationException(
								"TextMapInjectAdapter should only be used with Tracer.inject()");
					}
                });

                Listener<RespT> tracingResponseListener = new ForwardingClientCallListener
                    .SimpleForwardingClientCallListener<RespT>(responseListener) {
    

                    @Override
                    public void onHeaders(Metadata headers) {
    
                        if (verbose) {
     span.log(ImmutableMap.of("Response headers received", headers.toString())); }
                        delegate().onHeaders(headers);
                    }

                    @Override
                    public void onMessage(RespT message) {
    
                        if (streaming || verbose) {
     span.log("Response received"); }
                        delegate().onMessage(message);
                    }

                    @Override 
                    public void onClose(Status status, Metadata trailers) {
    
                        if (verbose) {
     
                            if (status.getCode().value() == 0) {
     span.log("Call closed"); }
                            else {
     span.log(ImmutableMap.of("Call failed", status.getDescription())); }
                        }
                        span.finish();
                        delegate().onClose(status, trailers);
                    }
                };
                delegate().start(tracingResponseListener, headers);
            }

            @Override 
            public void cancel(@Nullable String message, @Nullable Throwable cause) {
    
                String errorMessage;
                if (message == null) {
    
                    errorMessage = "Error";
                } else {
    
                    errorMessage = message;
                }
                if (cause == null) {
    
                    span.log(errorMessage);
                } else {
    
                    span.log(ImmutableMap.of(errorMessage, cause.getMessage()));
                }
                delegate().cancel(message, cause);
            }

            @Override
            public void halfClose() {
    
                if (streaming) {
     span.log("Finished sending messages"); }
                delegate().halfClose();
            }

            @Override
            public void sendMessage(ReqT message) {
    
                if (streaming || verbose) {
     span.log("Message sent"); }
                delegate().sendMessage(message);
            }
        };
    }
    
    private Span createSpanFromParent(Span parentSpan, String operationName) {
    
        if (parentSpan == null) {
    
            return tracer.buildSpan(operationName).startManual();
        } else {
    
            return tracer.buildSpan(operationName).asChildOf(parentSpan).startManual();
        }
    }

    /**
     * Builds the configuration of a ClientTracingInterceptor.
     */
    public static class Builder {
    

        private Tracer tracer;
        private OperationNameConstructor operationNameConstructor;
        private boolean streaming;
        private boolean verbose;
        private Set<ClientRequestAttribute> tracedAttributes;
        private ActiveSpanSource activeSpanSource;  

        /**
         * @param tracer to use for this intercepter
         * Creates a Builder with default configuration
         */
        public Builder(Tracer tracer) {
    
            this.tracer = tracer;
            this.operationNameConstructor = OperationNameConstructor.DEFAULT;
            this.streaming = false;
            this.verbose = false;
            this.tracedAttributes = new HashSet<ClientRequestAttribute>();
            this.activeSpanSource = ActiveSpanSource.GRPC_CONTEXT;
        } 

        /**
         * @param operationNameConstructor to name all spans created by this intercepter
         * @return this Builder with configured operation name
         */
        public Builder withOperationName(OperationNameConstructor operationNameConstructor) {
    
            this.operationNameConstructor = operationNameConstructor;
            return this;
        } 

        /**
         * Logs streaming events to client spans.
         * @return this Builder configured to log streaming events
         */
        public Builder withStreaming() {
    
            this.streaming = true;
            return this;
        }

        /**
         * @param tracedAttributes to set as tags on client spans
         *  created by this intercepter
         * @return this Builder configured to trace attributes
         */
        public Builder withTracedAttributes(ClientRequestAttribute... tracedAttributes) {
    
            this.tracedAttributes = new HashSet<ClientRequestAttribute>(
                Arrays.asList(tracedAttributes));
            return this;
        }

        /**
         * Logs all request life-cycle events to client spans.
         * @return this Builder configured to be verbose
         */
        public Builder withVerbosity() {
    
            this.verbose = true;
            return this;
        }

        /**
         * @param activeSpanSource that provides a method of getting the 
         *  active span before the client call
         * @return this Builder configured to start client span as children 
         *  of the span returned by activeSpanSource.getActiveSpan()
         */
        public Builder withActiveSpanSource(ActiveSpanSource activeSpanSource) {
    
            this.activeSpanSource = activeSpanSource;
            return this;
        }

        /**
         * @return a ClientTracingInterceptor with this Builder's configuration
         */
        public ClientTracingInterceptor build() {
    
            return new ClientTracingInterceptor(this.tracer, this.operationNameConstructor, 
                this.streaming, this.verbose, this.tracedAttributes, this.activeSpanSource);
        }
    }

    public enum ClientRequestAttribute {
    
        METHOD_TYPE,
        METHOD_NAME,
        DEADLINE,
        COMPRESSOR,
        AUTHORITY,
        ALL_CALL_OPTIONS,
        HEADERS
    }
}
application.xml配置
opentracing:
  jaeger:
    udp-sender:
      host: 169.44.197.59
      port: 6831
    remote-reporter:
      flush-interval: 1000
      max-queue-size: 5000
    log-spans: false
    probabilistic-sampler:
      sampling-rate: 1

集成pom配置
<dependency>
            <groupId>com.springcloud.grpc</groupId>
            <artifactId>grpc-client-starter</artifactId>
            <version>1.0.0-SNAPSHOT</version>
        </dependency>
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/lp19861126/article/details/96908909

智能推荐

c# 调用c++ lib静态库_c#调用lib-程序员宅基地

文章浏览阅读2w次,点赞7次,收藏51次。四个步骤1.创建C++ Win32项目动态库dll 2.在Win32项目动态库中添加 外部依赖项 lib头文件和lib库3.导出C接口4.c#调用c++动态库开始你的表演...①创建一个空白的解决方案,在解决方案中添加 Visual C++ , Win32 项目空白解决方案的创建:添加Visual C++ , Win32 项目这......_c#调用lib

deepin/ubuntu安装苹方字体-程序员宅基地

文章浏览阅读4.6k次。苹方字体是苹果系统上的黑体,挺好看的。注重颜值的网站都会使用,例如知乎:font-family: -apple-system, BlinkMacSystemFont, Helvetica Neue, PingFang SC, Microsoft YaHei, Source Han Sans SC, Noto Sans CJK SC, W..._ubuntu pingfang

html表单常见操作汇总_html表单的处理程序有那些-程序员宅基地

文章浏览阅读159次。表单表单概述表单标签表单域按钮控件demo表单标签表单标签基本语法结构<form action="处理数据程序的url地址“ method=”get|post“ name="表单名称”></form><!--action,当提交表单时,向何处发送表单中的数据,地址可以是相对地址也可以是绝对地址--><!--method将表单中的数据传送给服务器处理,get方式直接显示在url地址中,数据可以被缓存,且长度有限制;而post方式数据隐藏传输,_html表单的处理程序有那些

PHP设置谷歌验证器(Google Authenticator)实现操作二步验证_php otp 验证器-程序员宅基地

文章浏览阅读1.2k次。使用说明:开启Google的登陆二步验证(即Google Authenticator服务)后用户登陆时需要输入额外由手机客户端生成的一次性密码。实现Google Authenticator功能需要服务器端和客户端的支持。服务器端负责密钥的生成、验证一次性密码是否正确。客户端记录密钥后生成一次性密码。下载谷歌验证类库文件放到项目合适位置(我这边放在项目Vender下面)https://github.com/PHPGangsta/GoogleAuthenticatorPHP代码示例://引入谷_php otp 验证器

【Python】matplotlib.plot画图横坐标混乱及间隔处理_matplotlib更改横轴间距-程序员宅基地

文章浏览阅读4.3k次,点赞5次,收藏11次。matplotlib.plot画图横坐标混乱及间隔处理_matplotlib更改横轴间距

docker — 容器存储_docker 保存容器-程序员宅基地

文章浏览阅读2.2k次。①Storage driver 处理各镜像层及容器层的处理细节,实现了多层数据的堆叠,为用户 提供了多层数据合并后的统一视图②所有 Storage driver 都使用可堆叠图像层和写时复制(CoW)策略③docker info 命令可查看当系统上的 storage driver主要用于测试目的,不建议用于生成环境。_docker 保存容器

随便推点

网络拓扑结构_网络拓扑csdn-程序员宅基地

文章浏览阅读834次,点赞27次,收藏13次。网络拓扑结构是指计算机网络中各组件(如计算机、服务器、打印机、路由器、交换机等设备)及其连接线路在物理布局或逻辑构型上的排列形式。这种布局不仅描述了设备间的实际物理连接方式,也决定了数据在网络中流动的路径和方式。不同的网络拓扑结构影响着网络的性能、可靠性、可扩展性及管理维护的难易程度。_网络拓扑csdn

JS重写Date函数,兼容IOS系统_date.prototype 将所有 ios-程序员宅基地

文章浏览阅读1.8k次,点赞5次,收藏8次。IOS系统Date的坑要创建一个指定时间的new Date对象时,通常的做法是:new Date("2020-09-21 11:11:00")这行代码在 PC 端和安卓端都是正常的,而在 iOS 端则会提示 Invalid Date 无效日期。在IOS年月日中间的横岗许换成斜杠,也就是new Date("2020/09/21 11:11:00")通常为了兼容IOS的这个坑,需要做一些额外的特殊处理,笔者在开发的时候经常会忘了兼容IOS系统。所以就想试着重写Date函数,一劳永逸,避免每次ne_date.prototype 将所有 ios

如何将EXCEL表导入plsql数据库中-程序员宅基地

文章浏览阅读5.3k次。方法一:用PLSQL Developer工具。 1 在PLSQL Developer的sql window里输入select * from test for update; 2 按F8执行 3 打开锁, 再按一下加号. 鼠标点到第一列的列头,使全列成选中状态,然后粘贴,最后commit提交即可。(前提..._excel导入pl/sql

Git常用命令速查手册-程序员宅基地

文章浏览阅读83次。Git常用命令速查手册1、初始化仓库git init2、将文件添加到仓库git add 文件名 # 将工作区的某个文件添加到暂存区 git add -u # 添加所有被tracked文件中被修改或删除的文件信息到暂存区,不处理untracked的文件git add -A # 添加所有被tracked文件中被修改或删除的文件信息到暂存区,包括untracked的文件...

分享119个ASP.NET源码总有一个是你想要的_千博二手车源码v2023 build 1120-程序员宅基地

文章浏览阅读202次。分享119个ASP.NET源码总有一个是你想要的_千博二手车源码v2023 build 1120

【C++缺省函数】 空类默认产生的6个类成员函数_空类默认产生哪些类成员函数-程序员宅基地

文章浏览阅读1.8k次。版权声明:转载请注明出处 http://blog.csdn.net/irean_lau。目录(?)[+]1、缺省构造函数。2、缺省拷贝构造函数。3、 缺省析构函数。4、缺省赋值运算符。5、缺省取址运算符。6、 缺省取址运算符 const。[cpp] view plain copy_空类默认产生哪些类成员函数

推荐文章

热门文章

相关标签