Skip to content

chore: Fix CounterTest created timestamp flake#2049

Merged
zeitlinger merged 1 commit intomainfrom
codex/fix-countertest-created-timestamp-flake
Apr 24, 2026
Merged

chore: Fix CounterTest created timestamp flake#2049
zeitlinger merged 1 commit intomainfrom
codex/fix-countertest-created-timestamp-flake

Conversation

@zeitlinger
Copy link
Copy Markdown
Member

What changed

Relaxed the CounterTest.testTotalStrippedFromName protobuf text assertion so created_timestamp accepts both forms emitted by protobuf text format:

  • created_timestamp { seconds: ... nanos: ... }
  • created_timestamp { seconds: ... }

Why

This test was flaky when the created timestamp landed exactly on a whole-second boundary. In that case, protobuf text format omits the nanos field when it is zero, but the test required nanos to always be present.

Impact

This does not change product behavior. It removes a nondeterministic test failure in CI by matching the actual protobuf output contract more accurately.

Root cause

The assertion encoded a stronger formatting assumption than protobuf guarantees. protobuf-java may omit zero-valued nanos in text output.

Validation

  • ./mvnw test -pl prometheus-metrics-core -Dtest=CounterTest#testTotalStrippedFromName -Dcoverage.skip=true -Dcheckstyle.skip=true
  • mise run build

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@zeitlinger zeitlinger changed the title [codex] Fix CounterTest created timestamp flake chore: Fix CounterTest created timestamp flake Apr 24, 2026
@zeitlinger zeitlinger marked this pull request as ready for review April 24, 2026 12:31
@zeitlinger zeitlinger merged commit e898720 into main Apr 24, 2026
15 of 16 checks passed
@zeitlinger zeitlinger deleted the codex/fix-countertest-created-timestamp-flake branch April 24, 2026 12:48
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