Skip to content
Open
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 @@ -383,13 +383,14 @@ class HealthCheckFields {
String streamName;
String writerId;
String windowStartTime;
String windowDuration;
}

/*
* Compute current values of all health check metrics.
*/
private void gatherHealthCheckMetrics(HealthCheckFields healthCheckFields) {
healthCheckFields.streamName = streamName;
healthCheckFields.streamName = isMultiplexing ? "MULTIPLEXING" : streamName;
healthCheckFields.writerId = writerId;
healthCheckFields.queuedRequestCountMax = windowedQueuedRequestsMax;
healthCheckFields.queuedRetryCountMax = windowedQueuedRetriesMax;
Expand All @@ -412,6 +413,7 @@ private void gatherHealthCheckMetrics(HealthCheckFields healthCheckFields) {
healthCheckFields.connectionClosedCount = windowedConnectionClosedCount;
healthCheckFields.isConnected = streamConnectionIsConnected;
healthCheckFields.windowStartTime = healthCheckTimeStamp.toString();
healthCheckFields.windowDuration = HEALTH_CHECK_INTERVAL.toString();
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ void testHealthCheck() throws Exception {
&& healthCheckFields.msecLongestResponseWaitTime < msecResponseDelay);
assertEquals(appendCount, healthCheckFields.queuedRequestCountMax);
assertEquals(appendCount * sizePerRequest, healthCheckFields.inflightBytes);
assertEquals("projects/p1/datasets/d1/tables/t1/streams/s1", healthCheckFields.streamName);
assertEquals("MULTIPLEXING", healthCheckFields.streamName);
assertEquals(connectionWorker.getWriterId(), healthCheckFields.writerId);
Comment on lines +1209 to 1210
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The new windowDuration field added to the health metrics is not being verified in the tests. Consider adding an assertion to ensure it is correctly populated with the expected interval.

Suggested change
assertEquals("MULTIPLEXING", healthCheckFields.streamName);
assertEquals(connectionWorker.getWriterId(), healthCheckFields.writerId);
assertEquals("MULTIPLEXING", healthCheckFields.streamName);
assertEquals(connectionWorker.getWriterId(), healthCheckFields.writerId);
assertEquals(
ConnectionWorker.HEALTH_CHECK_INTERVAL.toString(), healthCheckFields.windowDuration);
References
  1. When testing for metric generation, it is acceptable to assert the exact number of metrics to ensure no unexpected metrics are produced.


// Wait for responses to arrive
Expand Down Expand Up @@ -1388,6 +1388,7 @@ void testInflightRetryCountHealthMetric() throws Exception {
assertTrue(healthCheckFields.responseCodes.containsKey(Code.INTERNAL.value()));
assertEquals(1, healthCheckFields.responseCodes.get(Code.INTERNAL.value()));
assertFalse(healthCheckFields.responseCodes.containsKey(Status.Code.OK.value()));
assertEquals("MULTIPLEXING", healthCheckFields.streamName);

// Allow the retries to complete successfully
future.get();
Expand Down Expand Up @@ -1499,5 +1500,6 @@ void testInflightRetryCountHealthMetricExactlyOnce() throws Exception {
assertEquals(1, healthCheckFields.responseCodes.get(Code.INTERNAL.value()));
assertTrue(healthCheckFields.responseCodes.containsKey(Status.Code.OK.value()));
assertEquals(3, healthCheckFields.responseCodes.get(Status.Code.OK.value()));
assertEquals("projects/p1/datasets/d1/tables/t1/streams/s1", healthCheckFields.streamName);
}
}
Loading