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

Instrumentation API changes: TimeExtractor with Context idea #6024

Conversation

mateuszrzeszutek
Copy link
Member

@mateuszrzeszutek mateuszrzeszutek commented May 13, 2022

Another part of #6014 (resolves #6014 maybe?)

The first commit contains the actual TimeExtractor changes, the second is an example of how the Timer class from #4514 could look like, using the new API.

@mateuszrzeszutek mateuszrzeszutek requested a review from a team May 13, 2022 10:37
@trask
Copy link
Member

trask commented May 16, 2022

Throwing out a few of other ideas to discuss in today's SIG meeting.

  • Add two new methods on Instrumenter below:

    • pros:
      • users don't need to deal with clocks/timers
      • it's not possible to change endTime, which is good since metrics doesn't support this
    • cons:
      • muddies the clean Instrumenter API with methods that are not very commonly used
      public Context markStartTime(Context parentContext, REQUEST request) {
        // put the current time into the parentContext and return it
      }
    
      public void startAndEndMarked(
          Context context, REQUEST request, @Nullable RESPONSE response, @Nullable Throwable error) {
        // get the start time
        // call start
        // call end
      }
    
  • Add a single new method on Instrumenter:

      public void startAndEnd(
          Context context,
          REQUEST request,
          @Nullable RESPONSE response,
          @Nullable Throwable error,
          long startTimeNanos,
          long endTimeNanos) {
    
      }
    
  • Add a known "Timer" context key (and associated Timer API) that the existing Instrumenter start and stop methods look for. Comparing to this PR:

    • pros:
      • can avoid customizing end time
    • cons:
      • more magical
      • requires checking for the "Timer" context key even in the common case where it's not used
  • This PR, but without passing the REQUEST object

@mateuszrzeszutek
Copy link
Member Author

Closing; we decided to make providing start/end time internal for now. I'll implement that in a separate PR.

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.

Some Instrumentation API thoughts
2 participants