All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bizmda.log.trace.FeignTraceInterceptor Maven / Gradle / Ivy

There is a newer version: 1.0.0.RC4
Show newest version
package com.bizmda.log.trace;

import feign.RequestInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;

@ConditionalOnClass(value = {RequestInterceptor.class})
public class FeignTraceInterceptor {
//    @Resource
//    private TraceProperties traceProperties;

    @Bean
    public RequestInterceptor feignTraceInterceptor() {
        return template -> {
                //传递日志traceId
                String traceId = MDCTraceUtils.getTraceId();
                if (!StringUtils.isEmpty(traceId)) {
                    template.header(MDCTraceUtils.TRACE_ID_HEADER, traceId);
                }
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy