Skip to content

Commit

Permalink
Stop using prom timer since its in seconds (#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen Zhiling authored and feast-ci-bot committed Nov 28, 2019
1 parent 8c30640 commit 1ef1b71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<FeatureSetSpec> featureSetSpecs =
getFeaturesRequest.getFeatureSetsList().stream()
.map(
Expand Down Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -197,7 +196,7 @@ private void sendAndProcessMultiGet(
throws InvalidProtocolBufferException {

List<byte[]> 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());
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -259,7 +258,7 @@ private boolean isStale(
*/
private List<byte[]> sendMultiGet(List<RedisKey> 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()
Expand All @@ -273,7 +272,7 @@ private List<byte[]> sendMultiGet(List<RedisKey> keys) {
.withCause(e)
.asRuntimeException();
} finally {
sendMultiGetTimer.observeDuration();
requestLatency.labels("sendMultiGet").observe(System.currentTimeMillis() - startTime);
}
}
}
Expand Down

0 comments on commit 1ef1b71

Please sign in to comment.