Skip to content

Print the span info on span exit and entry #16

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 2 commits into from
Aug 18, 2020

Conversation

oli-obk
Copy link
Collaborator

@oli-obk oli-obk commented Aug 17, 2020

I may have went a bit overboard with this one. I wanted to somehow render the fact that we're just re-emitting the current span info

Screenshot from 2020-08-17 15-19-16

Copy link
Owner

@davidbarsky davidbarsky left a comment

Choose a reason for hiding this comment

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

This rules! Thanks for opening this PR.

How do you feel introducing a similar implementation that you have in on_exit to on_close but also emitting the duration of the span? Since spans can be entered and existed multiple times having something to delineate that a span has just closed/exited for the last time can be really handy.

@oli-obk
Copy link
Collaborator Author

oli-obk commented Aug 17, 2020

Do you mean just the current duration from the start, or the duration the span was open? In the latter case we have to store the opening somewhere, any tips?

@davidbarsky
Copy link
Owner

I'm sorry my message wasn't more clear, let me try to rephrase. I think that there are a few distinct requests that I didn't properly separate.

  • I'd like to be able to visually distinguish between a span that has exited and a span that has closed. That could be done with durations, but that's not the only approach.
    • As I'm writing this comment, I remembered that tracing-tree isn't really used with asynchronous or non-blocking code. Therefore, I'm not sure how useful this feature is in the first place.
  • One idea I had was to use durations from the start of the span. However, after thinking about it a bit more, I realized that this opens a larger design space that's best discussed in a separate issue. I'd prefer to not block merging this PR on that point.

In the latter case we have to store the opening somewhere, any tips?

Sure! Here's the approach I was thinking of:

  • new_span creates a DateTime<Local>. Nothing needs to change here.
  • In an on_exit or on_close method, copy this approach to calculate the elapsed time of the span.

Again, the above approach can be done in a followup, but I'd like to hash out an approach first in an issue. I really love this PR as is and I'd be happy to merge it as-is, as I don't want to let perfect be the enemy of good 😄.

@oli-obk
Copy link
Collaborator Author

oli-obk commented Aug 17, 2020

We have a few subtle ways to signal that something is different. One would be to use some of the bold or double box drawing chars from https://en.wikipedia.org/wiki/Box-drawing_character This could look like

│┌┘
╞╛

(without the space between the lines, that's just github)

Also we can use bold lines instead of double lines.

I'll open an issue for the timings

@davidbarsky
Copy link
Owner

We have a few subtle ways to signal that something is different. One would be to use some of the bold or double box drawing chars from https://en.wikipedia.org/wiki/Box-drawing_character. This could look like [redacted]

That's a reasonable approach. For what it's worth, I think this PR is fine as-is. We can add some specific formatting for a span closing, if there's a need for it. I think that printing:

  • The time the span was most recently active on exit, and
  • The time the span was most recently active and it's total age (busy + idle)

will allow us to distinguish between an exited span and a closed span, respectively.

@oli-obk
Copy link
Collaborator Author

oli-obk commented Aug 18, 2020

For what it's worth, I think this PR is fine as-is.

ok :D then let's merge it for now and figure out the details about other improvements in the issue.

@davidbarsky davidbarsky merged commit c46446b into davidbarsky:main Aug 18, 2020
@oli-obk oli-obk deleted the wraparound branch August 18, 2020 16:14
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