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

io.github.hpsocket.soa.starter.skywalking.config.SoaSkyWalkingTaskConfig Maven / Gradle / Ivy


package io.github.hpsocket.soa.starter.skywalking.config;

import org.apache.skywalking.apm.toolkit.trace.TraceContext;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.core.task.TaskDecorator;

import io.github.hpsocket.soa.starter.skywalking.async.TracingRunnableWrapper;
import io.github.hpsocket.soa.starter.task.config.SoaTaskConfig;

/** HP-SOA Skywalking Task 配置 */
@AutoConfiguration
@ConditionalOnClass({TraceContext.class, SoaTaskConfig.class})
@AutoConfigureBefore(SoaTaskConfig.class)
public class SoaSkyWalkingTaskConfig
{
    public static final String mdcTaskDecoratorBeanName = SoaTaskConfig.mdcTaskDecoratorBeanName;
    
    /** Task 任务装饰器(注入 {@linkplain org.slf4j.MDC MDC} 和 traceId 调用链跟踪信息)*/
    @Bean(mdcTaskDecoratorBeanName)
    TaskDecorator taskDecorator()
    {
        return new TaskDecorator()
        {    
            @Override
            public Runnable decorate(Runnable runnable)
            {
                return TracingRunnableWrapper.of(runnable);
            }
        };
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy