Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change latency calculation method to not use Timer #338

Merged
merged 1 commit into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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