首页 > 解决方案 > 使用 Flask 和请求的 OpenCensus 分布式跟踪传播

问题描述

我正在尝试通过 OpenCensus 跨不同的服务实现分布式跟踪,其中每个服务都使用 Flask 进行服务并使用...发送下游请求 requests来构建它的回复。追踪平台是 GCP Cloud Trace。

我正在使用FlaskMiddleware,它正确地跟踪初始调用,但源和目标服务之间没有跨度信息的传播,即使中间件定义了传播(我已经尝试了一些):

#middleware = FlaskMiddleware(app, exporter=exporter, sampler=sampler, excludelist_paths=['healthz', 'metrics'], propagator=google_cloud_format.GoogleCloudFormatPropagator())
middleware = FlaskMiddleware(app, exporter=exporter, sampler=sampler, excludelist_paths=['healthz', 'metrics'], propagator=b3_format.B3FormatPropagator())
#middleware = FlaskMiddleware(app, exporter=exporter, sampler=sampler, excludelist_paths=['healthz', 'metrics'], propagator=trace_context_http_header_format.TraceContextPropagator())

我想问题是,当每个服务通过 Flask 提供服务并通过requests.

目前,我最终使每个服务都有自己的单一跨度跟踪。

标签: flaskpython-requestsdistributed-tracingopencensus

解决方案


推荐阅读