Skip to content

Add workflow spans for tagging the logs with step name - #6088

Open
Caio-Nogueira wants to merge 1 commit into
mainfrom
caio/workflows-tracing
Open

Add workflow spans for tagging the logs with step name#6088
Caio-Nogueira wants to merge 1 commit into
mainfrom
caio/workflows-tracing

Conversation

@Caio-Nogueira

@Caio-Nogueira Caio-Nogueira commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

This is a proposal to add arbitrary step-related tags on console logs emitted from within workflow instances (more specifically, steps).

#6608 got merged, meaning that the tracing api is now using async context to store active spans. This means that user spans can in theory be attributed to the correct span, once the log instrumentation is changed to do so

@codspeed-hq

codspeed-hq Bot commented Feb 16, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 72 untouched benchmarks
⏩ 129 skipped benchmarks1


Comparing caio/workflows-tracing (e7de698) with main (0138dcb)

Open in CodSpeed

Footnotes

  1. 129 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Caio-Nogueira
Caio-Nogueira force-pushed the caio/workflows-tracing branch 2 times, most recently from 9184d97 to 5dad480 Compare February 23, 2026 11:56
@codecov-commenter

codecov-commenter commented Feb 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.61%. Comparing base (0138dcb) to head (e7de698).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6088   +/-   ##
=======================================
  Coverage   66.60%   66.61%           
=======================================
  Files         402      402           
  Lines      115908   115908           
  Branches    19427    19427           
=======================================
+ Hits        77205    77209    +4     
+ Misses      27104    27101    -3     
+ Partials    11599    11598    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/workerd/api/workers-module.c++ Outdated
Comment thread src/workerd/api/workers-module.c++ Outdated
Comment thread src/workerd/api/workers-module.c++ Outdated
Comment thread src/workerd/api/workers-module.c++ Outdated
Comment thread src/workerd/api/workers-module.c++ Outdated
Comment thread src/workerd/api/workers-module.c++ Outdated
Comment thread src/workerd/io/tracer.h Outdated
Comment thread src/workerd/io/tracer.h Outdated
@ask-bonk

ask-bonk Bot commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

@Caio-Nogueira Bonk workflow was cancelled.

View workflow run · To retry, trigger Bonk again.

Comment thread src/workerd/api/workers-module.c++ Outdated
Comment thread src/workerd/api/workers-module.c++ Outdated
@Caio-Nogueira
Caio-Nogueira marked this pull request as ready for review February 24, 2026 13:18
@Caio-Nogueira
Caio-Nogueira requested review from a team as code owners February 24, 2026 13:18
Comment thread src/workerd/api/workers-module.c++ Outdated
Comment thread src/workerd/io/worker.c++ Outdated
@jasnell
jasnell requested review from fhanau and mar-cf February 25, 2026 19:49
@jasnell

jasnell commented Feb 25, 2026

Copy link
Copy Markdown
Collaborator

Tagging either @fhanau or @mar-cf to provide additional review on the bits that touch the tracing apis. These LGTM but want to make sure I'm not missing any critical detail.

@jasnell jasnell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up review. Most prior feedback was addressed — thanks for the updates.

Remaining findings:

  • Formatting: The file needs just format — missing indentation in KJ_IF_SOME body, flush-left code in runStep, misleading closing-brace comments
  • Misleading comment: setWorkflowInfo docstring claims buffered trace update that doesn't happen
  • Dead code: TraceContext::addLog added but never called
  • Missing bounds check: argv[0] accessed without size check

(These comments were generated with AI assistance and may contain errors.)

Comment thread src/workerd/api/workers-module.c++ Outdated
Comment thread src/workerd/api/workers-module.c++ Outdated
Comment thread src/workerd/io/tracer.h Outdated
Comment thread src/workerd/io/trace.c++
@github-actions

github-actions Bot commented Feb 26, 2026

Copy link
Copy Markdown

The generated output of @cloudflare/workers-types matches the snapshot in types/generated-snapshot 🎉

@Caio-Nogueira
Caio-Nogueira requested a review from a team as a code owner February 26, 2026 14:32

@fhanau fhanau left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the tracing-related changes and left some feedback. This excludes the handling of the async storage, which I'm less familiar with.

Comment thread src/workerd/io/trace.c++ Outdated
Comment thread src/workerd/io/trace-test.c++
Comment thread src/workerd/io/trace.h
Comment thread src/workerd/io/trace.h Outdated
Comment thread src/workerd/io/trace.h Outdated
Comment thread src/workerd/io/tracer.c++ Outdated
Comment thread src/workerd/io/tracer.h Outdated
Comment thread src/workerd/io/worker.c++ Outdated
Comment thread src/workerd/io/worker.c++ Outdated
Comment thread src/workerd/io/worker.h Outdated
@Caio-Nogueira
Caio-Nogueira force-pushed the caio/workflows-tracing branch 4 times, most recently from d11edea to bdb076d Compare March 2, 2026 10:58

@danlapid danlapid left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR combines too much in one.
It also seems to have feature crept since the last time I looked at it.
The changes to add workflowName and workflowInstanceId should be pulled out, especially since I'm not sure this is the right implementation but we can discuss that in the split PR.

@Caio-Nogueira
Caio-Nogueira force-pushed the caio/workflows-tracing branch 3 times, most recently from ead1ed0 to f8a2e26 Compare March 2, 2026 16:07
@Caio-Nogueira

Caio-Nogueira commented Mar 2, 2026

Copy link
Copy Markdown
Contributor Author

This PR combines too much in one. It also seems to have feature crept since the last time I looked at it. The changes to add workflowName and workflowInstanceId should be pulled out, especially since I'm not sure this is the right implementation but we can discuss that in the split PR.

I removed the invocation level fields from the trace event. Although I think we should think about them (could be in a separate PR). Keeping only the log-to-span attribution logic for now.

Comment thread src/workerd/api/workers-module.c++ Outdated
@Caio-Nogueira
Caio-Nogueira force-pushed the caio/workflows-tracing branch 3 times, most recently from 5709bda to 51e6f5a Compare April 23, 2026 17:13
@Caio-Nogueira

Copy link
Copy Markdown
Contributor Author

Update:

Since #6608 got merged we can just rely on the internal tracing module to wrap the user's callback.

I rebased with main and removed the log instrumentation logic - that comes later (EW-10672).

All we need from the workflows end is to trace the step.do's callback.

@jmorrell-cloudflare jmorrell-cloudflare left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danlapid @fhanau Do we still need to allowlist all spans in the internal repo?

Comment thread src/cloudflare/workers.ts Outdated
@Caio-Nogueira
Caio-Nogueira force-pushed the caio/workflows-tracing branch 4 times, most recently from 43579bf to 49bf362 Compare April 30, 2026 20:02
@danlapid
danlapid self-requested a review April 30, 2026 22:04
@danlapid

danlapid commented Apr 30, 2026

Copy link
Copy Markdown
Collaborator

@danlapid @fhanau Do we still need to allowlist all spans in the internal repo?

yes, but not ones created with the JS tracing API

@Caio-Nogueira

Caio-Nogueira commented May 1, 2026

Copy link
Copy Markdown
Contributor Author

@danlapid @fhanau Do we still need to allowlist all spans in the internal repo?

yes, but not ones created with the JS tracing API

Ah I thought internal spans also had to be whitelisted. You're right - tests seem to be passing without any changes to it 👍🏼

@Caio-Nogueira
Caio-Nogueira force-pushed the caio/workflows-tracing branch from 49bf362 to e7de698 Compare May 7, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants