Skip to content

Stabilize SamplingProfilerTest#3000

Open
zeitlinger wants to merge 1 commit into
open-telemetry:mainfrom
zeitlinger:agent/fix-sampling-profiler-flake
Open

Stabilize SamplingProfilerTest#3000
zeitlinger wants to merge 1 commit into
open-telemetry:mainfrom
zeitlinger:agent/fix-sampling-profiler-flake

Conversation

@zeitlinger

Copy link
Copy Markdown
Member

Summary

  • wait for the next profiling session after aInferred(tracer) in SamplingProfilerTest.testProfileTransaction()
  • keep the test assertions unchanged while removing the race between transaction work and session rollover

Why

SamplingProfilerTest.testProfileTransaction() can observe the inferred work before the profiler has advanced into the next session, which makes the test flaky.

Waiting for the next session keeps the existing behavior under test but avoids asserting too early.

Testing

  • GRADLE_USER_HOME=/tmp/gradle-home-otel-java-contrib ./gradlew --no-build-cache --no-configuration-cache :inferred-spans:test --tests io.opentelemetry.contrib.inferredspans.internal.SamplingProfilerTest

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@zeitlinger
zeitlinger marked this pull request as ready for review July 14, 2026 10:09
@zeitlinger
zeitlinger requested a review from a team as a code owner July 14, 2026 10:09
Copilot AI review requested due to automatic review settings July 14, 2026 10:09

Copilot AI left a comment

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.

Pull request overview

This PR aims to stabilize SamplingProfilerTest.testProfileTransaction() by removing a race between inferred work (aInferred(tracer)) and profiling session rollover, while keeping the existing assertions and behavior under test.

Changes:

  • Adds an additional Awaitility wait intended to ensure the next profiling session has started after aInferred(tracer) runs.
  • Keeps the existing span assertions unchanged while attempting to eliminate timing-related flakiness.

Comment on lines +186 to +188
await()
.timeout(Duration.ofSeconds(10))
.until(() -> setup.profiler.getProfilingSessions() > currentSession + 1);
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