How to do time tracing for *monolithic* clearly-moduled systems (not distributed systems), or should we do that?

huangapple go评论82阅读模式
英文:

How to do time tracing for *monolithic* clearly-moduled systems (not distributed systems), or should we do that?

问题

我看到了许多针对微服务的分布式跟踪解决方案。例如,Spring Cloud Sleuth,Zipkin的Brave等。然而,我有一个拆分得很清晰的单体服务,包含许多模块。因此,这些解决方案对我不适用。

依我之见,我需要一个跟踪系统来告诉我每个模块(类比非单体系统中的微服务)花费了多少时间。然而,我找不到任何解决方案。因此,我想知道我的需求实际上是不是一个真正的需求,而是一个伪需求?或者,如果这是一个真正的需求,我该如何找到一些解决方案?

谢谢!

英文:

I see many distributed tracing solutions for microservices. For instance, Spring Cloud Sleuth, Zipkin’s Brave, etc. However, I have a monolithic service with many modules separated clearly. Thus, those solutions do not work for me.

IMHO I need a tracing system to tell me which module (analogy to which microservice in a non-monolithic system) spends how much time. However, I could not find any. Thus, I wonder whether my need is actually not a real need but a pseudo need? Or, if it is a real need, how can I find some solutions?

Thanks!

答案1

得分: 1

这种情况下使用Sleuth可能是不常见的(Sleuth主要用于实现分布式跟踪和监控系统内的关键延迟)。

但是... Sleuth与Logback和SLF4J等日志框架集成,以添加有助于使用日志跟踪和诊断问题的唯一标识。

因此,当请求进入系统时,Sleuth将为其分配一个TraceId,该请求中的所有不同步骤,甚至跨应用程序和线程边界,都将具有相同的traceId

如果您想要监视某个模块内部执行的不同复杂操作,可以使用专用的Span来包装这些操作。

示例:

Span newSpan = tracer.nextSpan().name("module1Span").start();
try (SpanInScope ws = tracer.withSpanInScope(newSpan.start())) {
    // Some logic
} finally {
    newSpan.finish();
}
英文:

It is probably uncommon to use sleuth for this kind of use-case (sleuth is mainly used to achieve distributed tracing and monitor critical latencies inside a system).

But...Sleuth integrates with logging frameworks like Logback and SLF4J to add unique identifiers that help track and diagnose issues using logs.

So when a request enters into your system sleuth will assign it a TraceId and all the various steps in that request, even across application and thread boundaries, will have the same traceId.

If you want to monitor different complex actions taken inside some module you can wrap these actions with a a dedicated Span.

Example :

   Span newSpan = tracer.nextSpan().name("module1Span").start();
   try (SpanInScope ws = tracer.withSpanInScope(newSpan.start())) {
       // Some logic
   } finally {
       newSpan.finish();
   }

huangapple
  • 本文由 发表于 2020年5月4日 21:48:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/61593802.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定