Skip to content

Allow custom timestamps to be used on Span.end() #115

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

Merged
merged 1 commit into from
May 10, 2024

Conversation

rafaelring
Copy link
Contributor

Which problem is this PR solving?

Currently it's possible to start spans with a custom startTime but it isn't possible to set a custom endTime when ending them. This is useful for dispatching spans that happened on a different time window than the moment in which start()/end() were called.

Short description of the change

This PR adds a new optional endTime parameter to the Span.end() method which allows a custom endTime to be set on the Span rather than always using the timestamp.now.

How Has This Been Tested?

Added a new integration test in which we create a Span with a custom startTime and then end it with a custom endTime and validate the actual reported timestamps.

Checklist:

  • Unit tests have been added
  • Documentation has been updated

@aviary2-wf
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on Slack: #support-infosec.

@blakeroberts-wk
Copy link
Contributor

@rafaelring would you mind merging master or rebasing off master?

@rafaelzlisboa
Copy link

rafaelzlisboa commented May 3, 2024

Hi folks, sorry for the radio silence! We've updated the branch with the current master and will update the code to be compatible with master :)

@rafaelzlisboa
Copy link

@blakeroberts-wk how could we get approval to run the CI again? I belive we've addressed the changes that made it break last time 😓

[],
sdk.SpanLimits(),
startTime);
expect(span.startTime, Int64(1000000000000));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
expect(span.startTime, Int64(1000000000000));
expect(span.startTime, startTime);

span.end(endTime: Int64(1000000020000));
expect(span.startTime, Int64(1000000000000));
expect(span.endTime, Int64(1000000020000));
expect(span.endTime, greaterThan(span.startTime));
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove line, unnecessary expectation given the previous line

verifyNever(() => mockProcessor1.onEnd(span));
verifyNever(() => mockProcessor2.onEnd(span));

span.end(endTime: Int64(1000000020000));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
span.end(endTime: Int64(1000000020000));
final endTime = Int64(1000000020000);
span.end(endTime: endTime);


span.end(endTime: Int64(1000000020000));
expect(span.startTime, Int64(1000000000000));
expect(span.endTime, Int64(1000000020000));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
expect(span.endTime, Int64(1000000020000));
expect(span.endTime, endTime);

As it's possible for Spans to be started with a custom startTime, this
commit adds support for ending a span with a custom endTime.
@rafaelzlisboa
Copy link

@blakeroberts-wk thank you for the review - changes made :)

@changliu-wk
Copy link
Contributor

@Workiva/release-management-p

@changliu-wk
Copy link
Contributor

QA +1

Copy link

@rmconsole-wf rmconsole-wf left a comment

Choose a reason for hiding this comment

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

+1 from RM

@rmconsole7-wk rmconsole7-wk merged commit 9cc0911 into Workiva:master May 10, 2024
4 checks passed
@rafaelzlisboa rafaelzlisboa deleted the span-endtime branch May 22, 2024 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants