Skip to content

test(o11y): add tests for tracing, metrics and logging in java-compute#12730

Merged
diegomarquezp merged 67 commits intomainfrom
observability/test/compute-integration-test
May 5, 2026
Merged

test(o11y): add tests for tracing, metrics and logging in java-compute#12730
diegomarquezp merged 67 commits intomainfrom
observability/test/compute-integration-test

Conversation

@diegomarquezp
Copy link
Copy Markdown
Contributor

This PR adds tests for java-compute to confirm behavior of recently added o11y features.

Key changes:

  • sdk-platform-java/gax-java: Overrode requestUrlResolved in CompositeTracer to ensure url.full is recorded in HTTP/REST transport. This was a fix found during testing.
  • java-compute: Introduced ITComputeGoldenSignals.java to validate tracing, metrics, and logging.
  • java-compute: Added GOOGLE_SDK_JAVA_LOGGING=true environment variable to maven-surefire-plugin in pom.xml to enable logging for verification in tests.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces integration tests for observability "golden signals" (traces, metrics, and logs) in the Compute service. It adds necessary OpenTelemetry and logging dependencies to the POM, implements the ITComputeGoldenSignals test class, and updates CompositeTracer to delegate requestUrlResolved calls. Review feedback identifies an opportunity to prevent test flakiness by clearing the TestAppender state between tests and suggests removing a redundant call to getMDCPropertyMap in the appender's logic.

@diegomarquezp diegomarquezp marked this pull request as ready for review April 9, 2026 19:01
@diegomarquezp diegomarquezp requested a review from a team as a code owner April 9, 2026 19:01
Duration currentDelay = retrySettings.getInitialRetryDelayDuration();
com.google.monitoring.v3.TimeSeries targetTs = null;

while (metricsPollingStopwatch.elapsed().compareTo(retrySettings.getTotalTimeoutDuration())
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.

It seems a little too aggressive to put this in a while loop. Usually how long does it take for the metrics to show up?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It takes from 1 to 3 minutes. I modified this to polling every 30 seconds up to 3 minutes.

validateMetricsInCloudMonitoring(expectError);
}

private void validateLogging(boolean expectError) {
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.

Ideally we want to test with Cloud Logging, but I know it is hard to test without a proper exporter, so this is good enough for now.

Neenu1995 pushed a commit that referenced this pull request Apr 17, 2026
Comment thread java-compute/google-cloud-compute/pom.xml
@diegomarquezp diegomarquezp force-pushed the observability/test/compute-integration-test branch from 54d637c to aa22260 Compare April 29, 2026 18:39
@diegomarquezp
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces integration tests for 'golden signals' (traces, metrics, and logs) within the Compute library, updating several POM files to include OpenTelemetry and Logback dependencies and configuring environment variables for logging. Feedback indicates that the selected Logback version (1.5.25) is incompatible with Java 8, which the repository maintains, and suggests using a thread-safe collection in the test appender to avoid potential concurrency issues.

Comment thread google-cloud-jar-parent/pom.xml
Comment thread java-logging-logback/pom.xml
Duration pollInterval = Duration.ofSeconds(30);
TimeSeries targetTs = null;

while (metricsPollingStopwatch.elapsed().compareTo(totalTimeout) < 0) {
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.

This while loop might be too aggressive, can we do it every x seconds?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I put a Thread.sleep() at the end of the while loop of 30 seconds.

logger.info("Waiting for metrics in Cloud Monitoring, retrying in 30 seconds...");
Thread.sleep(pollInterval.toMillis());
}

Comment thread java-compute/google-cloud-compute/pom.xml Outdated
@diegomarquezp diegomarquezp merged commit f1faf60 into main May 5, 2026
129 of 131 checks passed
@diegomarquezp diegomarquezp deleted the observability/test/compute-integration-test branch May 5, 2026 01:29
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.

4 participants