Spring sleuth 运行时采样和跟踪决策
Spring sleuth Runtime Sampling and Tracing Decision
我正在尝试将我的应用程序与 Spring 侦探集成。
我能够进行成功的集成,并且可以看到 span 被导出到 Zipkin。
我正在通过 http 导出 zipkin。
Spring 引导版本 - 1.5.10.RELEASE
侦探 - 1.3.2.RELEASE
云- Edgware.SR2
但现在我需要以更可控的方式执行此操作,因为应用程序已经 运行 投入生产,人们担心侦探通过在方法上添加 @NewSpan 可能产生的开销。
我需要在运行时决定是否应该添加 Trace(不讨论导出)。就像执行器跟踪一样,根本没有添加。我认为这对应用程序没有任何开销。把 X-B3-Sampled = 0 不是导出而是添加跟踪信息。类似于 skipPattern 属性 但在运行时。
如果服务超过特定阈值或发生异常,则始终导出跟踪。
如果我不将 Spans 导出到 zipkin,那么跟踪信息会产生任何开销吗?
这个解决方案怎么样?我想这将在运行时对特定请求进行采样。
@Bean
public Sampler customSampler(){
return new Sampler() {
@Override
public boolean isSampled(Span span) {
logger.info("Inside sampling "+span.getTraceId());
HttpServletRequest httpServletRequest=HttpUtils.getRequest();
if(httpServletRequest!=null && httpServletRequest.getServletPath().startsWith("/test")){
return true;
}else
return false;
}
};
}
people are scared about the overhead which sleuth can have by adding @NewSpan on the methods.
他们有关于开销的任何信息吗?他们打开它并且应用程序开始显着滞后吗?他们害怕什么?这是您正在做的每微秒都很重要的 high-frequency 交易应用程序吗?
I need to decide on runtime whether the Trace should be added or not (Not talking about exporting). Like for actuator trace is not getting added at all. I assume this will have no overhead on the application. Putting X-B3-Sampled = 0 is not exporting but adding tracing information. Something like skipPattern property but at runtime.
我认为这不可能。通过添加拦截器、方面等来设置检测。它们在应用程序初始化时启动。
Always export the trace if service exceeds a certain threshold or in case of Exception.
使用新的 Brave 示踪工具 (Sleuth 2.0.0),您将能够以更简单的方式完成此操作。在此版本之前,您必须实现自己的 SpanReporter
版本来验证标签(如果它包含 error
标签),如果是这种情况,请将其发送到 zipkin,否则不会。
If I am not exporting Spans to zipkin then will there be any overhead by tracing information?
是的,您需要传递跟踪数据。但是,开销很小。
我正在尝试将我的应用程序与 Spring 侦探集成。
我能够进行成功的集成,并且可以看到 span 被导出到 Zipkin。
我正在通过 http 导出 zipkin。
Spring 引导版本 - 1.5.10.RELEASE
侦探 - 1.3.2.RELEASE
云- Edgware.SR2
但现在我需要以更可控的方式执行此操作,因为应用程序已经 运行 投入生产,人们担心侦探通过在方法上添加 @NewSpan 可能产生的开销。
我需要在运行时决定是否应该添加 Trace(不讨论导出)。就像执行器跟踪一样,根本没有添加。我认为这对应用程序没有任何开销。把 X-B3-Sampled = 0 不是导出而是添加跟踪信息。类似于 skipPattern 属性 但在运行时。
如果服务超过特定阈值或发生异常,则始终导出跟踪。
如果我不将 Spans 导出到 zipkin,那么跟踪信息会产生任何开销吗?
这个解决方案怎么样?我想这将在运行时对特定请求进行采样。
@Bean
public Sampler customSampler(){
return new Sampler() {
@Override
public boolean isSampled(Span span) {
logger.info("Inside sampling "+span.getTraceId());
HttpServletRequest httpServletRequest=HttpUtils.getRequest();
if(httpServletRequest!=null && httpServletRequest.getServletPath().startsWith("/test")){
return true;
}else
return false;
}
};
}
people are scared about the overhead which sleuth can have by adding @NewSpan on the methods.
他们有关于开销的任何信息吗?他们打开它并且应用程序开始显着滞后吗?他们害怕什么?这是您正在做的每微秒都很重要的 high-frequency 交易应用程序吗?
I need to decide on runtime whether the Trace should be added or not (Not talking about exporting). Like for actuator trace is not getting added at all. I assume this will have no overhead on the application. Putting X-B3-Sampled = 0 is not exporting but adding tracing information. Something like skipPattern property but at runtime.
我认为这不可能。通过添加拦截器、方面等来设置检测。它们在应用程序初始化时启动。
Always export the trace if service exceeds a certain threshold or in case of Exception.
使用新的 Brave 示踪工具 (Sleuth 2.0.0),您将能够以更简单的方式完成此操作。在此版本之前,您必须实现自己的 SpanReporter
版本来验证标签(如果它包含 error
标签),如果是这种情况,请将其发送到 zipkin,否则不会。
If I am not exporting Spans to zipkin then will there be any overhead by tracing information?
是的,您需要传递跟踪数据。但是,开销很小。