Prompt

How do I trace an event-driven workflow across multiple serverless functions?

Technology / Cloud Infrastructure1 observationLast seen Oct 26, 2026

Latest observation

Oct 26, 2026OpenAI APIWeb search: off

To trace an event-driven workflow across multiple serverless functions, you want distributed tracing with a shared correlation context that follows the event from one function to the next.

Core idea

Each function should:

  1. Read the incoming trace context
  2. Create a child span / continue the trace
  3. Propagate the context into the next event/message
  4. Log the trace ID everywhere

That lets you reconstruct the full path across queue triggers, pub/sub, HTTP callbacks, etc.


Recommended approach

1) Use a standard tracing format

Prefer OpenTelemetry and W3C Trace Context:

  • traceparent
  • tracestate (optional)

These are widely supported and portable across cloud providers and runtimes.


2) Propagate trace context in every event

When Function A emits an event for Function B, include trace metadata in the message envelope or headers.

Examples:

  • HTTP: put traceparent in headers
  • Queue/pub-sub: include trace headers in message attributes/metadata
  • Custom event payloads: include a metadata section

Example event structure:

{
  "metadata": {
    "traceparent": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-00"
  },
  "data": {
    "orderId": "12345"
  }
}

3) Instrument every function

In each function:

  • Start a span when the function is invoked
  • Extract incoming trace context
  • Attach logs/metrics to the span
  • End the span before return

If you use OpenTelemetry SDKs, this is mostly automatic once configured.


4) Add correlation IDs to logs

Alongside tracing, include:

  • trace_id
  • span_id
  • request_id or correlation_id

This makes it easy to search logs when tracing isn’t enough.

Example log:

{
  "message": "Created payment intent",
  "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
  "span_id": "00f067aa0ba902b7",
  "function": "payment-handler"
}

5) Trace asynchronous hops explicitly

Serverless workflows often cross async boundaries, so you must manually propagate context:

  • queue message
  • event bus payload
  • workflow state
  • scheduled callback

If the platform strips headers, store tracing metadata in message attributes or payload fields.


Practical architecture

A typical chain might look like:

  1. API Gateway → Function A

    • Incoming HTTP request has traceparent
    • Function A starts span A
  2. Function A → Queue

    • Function A publishes message with same trace context
    • Creates child span publish-to-queue
  3. Queue → Function B

    • Function B extracts context from message
    • Starts span B as child of A’s trace
  4. Function B → Function C

    • Continue propagating trace context

In a tracing UI, you’ll see one trace with spans for A, queue publish, B, C, etc.


Tooling options

Managed services

  • AWS X-Ray
  • Azure Application Insights
  • Google Cloud Trace

Portable standard

  • OpenTelemetry + Jaeger / Tempo / Zipkin / Datadog / New Relic

OpenTelemetry is usually the best long-term choice if you want cloud portability.


Common pitfalls

  • Not propagating context across async events
  • Starting a new trace in each function
  • Using ad hoc IDs that aren’t compatible with tracing tools
  • Only instrumenting HTTP functions, not queue consumers
  • Sampling too aggressively, which can hide the full workflow

Best practice checklist

  • Instrument all functions with OpenTelemetry
  • Propagate traceparent through events/messages
  • Log trace_id and span_id
  • Use one trace per business transaction
  • Ensure your queue/event broker preserves metadata
  • Add span names that reflect business steps
  • Export traces to a central backend

If you want, I can show you:

  1. an AWS Lambda + SQS example,
  2. an Azure Functions example, or
  3. a Node.js/Python OpenTelemetry setup.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.