Skip to content

feat(amber): trace the sync workflow execution entrypoint - #9445

Open
Ma77Ball wants to merge 3 commits into
apache:mainfrom
Ma77Ball:feat/trace-sync-execution
Open

Ma77Ball wants to merge 3 commits into
apache:mainfrom
Ma77Ball:feat/trace-sync-execution

Conversation

@Ma77Ball

@Ma77Ball Ma77Ball commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

  • SyncExecutionResource.executeWorkflowSync, the POST /execution/{wid}/{cuid}/run entrypoint, now opens its own span (named after the method) carrying texera.workflow.id, texera.computing_unit.id, and texera.operator.count.
  • The span is made current so the existing WorkflowService.initExecutionService span nests beneath it, and is marked ERROR whenever the run returns an unsuccessful result or throws: a caught Exception is recorded and the run returns an unsuccessful result (HTTP 200, success=false), while a non-Exception Throwable such as an Error is recorded, marks the span ERROR, and is re-raised. The span ends in a finally so every early return and the error path are covered.
  • A synchronous run now produces a single end-to-end trace in Jaeger showing total execution time with the init step as a child, using the same TexeraTracer and SpanAttrs pattern already in WorkflowService.

Any related issues, documentation, discussions?

Closes: #9440

How was this PR tested?

  • Run sbt "WorkflowExecutionService/testOnly *SyncExecutionResourceSpec" (CI): the "mark the execution span ERROR with correlation labels on a failed run" case asserts the span name, the three correlation attributes, ERROR status, and that initExecutionService nests under it (its parent span id equals this span's id); the "record the exception and mark the span ERROR when the run throws" case drives the catch arm with warehouseId = Some(1) and asserts an exception event plus ERROR. The amber module cannot be compiled in this environment (its JOOQ sources are generated against an unavailable database, a pre-existing build requirement), so these two cases are verified on CI.
  • Run sbt "Observability/testOnly *SpanAttrsSpec": the key-name case now also pins texera.computing_unit.id and texera.operator.count; passes locally (3 tests).
  • On the single-node stack with observability up, run a sync execution and confirm a single trace appears in Jaeger for SyncExecutionResource.executeWorkflowSync with initExecutionService nested under it.

Was this PR authored or co-authored using generative AI tooling?

Co-authored with Claude Opus 4.8 in compliance with ASF

SyncExecutionResource.executeWorkflowSync, the POST /execution/{wid}/{cuid}/run entrypoint, ran with no span of its own, so a synchronous run produced no end-to-end trace; only the nested WorkflowService.initExecutionService span existed. executeWorkflowSync now opens a span named after the method with texera.workflow.id, texera.computing_unit.id, and texera.operator.count attributes, makes it current so initExecutionService nests beneath it, records a thrown exception on the span, and ends it in a finally so every early return and the catch path are covered. A synchronous run now yields a single trace showing total execution time with the init step as a child, using the same TexeraTracer and SpanAttrs pattern already in WorkflowService.

reference/perf-candidates.md records this under P6 as the first slice, including the note that the amber module cannot be compiled locally without JOOQ code generation against the database (an existing build requirement unrelated to this change), so the change is verified by matching the established span pattern and relies on CI to compile.
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @Xiao-zhen-Liu, @aglinxinyuan
    You can notify them by mentioning @Xiao-zhen-Liu, @aglinxinyuan in a comment.

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

🟢 2 better · 🔴 7 worse · ⚪ 6 noise (<±5%) · 0 without baseline

Compared against main 9647f58 benchmarked on this same runner, so the delta is largely free of cross-runner hardware noise. The "7d avg" column still reflects the gh-pages dashboard. Treat <±5% as noise unless repeated.

Dashboard · Run

config throughput MB/s latency max Δ latest / 7d
🔴 bs=10 sw=10 sl=64 380 0.232 23,203/43,625/43,625 us 🟢 -19.1% / 🔴 +225.7%
🔴 bs=100 sw=10 sl=64 827 0.505 117,362/151,375/151,375 us 🔴 -5.8% / 🔴 +75.3%
⚪ bs=1000 sw=10 sl=64 975 0.595 1,027,808/1,078,015/1,078,015 us ⚪ within ±5% / 🔴 +32.7%
Baseline details

Latest main 9647f58 from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 380 tuples/sec 415 tuples/sec 993.83 tuples/sec -8.4% -61.8%
bs=10 sw=10 sl=64 MB/s 0.232 MB/s 0.253 MB/s 0.607 MB/s -8.3% -61.8%
bs=10 sw=10 sl=64 p50 23,203 us 21,290 us 10,119 us +9.0% +129.3%
bs=10 sw=10 sl=64 p95 43,625 us 53,915 us 13,394 us -19.1% +225.7%
bs=10 sw=10 sl=64 p99 43,625 us 53,915 us 16,114 us -19.1% +170.7%
bs=100 sw=10 sl=64 throughput 827 tuples/sec 878 tuples/sec 1,327 tuples/sec -5.8% -37.7%
bs=100 sw=10 sl=64 MB/s 0.505 MB/s 0.536 MB/s 0.81 MB/s -5.8% -37.7%
bs=100 sw=10 sl=64 p50 117,362 us 111,918 us 79,097 us +4.9% +48.4%
bs=100 sw=10 sl=64 p95 151,375 us 143,636 us 86,335 us +5.4% +75.3%
bs=100 sw=10 sl=64 p99 151,375 us 143,636 us 94,338 us +5.4% +60.5%
bs=1000 sw=10 sl=64 throughput 975 tuples/sec 975 tuples/sec 1,363 tuples/sec 0.0% -28.5%
bs=1000 sw=10 sl=64 MB/s 0.595 MB/s 0.595 MB/s 0.832 MB/s 0.0% -28.5%
bs=1000 sw=10 sl=64 p50 1,027,808 us 1,029,917 us 774,633 us -0.2% +32.7%
bs=1000 sw=10 sl=64 p95 1,078,015 us 1,070,968 us 814,584 us +0.7% +32.3%
bs=1000 sw=10 sl=64 p99 1,078,015 us 1,070,968 us 858,914 us +0.7% +25.5%
Raw CSV
config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,526.40,200,128000,380,0.232,23202.92,43625.08,43625.08
1,100,10,64,20,2418.72,2000,1280000,827,0.505,117361.54,151374.55,151374.55
2,1000,10,64,20,20515.22,20000,12800000,975,0.595,1027807.53,1078015.20,1078015.20

@Ma77Ball
Ma77Ball marked this pull request as ready for review November 14, 2026 13:02
@bobbai00
bobbai00 self-requested a review November 16, 2026 03:45

@bobbai00 bobbai00 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.

🔴 1 must-fix · 2 advisory · 0 polish: the span nests and ends correctly, but failed runs export as non-error spans.

Correctness (1)

  • SyncExecutionResource.scala:368: failed and timed-out runs never set ERROR status on the span (must-fix, see inline)

Simplifications (1)

  • SyncExecutionResource.scala:160: two span keys are raw strings instead of SpanAttrs constants (advisory, see inline)

Conventions (1)

  • SyncExecutionResource.scala:157: no test or performed check covers the new span (advisory, see inline)
Verification trace

Checked recordException in opentelemetry-sdk-trace 1.50.0 (SdkSpan): it adds an exception event and never sets status. Every failure exit of executeWorkflowSync (the outer catch via handleExecutionError, the timeout and wait-error returns, the null-service return, a terminal FAILED state) returns success = false, so one status check on the result covers all of them. Nesting holds: the span stays current on the request thread through the synchronous initExecutionService call, whose span builder takes the current context.

The executeWorkflowSync span recorded an exception but never set a status, so a failed run exported as UNSET and Jaeger's error filter skipped it, while the early timeout, wait-error, and null-service returns did not touch the span at all. The body is now a nested runExecution whose single result, or the failure handed back by the catch, sets the span to ERROR once when it is not successful, covering every failure path.

SpanAttrs gains ComputingUnitId and OperatorCount so the span tags those with shared keys instead of inline strings. SyncExecutionResourceSpec drives a failing run and asserts, via an in-memory SpanExporter installed into GlobalOpenTelemetry, that the span is named, tagged, and marked ERROR.
@Ma77Ball
Ma77Ball force-pushed the feat/trace-sync-execution branch from 5580145 to a48464e Compare November 21, 2026 06:01
@codecov-commenter

codecov-commenter commented Nov 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.68%. Comparing base (fa6a5de) to head (3fb963e).
⚠️ Report is 83 commits behind head on main.

Files with missing lines Patch % Lines
...he/texera/web/resource/SyncExecutionResource.scala 70.58% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9445      +/-   ##
============================================
- Coverage     91.79%   91.68%   -0.12%     
- Complexity     5022     5128     +106     
============================================
  Files          1283     1304      +21     
  Lines         56871    58091    +1220     
  Branches       7440     7575     +135     
============================================
+ Hits          52205    53259    +1054     
- Misses         2797     2923     +126     
- Partials       1869     1909      +40     
Flag Coverage Δ *Carryforward flag
access-control-service 77.44% <ø> (ø)
agent-service 99.55% <ø> (ø) Carriedforward from a48464e
amber 85.79% <75.00%> (+0.02%) ⬆️
computing-unit-managing-service 63.83% <ø> (-0.23%) ⬇️
config-service 87.50% <ø> (-0.24%) ⬇️
file-service 82.16% <ø> (-0.15%) ⬇️
frontend 96.42% <ø> (ø) Carriedforward from a48464e
notebook-migration-service 83.77% <ø> (ø)
pyamber 98.50% <ø> (ø) Carriedforward from a48464e
result-service 86.48% <ø> (?)
workflow-compiling-service 80.90% <ø> (+2.59%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bobbai00 bobbai00 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.

🟡 2 resolved · 1 open · 3 new (3 new = 2 newly introduced · 1 late catch): failed runs now export as ERROR spans; what is left is small.

Correctness (1)

  • SyncExecutionResource.scala:380: an Error skips the catch and the status line, so the span ends UNSET (advisory, see inline)

Polish: 2 quick touch-ups (see inline comments).

Still open: the test thread at SyncExecutionResource.scala:158, where nesting and the catch arm are unasserted (see the reply there).

Verification trace

Re-checked the round-1 fix at a48464e. The three early returns sit inside the nested def runExecution() and not inside a closure, so they return to the call at L371 and reach the status check at L378. handleExecutionError returns success = false on both branches, so a caught exception also ends ERROR. The new case's scan fails compilation inside initExecutionService, which stamps FAILED, so the case does reach L378. The one exit left unmarked is a non-Exception Throwable.

SyncExecutionResource.executeWorkflowSync wraps its body in an outer try whose catch now matches Throwable rather than Exception: the throwable is recorded as an "exception" event on the execution span, the span status is set to StatusCode.ERROR, and the throwable is rethrown, while the finally still closes the current-context scope and ends the span. The inner `case e: Exception` arm is unchanged and keeps turning expected engine failures into a success=false result, so the new outer arm only covers non-Exception Errors (for example OutOfMemoryError) that previously left the span UNSET.

SpanAttrsSpec: the "expose stable key names" case now also asserts SpanAttrs.ComputingUnitId.getKey is "texera.computing_unit.id" and SpanAttrs.OperatorCount.getKey is "texera.operator.count", so renaming either wire key fails a test.

SyncExecutionResourceSpec: the failed-run case now asserts the exported WorkflowService.initExecutionService span's parent span id equals the executeWorkflowSync span id, pinning that init nests under the sync span. A new case drives the throwing path by passing warehouseId = Some(1), which is refused before any engine run, and asserts the exported executeWorkflowSync span carries an "exception" event and ERROR status. The class Scaladoc now says the span behaviour is driven by two end-to-end cases.
@Ma77Ball
Ma77Ball requested a review from bobbai00 November 24, 2026 01:28

@bobbai00 bobbai00 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.

🟡 3 resolved · 1 open · 1 new (1 new = 1 newly introduced · 0 late catches): the code now covers every failure path; one description phrase and one Scaladoc word remain.

Conventions (1)

  • SyncExecutionResource.scala:373: the description says every Throwable is re-raised; an Exception still returns a 200 (advisory, see inline)

Still open: the Scaladoc count thread at SyncExecutionResourceSpec.scala:1258 (a third case now calls executeWorkflowSync, see the reply there).

Verification trace

Re-checked at 3fb963e. The new outer case t: Throwable arm (L381-384) only sees non-Exception throwables, because the inner arm (L373-376) converts every Exception into a result first, so nothing is recorded twice and the endpoint's HTTP behavior matches base. The new throwing case is refused at L176 under either warehouse setting, so it reaches the inner arm without an engine run. The nesting assertion compares the init span's parent id with this span's id, and each span case clears the exporter first.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trace the sync workflow-execution entrypoint

3 participants