Jaeger使用
注:
Jaeger服务端版本为:jaegertracing/all-in-one-1.6.0
OpenTracing版本为:0.33.0,最后一个版本,停留在May 06, 2019。最好升级到OpenTelemetry。
Jaeger客户端版本为:jaeger-client-1.3.2
。
Tags
Tag是一个非常常见的概念,时序数据库如InfluxDB,Prometheus里的基础概念。Jaeger也有这个概念,如下Jaeger UI里有一个Tags,主要用于筛选过滤部分可能会造成干扰的数据。
点击某个Trace进去,会发现如下信息:
因此,可输入如下内容实现过滤搜索:
- 精确匹配:
hostname=DESKTOP-L20EH42
- 排除匹配:
hostname=~DESKTOP-L20EH42
其他可用的Tag(常用的在前面):
- hostname
- ip
http.status_code
http.method
http.url
jaeger.version
- component
span.kind
sampler.type
sampler.param
排除特定路径
如上图,Operation里列出该应用下的所有接口。
在k8s集群里,pod健康检查需要应用暴露一个/health
接口。这个/health
接口是写在框架Jar里的,而不是每个应用都写一个HealthController(虽然可以这样做,我在上家公司也这样干过)。
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.ReflectionUtils;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody