A common use case for flow search is to see the related flow while inspecting a log event. You can do this with Aspecto. To do this, you must attach the active traceId to your logs.
Follow these steps to attach traceId to your logs.
Use the getContext
method, exposed from our package:
const { getContext } = require('@aspecto/opentelemetry');console.log('Something happened!', { traceId: getContext().traceId });
If you're using a custom logger, we recommend you add the traceId to all logs by default. Here's an example using winston:
const { getContext } = require('@aspecto/opentelemetry');const winston = require('winston');const addAspectoTraceId = winston.format((info) => {info.traceId = getContext().traceId;return info;});const logger = winston.createLogger({format: winston.format.combine(addAspectoTraceId(),winston.format.json()),transports: [ ... ],});
After completing the setup, and deploying your service, find the relevant log in your logging solution (e.g., CloudWatch, logz.io, etc...) and copy the traceId.
Next, go to Flow Search and search for the traceId you just copied:
Then, visualize and debug the flow.