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

Reinstate time-to-first-byte-ms metric. #575

Merged
merged 5 commits into from
Jan 7, 2020

Conversation

chrisgresty
Copy link
Contributor

See #550

@chrisgresty chrisgresty marked this pull request as ready for review December 18, 2019 14:44
Copy link
Contributor

@mikkokar mikkokar left a 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;

Copy link
Contributor

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());
Copy link
Contributor

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.

Copy link
Contributor

@mikkokar mikkokar left a 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")
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@mikkokar mikkokar merged commit f3a1d62 into ExpediaGroup:master Jan 7, 2020
@mikkokar mikkokar mentioned this pull request Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants