Tracing Analysis Solution

目录

1. Single-thread

Solution

 Examples

2. Multi-Thread

Automating access to the MDC

MDC And Managed Threads

MDCInsertingServletFilter

3. DIstributed System

vs

quickly start 

refers:


The solution is about from Single application single thread to single app multi thread to distributed system. Here is the basic Skeleton.

 

 

 

1. Single-thread

Solution

ThreadLocal: The ThreadLocal construct allows us to store data that will be accessible only by a specific thread.

 Examples

1. Spring RequestContextHolder

2. Slf4j MDC (Mapped Diagnositc Contexts)

package org.slf4j;

public class MDC {
  //Put a context value as identified by key
  //into the current thread's context map.
  public static void put(String key, String val);

  //Get the context identified by the key parameter.
  public static String get(String key);

  //Remove the context identified by the key parameter.
  public static void remove(String key);

  //Clear all entries in the MDC.
  public static void clear();
}

Example : Basic MDC usage ( logback-examples/src/main/java/chapters/mdc/SimpleMDC.java)

package chapters.mdc;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;

import ch.qos.logback.classic.PatternLayout;
import ch.qos.log
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值