-
Notifications
You must be signed in to change notification settings - Fork 79
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
Reinstate time-to-first-byte-ms metric. #575
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to report TTFB as a latency histogram. Also the time-to-first-byte
should move out of the connection pool scope: a level up in the name hierarchy.
final Histogram timeToFirstByteHistogram = new Histogram(new SlidingWindowReservoir(50)); | ||
private final Supplier<Long> ttfbSupplier = () -> (long) timeToFirstByteHistogram.getSnapshot().getMean(); | ||
private final Supplier<Long> memoizedTtfbSupplier = memoizeWithExpiration(ttfbSupplier::get, 5, MILLISECONDS)::get; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a documented feature, we need to expose TTFB metric as a histogram. But the supplier here just gets the mean of the recorded values.
For TTFB to be useful as a documented feature, we need to report a full histogram. The mean alone does't really say anything. Histogram on the other hand shows accurately when and how the latencies are affected.
@@ -91,6 +91,7 @@ private static void registerMetrics(ConnectionPool hostConnectionPool, MetricReg | |||
scopedRegistry.register("connections-closed", (Gauge<Integer>) () -> (int) stats.closedConnections()); | |||
scopedRegistry.register("connections-terminated", (Gauge<Integer>) () -> (int) stats.terminatedConnections()); | |||
scopedRegistry.register("connections-in-establishment", (Gauge<Integer>) () -> (int) stats.connectionsInEstablishment()); | |||
scopedRegistry.register("time-to-first-byte-ms", (Gauge<Long>) () -> (long) stats.timeToFirstByteMs()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe CodaHale adds a time unit in the metric itself. Therefore I believe -ms
suffix is unnecessary. But better to verify this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment inside ...
However I would also add a Kotlin functional test. Just to show that the metric is being collected with a positive, non-zero value.
@@ -107,7 +107,7 @@ private void removeMetrics() { | |||
MetricRegistry scopedRegistry = getMetricScope(connectionPool); | |||
asList("busy-connections", "pending-connections", "available-connections", "ttfb", | |||
"connection-attempts", "connection-failures", "connections-closed", "connections-terminated", | |||
"connections-in-establishment") | |||
"connections-in-establishment", "time-to-first-byte-ms") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "time-to-first-byte-ms" can be removed here?
* Measured as time to first content byte. | ||
* Timer started when request is sent, and stopped when the first content | ||
byte is received. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
See #550