Registry / data / sparkmeasure

sparkmeasure

JSON →
library0.28.0pypypi✓ verified 22d ago

sparkMeasure is a Python API for the core Scala library, designed for performance troubleshooting of Apache Spark workloads. It simplifies the collection and analysis of Spark metrics, making it suitable for interactive analysis, testing, and production monitoring. The library focuses on easing metric collection and analysis for both developers and data engineers. Releases are frequent, typically on a quarterly to half-yearly cadence, with the current stable version being 0.27.0.

pip install sparkmeasure
INSTALL
IMPORT
SIG · SPARKMEASURE
S
sparkmeasure
datapythonv0.28.0
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.28.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

StageMetrics
from sparkmeasure import StageMetrics
TaskMetrics
from sparkmeasure import TaskMetrics

This quickstart demonstrates how to initialize SparkMeasure and use the `runandmeasure` method to collect and report performance metrics for a Spark SQL query. It sets up a local SparkSession, loads the necessary SparkMeasure JAR, and then uses `StageMetrics` to instrument a simple operation.

from pyspark.sql import SparkSession from sparkmeasure import StageMetrics # Configure SparkSession to include the spark-measure JAR spark = (SparkSession.builder .appName("SparkMeasure Quickstart") .master("local[*]") .config("spark.jars.packages", "ch.cern.sparkmeasure:spark-measure_2.13:0.27") .getOrCreate()) # Initialize StageMetrics stagemetrics = StageMetrics(spark) # Run and measure a Spark job print("Running a simple Spark SQL query and measuring performance...") stagemetrics.runandmeasure(globals(), 'spark.sql("SELECT count(*) FROM range(1000) CROSS JOIN range(1000)").show()') print("\nPrinting performance report:") stagemetrics.print_report() spark.stop()
Debug
Known issues
breakingThe configuration properties for the Kafka sink have changed in version 0.27. Kafka Producer properties must now be passed via Spark config using the prefix `spark.sparkmeasure.kafka.<kafkaProperty>=<value>`.
fix
Update Spark configuration to use the new prefix for Kafka Producer properties (e.g., `spark.sparkmeasure.kafka.bootstrap.servers`).
affects: >=0.27.0
gotchaSpark Connect integration is partial. While Flight Recorder mode can capture application-wide metrics, per-client (Spark Connect client-side) metrics are not fully reported. Direct access to SparkContext and its listener interface is required for full integration.
fix
Be aware of these limitations when using sparkMeasure with Spark Connect. Consider Flight Recorder mode for application-level metrics or alternative monitoring for client-specific details.
affects: All versions
gotchaMetrics collected by sparkMeasure are buffered in the driver's memory. For very large workloads or extensive metric collection, this can become a bottleneck or lead to out-of-memory errors on the driver.
fix
Monitor driver memory usage. For large-scale data, consider saving metrics to file or external sinks (Kafka, InfluxDB) using Flight Recorder mode, which directly writes collected metrics.
affects: All versions
gotchaCollecting metrics using `TaskMetrics` (at the granularity of each task completion) incurs additional overhead compared to `StageMetrics` (aggregated by stage). Use `TaskMetrics` only when fine-grained data (e.g., for skew analysis) is strictly necessary.
fix
Prefer `StageMetrics` for general performance overview and troubleshooting, and switch to `TaskMetrics` only when detailed task-level analysis is required.
affects: All versions
gotchasparkMeasure primarily collects metrics for *successfully* executed tasks. Resources consumed by failed tasks are generally not included in the reports.
fix
When analyzing job failures, be aware that reported metrics might not fully account for all resource usage leading up to the failure. Complement with Spark UI event logs for full failure context.
affects: All versions
Upgrade
Version history
0.28.0latest on PyPI · released May 19, 2026
Audit
Dependencies
pysparkrequiredsparkmeasure is a wrapper for a Scala Spark library and requires a Spark environment (PySpark for Python users).
Agent activity
16 hits · last 30 days
node
12
OpenAI (training)
2
Amazon
1
Resources
sparkmeasure — pip install sparkmeasure · libregistry