Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use epoch milli to check span start/stop #60

Merged
merged 1 commit into from
Sep 9, 2022

Conversation

ttddyy
Copy link
Contributor

@ttddyy ttddyy commented Sep 7, 2022

Prior to this change, TracerAssert#onlySpan randomly failed.

This was because it had followings to check a span has started/stopped.

assertTrue(span.getStartTimestamp().getNano() > 0, "Span must be started");
assertTrue(span.getEndTimestamp().getNano() > 0, "Span must be finished");

The getNano() could return 0 for valid Instant.

For example:

Instant i = Instant.parse("2022-09-07T00:33:58Z");
assertThat(i.getNano()).isEqualTo(0);

i = Instant.ofEpochMilli(1662510838000L);
assertThat(i.getNano()).isEqualTo(0);

Instead of using getNano(), this PR changes to constantly use toEpochMilli() > 0 to check whether the span has started or stopped.

Instant.ofEpochMilli(0).toEpochMilli() returns 0 whereas Instant.ofEpochMilli(10).toEpochMilli() returns 10.

@marcingrzejszczak marcingrzejszczak added the bug A general bug label Sep 9, 2022
@marcingrzejszczak marcingrzejszczak added this to the 1.0.0-M8 milestone Sep 9, 2022
@marcingrzejszczak marcingrzejszczak merged commit b2d0c6b into micrometer-metrics:main Sep 9, 2022
@ttddyy ttddyy deleted the use-epochMilli branch September 9, 2022 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants