Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/3466#discussion_r22243982
--- Diff:
streaming/src/main/scala/org/apache/spark/streaming/StreamingSource.scala ---
@@ -28,46 +28,58 @@ private[streaming] class StreamingSource(ssc:
StreamingContext) extends Source {
private val streamingListener = ssc.progressListener
- private def registerGauge[T](name: String, f:
StreamingJobProgressListener => T,
+ private def registerGauge[T](name: String, f:
StreamingJobProgressListener => Option[T],
defaultValue: T) {
metricRegistry.register(MetricRegistry.name("streaming", name), new
Gauge[T] {
- override def getValue: T =
Option(f(streamingListener)).getOrElse(defaultValue)
--- End diff --
I think its better to keep the Option here (and document that
`defaultValue` is used when `f` returns `null`. And other places should not
have to use Option. This is safer for any one to use and also minimizes the
changes.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]