How do I use distributed tracing with Prefect flow...
# prefect-community
o
How do I use distributed tracing with Prefect flows and X-Correlation-ID? Let’s say that I have a Node.js server that creates flow from deployments using create_flow_run_from_deployment. Is there a way to pass HTTP headers or a span-id/correlation-id to my Prefect workflow that is running on the agent? Maybe in the context? I saw the following statement in the documentation about the logger:
Contextual data about the run will be attached to the log records.
The goal is to be able to piece all events and actions related to a single client transaction. So if I have transaction id (X-Correlation-ID HTTP header) set to 1234, I want to use the Prefect logger and attach this token id (1234) to the logs, so later on I can debug related events in the stream. BTW, we are using Grafana Loki and promtail to periodically collect all events from all microservices into a time-series database. The context of this question is unified logging, and obviously debugging failures in production, and also during development of workflows. Motivation is that there may be multiple different runs of the same workflow and we want to correlate and group events related to the same transaction that was initiated by the end user on our platform. Thanks!
s
With create_flow_run_from_deployment, you are able to attach your own custom log statements from the output by a series of async calls. You can find an example here on how you can do so