-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generalize ingestion pipeline metrics
Signed-off-by: Oleksii Moskalenko <[email protected]>
- Loading branch information
Showing
10 changed files
with
109 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
spark/ingestion/src/main/scala/feast/ingestion/metrics/IngestionPipelineMetrics.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright 2018-2020 The Feast Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package feast.ingestion.metrics | ||
|
||
import org.apache.spark.SparkEnv | ||
import org.apache.spark.metrics.source.IngestionPipelineMetricSource | ||
|
||
object IngestionPipelineMetrics { | ||
def incrementDeadletters[A](rowIterator: Iterator[A]): Iterator[A] = { | ||
if (metricSource.nonEmpty) | ||
metricSource.get.METRIC_DEADLETTER_ROWS_INSERTED.inc(rowIterator.length) | ||
|
||
rowIterator | ||
} | ||
|
||
def incrementRead[A](rowIterator: Iterator[A]): Iterator[A] = { | ||
if (metricSource.nonEmpty) | ||
metricSource.get.METRIC_ROWS_READ_FROM_SOURCE.inc(rowIterator.length) | ||
|
||
rowIterator | ||
} | ||
|
||
private lazy val metricSource: Option[IngestionPipelineMetricSource] = { | ||
this.synchronized { | ||
if ( | ||
SparkEnv.get.metricsSystem | ||
.getSourcesByName(IngestionPipelineMetricSource.sourceName) | ||
.isEmpty | ||
) { | ||
SparkEnv.get.metricsSystem.registerSource(new IngestionPipelineMetricSource) | ||
} | ||
} | ||
|
||
SparkEnv.get.metricsSystem.getSourcesByName(IngestionPipelineMetricSource.sourceName) match { | ||
case Seq(head) => Some(head.asInstanceOf[IngestionPipelineMetricSource]) | ||
case _ => None | ||
} | ||
} | ||
} |
47 changes: 0 additions & 47 deletions
47
spark/ingestion/src/main/scala/feast/ingestion/stores/deadletters/DeadLetterMetrics.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
spark/ingestion/src/test/scala/feast/ingestion/metrics/StatsDStub.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package feast.ingestion.metrics | ||
|
||
import java.net.{DatagramPacket, DatagramSocket, SocketTimeoutException} | ||
|
||
import scala.collection.mutable.ArrayBuffer | ||
|
||
class StatsDStub { | ||
val socket = new DatagramSocket() | ||
socket.setSoTimeout(100) | ||
|
||
def port: Int = socket.getLocalPort | ||
|
||
def receive: Array[String] = { | ||
val messages: ArrayBuffer[String] = ArrayBuffer() | ||
var finished = false | ||
|
||
do { | ||
val buf = new Array[Byte](65535) | ||
val p = new DatagramPacket(buf, buf.length) | ||
try { | ||
socket.receive(p) | ||
} catch { | ||
case _: SocketTimeoutException => | ||
finished = true | ||
} | ||
messages += new String(p.getData, 0, p.getLength) | ||
} while (!finished) | ||
|
||
messages.toArray | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters