-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-24637][SS] Add metrics regarding state and watermark to dropwizard metrics #21622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,10 +17,13 @@ | |
|
|
||
| package org.apache.spark.sql.execution.streaming | ||
|
|
||
| import java.text.SimpleDateFormat | ||
|
|
||
| import com.codahale.metrics.{Gauge, MetricRegistry} | ||
|
|
||
| import org.apache.spark.internal.Logging | ||
| import org.apache.spark.metrics.source.{Source => CodahaleSource} | ||
| import org.apache.spark.sql.catalyst.util.DateTimeUtils | ||
| import org.apache.spark.sql.streaming.StreamingQueryProgress | ||
|
|
||
| /** | ||
|
|
@@ -39,6 +42,23 @@ class MetricsReporter( | |
| registerGauge("processingRate-total", _.processedRowsPerSecond, 0.0) | ||
| registerGauge("latency", _.durationMs.get("triggerExecution").longValue(), 0L) | ||
|
|
||
| private val timestampFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") // ISO8601 | ||
| timestampFormat.setTimeZone(DateTimeUtils.getTimeZone("UTC")) | ||
|
|
||
| registerGauge("eventTime-watermark", | ||
| s => convertStringDateToMillis(s.eventTime.get("watermark")), 0L) | ||
|
|
||
| registerGauge("states-rowsTotal", _.stateOperators.map(_.numRowsTotal).sum, 0L) | ||
| registerGauge("states-usedBytes", _.stateOperators.map(_.memoryUsedBytes).sum, 0L) | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can add more metrics like "providerLoadedMapSizeBytes" after adopting SPARK-24441, so that actual memory usage of state store provider could be tracked via time-series manner.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those are custom metrics, which may or may not be present depending on the implementation of state store. I dont recommend adding them here directly.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the input! I'll keep the patch as it is. Could you suggest some approaches to extend the maintained metrics? I would like to expand more, and newer things might be coming from custom metrics (like from source and sink) so might be worth to have extension point. My question is beyond of this PR, so please continue reviewing the patch. Thanks! |
||
| private def convertStringDateToMillis(isoUtcDateStr: String) = { | ||
| if (isoUtcDateStr != null) { | ||
| timestampFormat.parse(isoUtcDateStr).getTime | ||
| } else { | ||
| 0L | ||
| } | ||
| } | ||
|
|
||
| private def registerGauge[T]( | ||
| name: String, | ||
| f: StreamingQueryProgress => T, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s=>progressto make it clear.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
registerGauge, and once we register the metric,getValuein Gauge is called from Dropwizard so I'm not sure we can control whether reporting the value or not.