databricks.labs.dqx.metrics_listener
StreamingMetricsListener Objects
class StreamingMetricsListener(listener.StreamingQueryListener)
Implements a Spark StreamingQueryListener for writing data quality summary metrics to an output destination. See
the Spark documentation
for detailed information about StreamingQueryListener.
Arguments:
metrics_config- Output configuration used for writing data quality summary metricsmetrics_observation-DQMetricsObservationwith data quality summary informationspark-SparkSessionfor writing summary metricstarget_query_id- Optional query ID of the specific streaming query to monitor. If provided, only events from this query will be processed (useful when multiple queries share the same observation).
onQueryStarted
def onQueryStarted(event: listener.QueryStartedEvent) -> None
Writes a message to the standard output logs when a streaming query starts.
Arguments:
event- AQueryStartedEventwith details about the streaming query
onQueryProgress
def onQueryProgress(event: listener.QueryProgressEvent) -> None
Writes the custom metrics from the DQMetricsObserver to the output destination.
Arguments:
event- AQueryProgressEventwith details about the last processed micro-batch
onQueryIdle
def onQueryIdle(event: listener.QueryIdleEvent) -> None
Writes a message to the standard output logs when a streaming query is idle.
Arguments:
event- AQueryIdleEventwith details about the streaming query
onQueryTerminated
def onQueryTerminated(event: listener.QueryTerminatedEvent) -> None
Writes a message to the standard output logs when a streaming query stops due to cancellation or failure.
Arguments:
event- AQueryTerminatedEventwith details about the streaming query