【发布时间】:2019-12-17 10:57:32
【问题描述】:
我正在使用教程https://github.com/contino/jaeger-django-docker-tutorial 在 Django 中使用 JaegerTracing。现在我不知道如何从响应标头中取出 traceId,因为它不存在。
在 Jaeger UI 中查找跟踪时,它会返回带有数据的响应(另请参见下面的屏幕截图):
{
"data": [{
"traceID": "885bef8bbc18649c",
"spans": [{
"traceID": "885bef8bbc18649c",
"spanID": "cc4a59c2161aa05d",
"flags": 1,
"operationName": "test",
"references": [],
"startTime": 1576579367614065,
"duration": 430,
"tags": [{
"key": "sampler.type",
"type": "string",
"value": "const"
}, {
"key": "sampler.param",
"type": "bool",
"value": true
}, {
"key": "component",
"type": "string",
"value": "django"
}, {
"key": "span.kind",
"type": "string",
"value": "server"
}, {
"key": "http.method",
"type": "string",
"value": "GET"
}, {
"key": "http.url",
"type": "string",
"value": "/polls/test/"
}, {
"key": "path",
"type": "string",
"value": "/polls/test/"
}, {
"key": "method",
"type": "string",
"value": "GET"
}, {
"key": "http.status_code",
"type": "int64",
"value": 200
}],
"logs": [],
"processID": "p1",
"warnings": null
}],
"processes": {
"p1": {
"serviceName": "polls_app",
"tags": [{
"key": "hostname",
"type": "string",
"value": "12625857e878"
}, {
"key": "ip",
"type": "string",
"value": "172.23.0.3"
}, {
"key": "jaeger.version",
"type": "string",
"value": "Python-3.13.1.dev0"
}]
}
},
"warnings": null
}],
"total": 0,
"limit": 0,
"offset": 0,
"errors": null
}
我怀疑它在响应标头中,但事实并非如此。
我该怎么做?
【问题讨论】:
-
OpenTracing 工具通常不会在响应中发送额外的标头,因为对于关联事件,仅在请求中向前发送标头就足够了。然而,它一直是在西雅图举行的最后一次 W3C Trace Context 工作组面对面会议上讨论的主题。从您的问题中不清楚您要通过响应标头实现什么。
-
我想通过跟踪 ID 访问某些请求日志。谢谢你的回答。