Attach via spark.extraListeners — get a ranked report of performance issues with exact config fixes at every job end, on every cluster.
Three steps, no infrastructure required.
Add spark.extraListeners=...SparkLensListener and spark.sparklens.output=text to your spark-submit command or spark-defaults.conf. Nothing else needed.
Heads-up: spark.extraListeners= replaces any existing listener list. Use a comma to append: OtherListener,SparkLensListener. For batch applications only — Structured Streaming results will be misleading.
spark-lens listens to every task, stage, job, and SQL execution as they complete — zero overhead on the hot path. It only processes data after the application ends.
At application end, issues are ranked by estimated savings and printed to driver stdout or written to a file. Every issue includes a concrete recommendation and ready-to-paste config or code fixes — with estimated time saved per run.
Four formats: text for driver stdout, HTML for humans, JSON for CI parsers and dashboards, log for log aggregation (one line per issue).
Human-readable with priority fixes section, issue list, and quick-wins grouped by config change. Default when a file path is given without a format extension.
Metrics summary panel, stage timeline, memory pressure line chart, shuffle metrics breakdown, GC timeline, and issue severity timeline. Collapsible issue cards with severity badges, savings, and fixes. Suitable for sharing as a CI artifact.
Stable schema with health_score, total_estimated_savings_ms, top_actions, and full issue array. Parse in CI pipelines or feed into dashboards.
One log line per issue via the driver Java logger. Compatible with Datadog, Splunk, CloudWatch Logs — filter on SPARKLENS tag. No file path needed.
Issues are grouped by type — e.g. Disk Spill in Stage 3 [+4 more stages] — so the report stays readable on large pipelines. Each issue shows its estimated impact badge, metrics table, and config/code fix blocks. Stage pills have callSite tooltips.
Use spark.sparklens.output=log. Each line is prefixed with [spark-lens] — grep or filter by this tag in Datadog, Splunk, CloudWatch, or any log aggregator. No separate file path needed.
29 analyzers covering skew, memory, I/O, query planning, configuration, reliability, and executor scaling — every issue includes an estimated savings figure.
All settings are optional. No required configuration.
| Property | Default | Values | Description |
|---|---|---|---|
spark.sparklens.output | off | off · text · json · html · log — comma-separated for multiple | Output format(s). off is silent unless fail.on is set. Example: text,json |
spark.sparklens.report.path | (stdout) | local path, hdfs://, s3://… | Write report to a file. Supports any Hadoop-compatible filesystem. With multiple formats each gets its own extension (.txt, .json, .html). |
spark.sparklens.report.path.<fmt> | — | path per format | Format-specific path override — highest priority. Available for .text .json .html .log. |
spark.sparklens.fail.on | (none) | critical · warning · info | Throw RuntimeException at app end if issues at this severity or above are found. Exit code is non-zero — CI pipeline fails automatically. |
Add to spark-defaults.conf on every node — every job gets analyzed automatically, no per-job flags needed.
Fail the Spark job itself when critical issues are detected — no external tooling required.
Flat deduction per issue, floored at 0. A single CartesianProduct (−30) always scores worse than five config warnings (−50 → but likely −50 is still a 50/100 score showing both matter).
spark-lens-testing lets you write ScalaTest specs that assert on analysis results — catching performance regressions in CI before they reach production.
haveIssue(id)Issue with that exact id or id prefix is present. e.g. "plan-cartesian" matches "plan-cartesian-3"
haveIssueOfCategory(cat)Any issue in that category: spill, skew, join, gc, config, plan, io, reliability
haveIssueOfSeverity(sev)Any issue at Critical, Warning, or Info
haveNoIssuesOfSeverity(sev)No issue at that severity — assert a job is clean
haveHealthScoreAbove(n)Health score > n. e.g. haveHealthScoreAbove(75)
haveHealthScoreBelow(n)Health score < n — verify a bad job is detected
When any assertion fails, the complete text report is embedded in the test failure — no guessing which issue fired or what the fix is.
You can also print the report manually during debugging: result.textReport.
Both SparkLensSpec (FlatSpec) and SparkLensSuite (FunSuite) are available. Requires JVM < 23 — build.sbt auto-detects Java 17 when the host JVM is newer. Set JAVA_17_HOME if needed.