Skip to content

Commit b3a945e

Browse files
author
zhilingc
committed
Add support for prometheus metrics, calculate lag and count
1 parent 32c5eb5 commit b3a945e

25 files changed

Lines changed: 180 additions & 1735 deletions

ingestion/pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,11 @@
272272
<artifactId>jedis</artifactId>
273273
<version>3.1.0</version>
274274
</dependency>
275-
275+
<dependency>
276+
<groupId>io.prometheus</groupId>
277+
<artifactId>simpleclient_pushgateway</artifactId>
278+
<version>0.7.0</version>
279+
</dependency>
276280
<dependency>
277281
<groupId>org.projectlombok</groupId>
278282
<artifactId>lombok</artifactId>

ingestion/src/main/java/feast/ingestion/ImportJob.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
import feast.ingestion.transform.ReadFeatureRow;
1414
import feast.ingestion.transform.ToFeatureRowExtended;
1515
import feast.ingestion.transform.WriteFeaturesTransform;
16+
import feast.ingestion.transform.metrics.WriteMetricsTransform;
1617
import feast.ingestion.util.StorageUtil;
18+
import feast.types.FeatureRowExtendedProto.FeatureRowExtended;
1719
import java.io.IOException;
1820
import java.net.URISyntaxException;
1921
import java.util.HashMap;
@@ -25,6 +27,7 @@
2527
import org.apache.beam.sdk.PipelineResult;
2628
import org.apache.beam.sdk.options.PipelineOptionsFactory;
2729
import org.apache.beam.sdk.options.PipelineOptionsValidator;
30+
import org.apache.beam.sdk.values.PCollection;
2831
import org.apache.kafka.clients.consumer.KafkaConsumer;
2932
import org.apache.kafka.clients.consumer.OffsetAndTimestamp;
3033
import org.apache.kafka.common.PartitionInfo;
@@ -39,8 +42,8 @@ public class ImportJob {
3942
* <p>The arguments will be passed to Beam {@code PipelineOptionsFactory} to create {@code
4043
* ImportJobPipelineOptions}.
4144
*
42-
* <p>The returned PipelineResult object can be used to check the state of the pipeline e.g. if it
43-
* is running, done or cancelled.
45+
* <p>The returned PipelineResult object can be used to check the state of the pipeline e.g. if
46+
* it is running, done or cancelled.
4447
*
4548
* @param args command line arguments, typically come from the main() method
4649
* @return PipelineResult
@@ -55,8 +58,8 @@ public static PipelineResult runPipeline(String[] args) throws IOException, URIS
5558
/**
5659
* Create and run a Beam pipeline from {@code ImportJobPipelineOptions}.
5760
*
58-
* <p>The returned PipelineResult object can be used to check the state of the pipeline e.g. if it
59-
* is running, done or cancelled.
61+
* <p>The returned PipelineResult object can be used to check the state of the pipeline e.g. if
62+
* it is running, done or cancelled.
6063
*
6164
* @param pipelineOptions configuration for the pipeline
6265
* @return PipelineResult
@@ -81,10 +84,14 @@ public static PipelineResult runPipeline(ImportJobPipelineOptions pipelineOption
8184
setupSource(pipelineOptions.getJobName(), featureSetSpec.getSource());
8285
setupStore(store, featureSetSpec);
8386

84-
pipeline
87+
PCollection<FeatureRowExtended> featureRows = pipeline
8588
.apply("Read FeatureRow", new ReadFeatureRow(featureSetSpec))
8689
.apply("Filter FeatureRow", new FilterFeatureRow(featureSetSpec))
87-
.apply("Create FeatureRowExtended from FeatureRow", new ToFeatureRowExtended())
90+
.apply("Create FeatureRowExtended from FeatureRow", new ToFeatureRowExtended());
91+
92+
featureRows
93+
.apply("Write metrics", new WriteMetricsTransform(store.getName(), featureSetSpec));
94+
featureRows
8895
.apply("Write FeatureRowExtended", new WriteFeaturesTransform(store, featureSetSpec));
8996
}
9097
}
@@ -128,8 +135,9 @@ private static void setupStore(Store store, FeatureSetSpec featureSetSpec) {
128135
* <p>Manually sets the consumer group offset for this job's consumer group to the offset at the
129136
* time at which we provision the ingestion job.
130137
*
131-
* <p>This is necessary because the setup time for certain runners (e.g. Dataflow) might cause the
132-
* worker to miss the messages that were emitted into the stream prior to the workers being ready.
138+
* <p>This is necessary because the setup time for certain runners (e.g. Dataflow) might cause
139+
* the worker to miss the messages that were emitted into the stream prior to the workers being
140+
* ready.
133141
*/
134142
private static void setupSource(String jobName, Source source) {
135143
if (!source.getType().equals(SourceType.KAFKA)) {
@@ -174,4 +182,5 @@ private static void setupSource(String jobName, Source source) {
174182
}
175183
});
176184
}
185+
177186
}

ingestion/src/main/java/feast/ingestion/metrics/FeastMetrics.java

Lines changed: 0 additions & 87 deletions
This file was deleted.

ingestion/src/main/java/feast/ingestion/model/Features.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

ingestion/src/main/java/feast/ingestion/model/Specs.java

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)