mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 17:07:15 +02:00
Fix proxy metrics instrumentation bug
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=197209531
This commit is contained in:
parent
68b24f0a54
commit
0cb303ed7f
4 changed files with 27 additions and 18 deletions
|
@ -113,6 +113,10 @@ public class BackendMetricsHandler extends ChannelDuplexHandler {
|
|||
}
|
||||
FullHttpRequest request = (FullHttpRequest) msg;
|
||||
|
||||
// Record request size now because the content would have read by the time the listener is
|
||||
// called and the readable bytes would be zero by then.
|
||||
int bytes = request.content().readableBytes();
|
||||
|
||||
// Record sent time before write finishes allows us to take network latency into account.
|
||||
DateTime sentTime = clock.nowUtc();
|
||||
ChannelFuture unusedFuture =
|
||||
|
@ -121,7 +125,7 @@ public class BackendMetricsHandler extends ChannelDuplexHandler {
|
|||
future -> {
|
||||
if (future.isSuccess()) {
|
||||
// Only instrument request metrics when the request is actually sent to GAE.
|
||||
metrics.requestSent(relayedProtocolName, clientCertHash, request);
|
||||
metrics.requestSent(relayedProtocolName, clientCertHash, bytes);
|
||||
requestSentTimeQueue.add(sentTime);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -23,7 +23,6 @@ import com.google.monitoring.metrics.IncrementableMetric;
|
|||
import com.google.monitoring.metrics.LabelDescriptor;
|
||||
import com.google.monitoring.metrics.MetricRegistryImpl;
|
||||
import google.registry.util.NonFinalForTesting;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.FullHttpResponse;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
@ -112,9 +111,9 @@ public class BackendMetrics {
|
|||
}
|
||||
|
||||
@NonFinalForTesting
|
||||
public void requestSent(String protocol, String certHash, FullHttpRequest request) {
|
||||
public void requestSent(String protocol, String certHash, int bytes) {
|
||||
requestsCounter.increment(protocol, certHash);
|
||||
requestBytes.record(request.content().readableBytes(), protocol, certHash);
|
||||
requestBytes.record(bytes, protocol, certHash);
|
||||
}
|
||||
|
||||
@NonFinalForTesting
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue