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

split info spans when logging request IDs #420

Merged
merged 1 commit into from
Aug 28, 2024
Merged

Conversation

joeshaw
Copy link
Member

@joeshaw joeshaw commented Aug 27, 2024

Otherwise we end up with log messages that include multiple request
IDs when we are processing concurrent requests.

Otherwise we end up with log messages that include multiple request
IDs when we are processing concurrent requests.
@joeshaw
Copy link
Member Author

joeshaw commented Aug 27, 2024

Following #146, concurrent requests would look like:

2024-08-26T23:23:14.155726Z  INFO request{id=5}:request{id=14}:request{id=18}:request{id=23}:request{id=39}:request{id=51}:request{id=60}:request{id=61}:request{id=62}:request{id=76}:request{id=80}:request{id=115}:request{id=117}:request{id=119}:request{id=129}:request{id=135}:request{id=141}:request{id=147}: request completed using 1.7 MB of WebAssembly heap

This PR addresses that by using two info spans, one for the tokio task itself and one for handling the request after reading off the receiver channel.

@cee-dub
Copy link
Contributor

cee-dub commented Aug 27, 2024

Is the tokio task like a "global span" or is the scope a bit smaller than that? Two reasons:

  • It could be a memory leak
  • not sure of the utility of a single span for a whole series of requests

Also, my question might be irrelevant if I'm thinking of something like OTEL tracing and this is a more basic thing.

@joeshaw
Copy link
Member Author

joeshaw commented Aug 27, 2024

The tokio task is the thing that runs the Wasm guest code, so the first span applies only to that task.

The bigger issue I think was the span across the receiver.await. What I think is happening is that each incoming request was creating a span, then blocking waiting for the response. When the response was popped off, there were still a bunch of spans still alive and blocking on their own, so you got request IDs for each of the waiting ones.

This breaks things into two spans, with the same data (the request ID). One for the task which tokio runs (this is basically a revert of #146), and then another one that's created just after the response is taken off the receiver channel, and only applies to the work after it's done.

Copy link
Contributor

@cee-dub cee-dub left a comment

Choose a reason for hiding this comment

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

Ah ha, I see #416 and how this relates. Are there any messages that now lack the request ID on this branch? I imagine perfecting this isn’t currently worth much more effort. Fixing the obvious bug is great.

@joeshaw
Copy link
Member Author

joeshaw commented Aug 28, 2024

Are there any messages that now lack the request ID on this branch?

I don't think so, but I have only anecdotal evidence. Rrunning 4 services locally and then running a highly parallel integration test suite against them, all the messages that are generated by Viceroy itself include the request ID.

@joeshaw joeshaw merged commit c70154b into main Aug 28, 2024
15 checks passed
@joeshaw joeshaw deleted the joeshaw/split-info-spans branch August 28, 2024 19:28
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