From d4d453a0e43731b426d7712cab5a910402e5c5e6 Mon Sep 17 00:00:00 2001 From: zhilingc Date: Thu, 28 Nov 2019 16:40:35 +0800 Subject: [PATCH] Stop using prom timer since its in seconds --- .../serving/service/BigQueryServingService.java | 5 ++--- .../feast/serving/service/RedisServingService.java | 13 ++++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/serving/src/main/java/feast/serving/service/BigQueryServingService.java b/serving/src/main/java/feast/serving/service/BigQueryServingService.java index f846345215..15d30c440c 100644 --- a/serving/src/main/java/feast/serving/service/BigQueryServingService.java +++ b/serving/src/main/java/feast/serving/service/BigQueryServingService.java @@ -55,7 +55,6 @@ import feast.serving.ServingAPIProto.JobType; import feast.serving.util.BigQueryUtil; import io.grpc.Status; -import io.prometheus.client.Histogram.Timer; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -113,7 +112,7 @@ public GetOnlineFeaturesResponse getOnlineFeatures(GetOnlineFeaturesRequest getF /** {@inheritDoc} */ @Override public GetBatchFeaturesResponse getBatchFeatures(GetBatchFeaturesRequest getFeaturesRequest) { - Timer getBatchFeaturesTimer = requestLatency.labels("getBatchFeatures").startTimer(); + long startTime = System.currentTimeMillis(); List featureSetSpecs = getFeaturesRequest.getFeatureSetsList().stream() .map( @@ -249,7 +248,7 @@ public GetBatchFeaturesResponse getBatchFeatures(GetBatchFeaturesRequest getFeat }) .start(); - getBatchFeaturesTimer.observeDuration(); + requestLatency.labels("getBatchFeatures").observe(System.currentTimeMillis() - startTime); return GetBatchFeaturesResponse.newBuilder().setJob(feastJob).build(); } diff --git a/serving/src/main/java/feast/serving/service/RedisServingService.java b/serving/src/main/java/feast/serving/service/RedisServingService.java index 38a3ae63d9..a3085045fd 100644 --- a/serving/src/main/java/feast/serving/service/RedisServingService.java +++ b/serving/src/main/java/feast/serving/service/RedisServingService.java @@ -46,7 +46,6 @@ import io.grpc.Status; import io.opentracing.Scope; import io.opentracing.Tracer; -import io.prometheus.client.Histogram.Timer; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -80,7 +79,7 @@ public GetFeastServingInfoResponse getFeastServingInfo( @Override public GetOnlineFeaturesResponse getOnlineFeatures(GetOnlineFeaturesRequest request) { try (Scope scope = tracer.buildSpan("Redis-getOnlineFeatures").startActive(true)) { - Timer getOnlineFeaturesTimer = requestLatency.labels("getOnlineFeatures").startTimer(); + long startTime = System.currentTimeMillis(); GetOnlineFeaturesResponse.Builder getOnlineFeaturesResponseBuilder = GetOnlineFeaturesResponse.newBuilder(); @@ -121,7 +120,7 @@ public GetOnlineFeaturesResponse getOnlineFeatures(GetOnlineFeaturesRequest requ featureValuesMap.values().stream() .map(m -> FieldValues.newBuilder().putAllFields(m).build()) .collect(Collectors.toList()); - getOnlineFeaturesTimer.observeDuration(); + requestLatency.labels("getOnlineFeatures").observe(System.currentTimeMillis() - startTime); return getOnlineFeaturesResponseBuilder.addAllFieldValues(fieldValues).build(); } } @@ -197,7 +196,7 @@ private void sendAndProcessMultiGet( throws InvalidProtocolBufferException { List jedisResps = sendMultiGet(redisKeys); - Timer processResponseTimer = requestLatency.labels("processResponse").startTimer(); + long startTime = System.currentTimeMillis(); try (Scope scope = tracer.buildSpan("Redis-processResponse").startActive(true)) { String featureSetId = String.format("%s:%d", featureSetRequest.getName(), featureSetRequest.getVersion()); @@ -234,7 +233,7 @@ private void sendAndProcessMultiGet( .forEach(f -> featureValues.put(featureSetId + ":" + f.getName(), f.getValue())); } } finally { - processResponseTimer.observeDuration(); + requestLatency.labels("processResponse").observe(System.currentTimeMillis() - startTime); } } @@ -259,7 +258,7 @@ private boolean isStale( */ private List sendMultiGet(List keys) { try (Scope scope = tracer.buildSpan("Redis-sendMultiGet").startActive(true)) { - Timer sendMultiGetTimer = requestLatency.labels("sendMultiGet").startTimer(); + long startTime = System.currentTimeMillis(); try (Jedis jedis = jedisPool.getResource()) { byte[][] binaryKeys = keys.stream() @@ -273,7 +272,7 @@ private List sendMultiGet(List keys) { .withCause(e) .asRuntimeException(); } finally { - sendMultiGetTimer.observeDuration(); + requestLatency.labels("sendMultiGet").observe(System.currentTimeMillis() - startTime); } } }