Skip to content

Spark Executor Tasks Instrumentation - #6515

Merged
paul-laffon-dd merged 9 commits into
masterfrom
paul.laffon/spark-tasks-instrumentation
Feb 27, 2024
Merged

paul-laffon-dd merged 9 commits into
masterfrom
paul.laffon/spark-tasks-instrumentation

Conversation

@paul-laffon-dd

Copy link
Copy Markdown
Contributor

What Does This Do

Add a new instrumentation spark-executor to trace tasks running on spark executors

The existing spark instrumentation is running on the spark driver, capturing spark internals (spark.sql, spark.job, spark.stage...), while this new instrumentation will trace task being run on spark executors.

Motivation

Generate traces for spark.task, with underlying spans (like s3 or database calls) being linked.

Additional Notes

  • each spark.task is a distinct trace and not on the existing spark.application / spark.job traces:

    • a spark job/application can have millions on tasks, making it unpractical to have everything in one trace
    • sampling should be applied to spark.task, while all spark.application and spark.job traces are kept
    • Span link will be used to link the spark.task to other spark traces
  • task errors are not captured for now

    • spark catch all throwable in task execution, making it complex to retrieve it from the instrumentation

@pr-commenter

pr-commenter Bot commented Jan 18, 2024 •

Copy link
Copy Markdown

Benchmarks

Startup

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master paul.laffon/spark-tasks-instrumentation
git_commit_date 1708008561 1708008822
git_commit_sha 142c8ca 89aa6af
release_version 1.31.0-SNAPSHOT~142c8cac77 1.31.0-SNAPSHOT~89aa6af746
See matching parameters
Baseline Candidate
application insecure-bank insecure-bank
ci_job_date 1708011752 1708011752
ci_job_id 435112682 435112682
ci_pipeline_id 28357177 28357177
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
module Agent Agent
parent None None
variant iast iast

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 46 metrics, 8 unstable metrics.

Startup time reports for petclinic
gantt
    title petclinic - global startup overhead: candidate=1.31.0-SNAPSHOT~89aa6af746, baseline=1.31.0-SNAPSHOT~142c8cac77

    dateFormat X
    axisFormat %s
section tracing
Agent [baseline] (1.063 s) : 0, 1063304
Total [baseline] (9.387 s) : 0, 9386511
Agent [candidate] (1.075 s) : 0, 1075032
Total [candidate] (9.37 s) : 0, 9369995
section appsec
Agent [baseline] (1.16 s) : 0, 1160169
Total [baseline] (9.465 s) : 0, 9465386
Agent [candidate] (1.175 s) : 0, 1174712
Total [candidate] (9.499 s) : 0, 9498584
section iast
Agent [baseline] (1.188 s) : 0, 1188371
Total [baseline] (9.681 s) : 0, 9681306
Agent [candidate] (1.196 s) : 0, 1195891
Total [candidate] (9.69 s) : 0, 9690356
section profiling
Agent [baseline] (1.275 s) : 0, 1274505
Total [baseline] (9.533 s) : 0, 9532880
Agent [candidate] (1.278 s) : 0, 1278404
Total [candidate] (9.543 s) : 0, 9543488
Loading
  • baseline results
Module Variant Duration Δ tracing
Agent tracing 1.063 s -
Agent appsec 1.16 s 96.865 ms (9.1%)
Agent iast 1.188 s 125.067 ms (11.8%)
Agent profiling 1.275 s 211.202 ms (19.9%)
Total tracing 9.387 s -
Total appsec 9.465 s 78.875 ms (0.8%)
Total iast 9.681 s 294.795 ms (3.1%)
Total profiling 9.533 s 146.369 ms (1.6%)
  • candidate results
Module Variant Duration Δ tracing
Agent tracing 1.075 s -
Agent appsec 1.175 s 99.68 ms (9.3%)
Agent iast 1.196 s 120.859 ms (11.2%)
Agent profiling 1.278 s 203.373 ms (18.9%)
Total tracing 9.37 s -
Total appsec 9.499 s 128.589 ms (1.4%)
Total iast 9.69 s 320.361 ms (3.4%)
Total profiling 9.543 s 173.493 ms (1.9%)
gantt
    title petclinic - break down per module: candidate=1.31.0-SNAPSHOT~89aa6af746, baseline=1.31.0-SNAPSHOT~142c8cac77

    dateFormat X
    axisFormat %s
section tracing
BytebuddyAgent [baseline] (670.091 ms) : 0, 670091
BytebuddyAgent [candidate] (676.957 ms) : 0, 676957
GlobalTracer [baseline] (298.848 ms) : 0, 298848
GlobalTracer [candidate] (302.715 ms) : 0, 302715
AppSec [baseline] (51.347 ms) : 0, 51347
AppSec [candidate] (52.178 ms) : 0, 52178
Remote Config [baseline] (708.316 µs) : 0, 708
Remote Config [candidate] (717.75 µs) : 0, 718
Telemetry [baseline] (7.692 ms) : 0, 7692
Telemetry [candidate] (7.786 ms) : 0, 7786
section appsec
BytebuddyAgent [baseline] (668.421 ms) : 0, 668421
BytebuddyAgent [candidate] (677.461 ms) : 0, 677461
GlobalTracer [baseline] (299.082 ms) : 0, 299082
GlobalTracer [candidate] (302.918 ms) : 0, 302918
AppSec [baseline] (150.766 ms) : 0, 150766
AppSec [candidate] (152.011 ms) : 0, 152011
Remote Config [baseline] (635.048 µs) : 0, 635
Remote Config [candidate] (647.176 µs) : 0, 647
Telemetry [baseline] (6.832 ms) : 0, 6832
Telemetry [candidate] (6.942 ms) : 0, 6942
section iast
BytebuddyAgent [baseline] (779.854 ms) : 0, 779854
BytebuddyAgent [candidate] (787.368 ms) : 0, 787368
GlobalTracer [baseline] (292.049 ms) : 0, 292049
GlobalTracer [candidate] (291.005 ms) : 0, 291005
AppSec [baseline] (54.869 ms) : 0, 54869
AppSec [candidate] (52.514 ms) : 0, 52514
IAST [baseline] (19.965 ms) : 0, 19965
IAST [candidate] (23.211 ms) : 0, 23211
Remote Config [baseline] (604.078 µs) : 0, 604
Remote Config [candidate] (608.268 µs) : 0, 608
Telemetry [baseline] (6.702 ms) : 0, 6702
Telemetry [candidate] (6.552 ms) : 0, 6552
section profiling
BytebuddyAgent [baseline] (664.235 ms) : 0, 664235
BytebuddyAgent [candidate] (666.83 ms) : 0, 666830
GlobalTracer [baseline] (380.482 ms) : 0, 380482
GlobalTracer [candidate] (382.165 ms) : 0, 382165
AppSec [baseline] (51.963 ms) : 0, 51963
AppSec [candidate] (51.529 ms) : 0, 51529
Remote Config [baseline] (660.876 µs) : 0, 661
Remote Config [candidate] (651.527 µs) : 0, 652
Telemetry [baseline] (12.254 ms) : 0, 12254
Telemetry [candidate] (10.864 ms) : 0, 10864
ProfilingAgent [baseline] (110.453 ms) : 0, 110453
ProfilingAgent [candidate] (111.816 ms) : 0, 111816
Profiling [baseline] (110.478 ms) : 0, 110478
Profiling [candidate] (111.84 ms) : 0, 111840
Loading

Load

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
end_time 2024-02-15T15:18:32 2024-02-15T15:37:29
git_branch master paul.laffon/spark-tasks-instrumentation
git_commit_date 1708008561 1708008822
git_commit_sha 142c8ca 89aa6af
release_version 1.31.0-SNAPSHOT~142c8cac77 1.31.0-SNAPSHOT~89aa6af746
start_time 2024-02-15T15:18:19 2024-02-15T15:37:16
See matching parameters
Baseline Candidate
application insecure-bank insecure-bank
ci_job_date 1708011752 1708011752
ci_job_id 435112682 435112682
ci_pipeline_id 28357177 28357177
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
variant iast iast

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 11 metrics, 15 unstable metrics.

Request duration reports for petclinic
gantt
    title petclinic - request duration [CI 0.99] : candidate=1.31.0-SNAPSHOT~89aa6af746, baseline=1.31.0-SNAPSHOT~142c8cac77
    dateFormat X
    axisFormat %s
section baseline
no_agent (1.354 ms) : 1335, 1373
.   : milestone, 1354,
appsec (1.791 ms) : 1766, 1816
.   : milestone, 1791,
iast (1.52 ms) : 1496, 1545
.   : milestone, 1520,
profiling (1.572 ms) : 1546, 1599
.   : milestone, 1572,
tracing (1.51 ms) : 1485, 1535
.   : milestone, 1510,
section candidate
no_agent (1.339 ms) : 1320, 1358
.   : milestone, 1339,
appsec (1.795 ms) : 1770, 1820
.   : milestone, 1795,
iast (1.534 ms) : 1510, 1559
.   : milestone, 1534,
profiling (1.538 ms) : 1511, 1564
.   : milestone, 1538,
tracing (1.481 ms) : 1455, 1506
.   : milestone, 1481,
Loading
  • baseline results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 1.354 ms [1.335 ms, 1.373 ms] -
appsec 1.791 ms [1.766 ms, 1.816 ms] 436.82 µs (32.3%)
iast 1.52 ms [1.496 ms, 1.545 ms] 166.31 µs (12.3%)
profiling 1.572 ms [1.546 ms, 1.599 ms] 218.551 µs (16.1%)
tracing 1.51 ms [1.485 ms, 1.535 ms] 155.9 µs (11.5%)
  • candidate results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 1.339 ms [1.32 ms, 1.358 ms] -
appsec 1.795 ms [1.77 ms, 1.82 ms] 456.152 µs (34.1%)
iast 1.534 ms [1.51 ms, 1.559 ms] 195.295 µs (14.6%)
profiling 1.538 ms [1.511 ms, 1.564 ms] 198.994 µs (14.9%)
tracing 1.481 ms [1.455 ms, 1.506 ms] 141.897 µs (10.6%)
Request duration reports for insecure-bank
gantt
    title insecure-bank - request duration [CI 0.99] : candidate=1.31.0-SNAPSHOT~89aa6af746, baseline=1.31.0-SNAPSHOT~142c8cac77
    dateFormat X
    axisFormat %s
section baseline
no_agent (366.963 µs) : 347, 387
.   : milestone, 367,
iast (469.142 µs) : 448, 490
.   : milestone, 469,
iast_FULL (536.229 µs) : 516, 557
.   : milestone, 536,
iast_GLOBAL (495.686 µs) : 475, 516
.   : milestone, 496,
iast_HARDCODED_SECRET_DISABLED (480.617 µs) : 460, 501
.   : milestone, 481,
iast_INACTIVE (452.279 µs) : 431, 474
.   : milestone, 452,
iast_TELEMETRY_OFF (469.231 µs) : 448, 490
.   : milestone, 469,
tracing (445.233 µs) : 424, 466
.   : milestone, 445,
section candidate
no_agent (372.117 µs) : 351, 393
.   : milestone, 372,
iast (480.916 µs) : 460, 502
.   : milestone, 481,
iast_FULL (527.794 µs) : 507, 548
.   : milestone, 528,
iast_GLOBAL (485.963 µs) : 466, 506
.   : milestone, 486,
iast_HARDCODED_SECRET_DISABLED (478.788 µs) : 458, 499
.   : milestone, 479,
iast_INACTIVE (443.347 µs) : 423, 464
.   : milestone, 443,
iast_TELEMETRY_OFF (471.34 µs) : 451, 492
.   : milestone, 471,
tracing (440.293 µs) : 420, 461
.   : milestone, 440,
Loading
  • baseline results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 366.963 µs [347.153 µs, 386.773 µs] -
iast 469.142 µs [448.397 µs, 489.886 µs] 102.179 µs (27.8%)
iast_FULL 536.229 µs [515.516 µs, 556.941 µs] 169.266 µs (46.1%)
iast_GLOBAL 495.686 µs [475.0 µs, 516.371 µs] 128.723 µs (35.1%)
iast_HARDCODED_SECRET_DISABLED 480.617 µs [459.841 µs, 501.393 µs] 113.655 µs (31.0%)
iast_INACTIVE 452.279 µs [430.97 µs, 473.588 µs] 85.316 µs (23.2%)
iast_TELEMETRY_OFF 469.231 µs [448.288 µs, 490.174 µs] 102.269 µs (27.9%)
tracing 445.233 µs [424.351 µs, 466.116 µs] 78.271 µs (21.3%)
  • candidate results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 372.117 µs [350.971 µs, 393.263 µs] -
iast 480.916 µs [459.57 µs, 502.262 µs] 108.799 µs (29.2%)
iast_FULL 527.794 µs [507.467 µs, 548.122 µs] 155.677 µs (41.8%)
iast_GLOBAL 485.963 µs [465.577 µs, 506.348 µs] 113.846 µs (30.6%)
iast_HARDCODED_SECRET_DISABLED 478.788 µs [458.134 µs, 499.443 µs] 106.671 µs (28.7%)
iast_INACTIVE 443.347 µs [422.719 µs, 463.975 µs] 71.23 µs (19.1%)
iast_TELEMETRY_OFF 471.34 µs [450.502 µs, 492.179 µs] 99.223 µs (26.7%)
tracing 440.293 µs [419.544 µs, 461.043 µs] 68.176 µs (18.3%)

@paul-laffon-dd paul-laffon-dd added the inst: apache spark Apache Spark instrumentation label Jan 18, 2024
@paul-laffon-dd
paul-laffon-dd marked this pull request as ready for review January 18, 2024 13:18
@paul-laffon-dd
paul-laffon-dd requested a review from a team as a code owner January 18, 2024 13:18

@raphaelgavache raphaelgavache left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm, looks great!

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

Can you also update CODEOWNERS so that data-jobs-monitoring owns the instrumentation files here?

@paul-laffon-dd

Copy link
Copy Markdown
Contributor Author

@bm1549 In order to add the team @DataDog/data-jobs-monitoring as CODEOWNERS, it need to have access to the repository

image

@bm1549

bm1549 commented Feb 6, 2024

Copy link
Copy Markdown
Contributor

@paul-laffon-dd it seems like that team is not a subteam of https://github.com/orgs/DataDog/teams/dev which is causing the issue

@tiffon as maintainer of the team, can you update the parent team to be dev?
https://github.com/orgs/DataDog/teams/data-jobs-monitoring/edit

@paul-laffon-dd

Copy link
Copy Markdown
Contributor Author

Thanks @bm1549, we updated the team settings and the CODEOWNERS file is now valid

DECORATE.onTaskEnd(span, taskRunner);
DECORATE.beforeFinish(scope);

scope.close();

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.

span.close & finish should be in finally blocks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Move those in finally block

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

Scope.close and span.finish should probably be in finally blocks; otherwise, you risk traces not being published in a timely fashion.

DECORATE.onTaskEnd(span, taskRunner);
DECORATE.beforeFinish(scope);
} finally {
scope.close();

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.

I think this is probably fine, but typically each clean-up needs to be in its own finally block.
In this case - if scope.close raises an exception then you won't perform span.finish.

@paul-laffon-dd
paul-laffon-dd merged commit 2c1fe7c into master Feb 27, 2024
@paul-laffon-dd
paul-laffon-dd deleted the paul.laffon/spark-tasks-instrumentation branch February 27, 2024 09:42
@github-actions github-actions Bot added this to the 1.31.0 milestone Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inst: apache spark Apache Spark instrumentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants