Skip to content

Internal - Make smoke test detect service entity correlation failures - #681

Merged
cleverchuk merged 5 commits into
mainfrom
cc/NH-155758
Nov 18, 2026
Merged

cleverchuk merged 5 commits into
mainfrom
cc/NH-155758

Conversation

@cleverchuk

Copy link
Copy Markdown
Contributor

TL;DR

v3.3.0 shipped a change that caused SWO to stop correlating telemetry with the Service entity, and the k6 smoke test did not catch it. This PR makes the smoke test validate correlation from the backend's perspective: each run uses a unique service name, and the metric and log checks are scoped to the Service entity the backend inferred, not to the service.name attribute. Verified by reproducing the v3.3.0 behavior on this branch (smoke test fails) and then restoring the fix (smoke test passes).

Why the smoke test missed it

  • Metric checks matched the attribute, not the entity. Metrics were queried with service.name:"java-apm-smoke-test", which matches the raw resource attribute regardless of correlation.

  • The log check was satisfied by the shared service identity. Every run, on every branch, reported as java-apm-smoke-test, so the Service entity was long-lived and not tied to the run under test.

Changes

  • Per-run service name. The petclinic service is named java-apm-smoke-test-<yyyyMMdd-HHmmss> (UTC run start). The name is generated once per test JVM and shared by the petclinic container (both the SW_APM_SERVICE_KEY and declarative sdk-config.yaml variants) and k6. The backend must infer a fresh Service entity on every run, so stale entities and telemetry cannot satisfy the checks.
  • Entity lookup by exact name. The Service entity is resolved with an IN filter on name instead of scanning the first 50 Service entities. The lookup throws if the entity is not found.
  • Entity-scoped metric checks. Metrics are queried with sw.entity.service.id:"<entityId>", the tag the backend adds once telemetry is correlated to a Service entity (the same filter the SWO UI uses for a service's metrics). Logs continue to be queried by entityIds, now reusing the resolved id.
  • Explicit failure on exhaustion. When metric retries are exhausted, a failed check is recorded under the same name. Previously no check was recorded, so the JUnit test failed with PathNotFoundException (run 44204822454) instead of its assertion message (run 44212549919).

Verification

The branch temporarily reproduced v3.3.0 by re-enabling ServiceInstanceIdResourceProvider and removing service.instance.id from ApmResourceProvider. The second change was needed because ApmResourceProvider runs after the upstream provider; its differing service.instance.id value causes the SDK to drop the upstream service.instance entity during resource merge (logged as Removing entity association [service.instance]), which masked the regression.

Check (SmokeTest) Entity exported (v3.3.0 behavior) Fix restored
assertThatMetricsAreExported FAILED PASSED
assertThatRuntimeMetrics17AreExported FAILED PASSED
assertThatLogsAreExported FAILED PASSED

A direct query against the broken run's entity showed the failure mode: metrics were present by service.name but absent by sw.entity.service.id, and no logs were attached to the entity. The temporary changes are reverted in the last commit.

…akage

The k6 checks used a fixed service name, so stale entities and telemetry
from previous runs satisfied them. v3.3.0's entity inference regression
went undetected as a result.

- Suffix the smoke test service name with the run's UTC start datetime
  and share it across petclinic (v1 and v2 sdk-config) and k6
- Throw from getEntityId() when the service entity is not found instead
  of querying logs with an undefined entity id

Temporarily re-enable ServiceInstanceIdResourceProvider to verify the
smoke test now fails; revert before merging.
ApmResourceProvider runs after the upstream ServiceInstanceIdResourceProvider
and its plain service.instance.id attribute strips the upstream
service.instance entity during resource merge, so re-enabling the provider
alone did not reproduce v3.3.0. Remove it so the entity is exported and the
smoke test can be verified against the real breakage; revert before merging.
Metrics were queried by the service.name attribute, which still matches
when the backend fails to correlate telemetry to the Service entity. Query
by sw.entity.service.id instead, the tag the backend adds once telemetry is
correlated, so the checks fail when entity inference breaks.

- Resolve the Service entity once per iteration and reuse its id for the
  metric and log checks
- Look up the entity by exact name instead of scanning the first 50
  Service entities
Exhausting retries without a positive measurement recorded no check, so
the JUnit assertion failed with PathNotFoundException instead of a clear
assertion message. Record an explicit failure under the same check name.
…cation

Revert the temporary changes that reproduced the v3.3.0 entity inference
breakage: disable ServiceInstanceIdResourceProvider again and restore
service.instance.id in ApmResourceProvider. The smoke test was confirmed
to fail with them in place.
@cleverchuk
cleverchuk requested review from a team as code owners November 18, 2026 16:34
Copilot AI balanced review requested due to automatic review settings November 18, 2026 16:34
@cleverchuk cleverchuk changed the title Make smoke test detect service entity correlation failures Internal - Make smoke test detect service entity correlation failures Nov 18, 2026

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.

🟡 Changes recommended

Service names can collide across concurrent test JVMs started in the same UTC second, allowing a healthy release job to satisfy a broken job’s metric and log checks.

1 open issue
What changed in this PR

Strengthens smoke tests to detect failures in backend Service entity correlation, rather than merely checking telemetry resource attributes.

Changes:

  • Shares a timestamp-based service name between PetClinic and k6 for each test JVM.
  • Resolves the Service entity by exact name and scopes metric and log checks to its ID.
  • Records an explicit failed metric check when retries are exhausted.
File Description
smoke-tests/​src/​test/​java/​com/​solarwinds/​util/​ServiceNames.java Generates the shared timestamp-based service name.
smoke-tests/​src/​test/​java/​com/​solarwinds/​containers/​PetClinicRestContainer.java Passes the shared name to both agent configuration variants.
smoke-tests/​src/​test/​java/​com/​solarwinds/​containers/​K6Container.java Supplies the shared service name to k6.
smoke-tests/​sdk-config.yaml Reads the service name from the environment.
smoke-tests/​README.md Documents the new service-name format.
smoke-tests/​k6/​basic.js Adds exact entity lookup, entity-scoped checks, and explicit metric failure reporting.

Review effort: Balanced

@jerrytfleung jerrytfleung left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@cleverchuk
cleverchuk merged commit 2b5f851 into main Nov 18, 2026
18 checks passed
@cleverchuk
cleverchuk deleted the cc/NH-155758 branch November 18, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants