-
Notifications
You must be signed in to change notification settings - Fork 479
Add tracing spans for input and output gates hold and wait #5563
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |||||
| // https://opensource.org/licenses/Apache-2.0 | ||||||
|
|
||||||
| #include "actor-cache.h" | ||||||
| #include "workerd/io/io-gate.h" | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| #include <workerd/api/actor-state.h> | ||||||
| #include <workerd/api/global-scope.h> | ||||||
|
|
@@ -3441,15 +3442,25 @@ struct Worker::Actor::Impl { | |||||
|
|
||||||
| void inputGateLocked() override { | ||||||
| metrics.inputGateLocked(); | ||||||
| if (IoContext::hasCurrent()) { | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should always have an active IoContext shouldn't we? auto& context = IoContext::current();
auto inputGateHoldSpan = context.makeTraceSpan("actor_input_gate_hold"_kjc);Should be better
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on my testing, we don't have IoContext when we invoke the input gate or hold them. I am trying to see if I can use the parent's context.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would really limit the effectiveness and reliability of this PR. I don't understand input gates well enough but I would love to learn more about them to understand how to best approach this. |
||||||
| auto& ioContext = IoContext::current(); | ||||||
| inputGateHoldSpan = ioContext.makeTraceSpan("actor_input_gate_hold"_kjc); | ||||||
| } | ||||||
| } | ||||||
| void inputGateReleased() override { | ||||||
| metrics.inputGateReleased(); | ||||||
| inputGateHoldSpan = kj::none; | ||||||
| } | ||||||
| void inputGateWaiterAdded() override { | ||||||
| metrics.inputGateWaiterAdded(); | ||||||
| if (IoContext::hasCurrent()) { | ||||||
| auto& ioContext = IoContext::current(); | ||||||
| inputGateWaitSpan = ioContext.makeTraceSpan("actor_input_gate_wait"_kjc); | ||||||
| } | ||||||
| } | ||||||
| void inputGateWaiterRemoved() override { | ||||||
| metrics.inputGateWaiterRemoved(); | ||||||
| inputGateWaitSpan = kj::none; | ||||||
| } | ||||||
| // Implements InputGate::Hooks. | ||||||
|
|
||||||
|
|
@@ -3469,15 +3480,25 @@ struct Worker::Actor::Impl { | |||||
|
|
||||||
| void outputGateLocked() override { | ||||||
| metrics.outputGateLocked(); | ||||||
| if (IoContext::hasCurrent()) { | ||||||
| auto& ioContext = IoContext::current(); | ||||||
| outputGateHoldSpan = ioContext.makeTraceSpan("actor_output_gate_hold"_kjc); | ||||||
| } | ||||||
| } | ||||||
| void outputGateReleased() override { | ||||||
| metrics.outputGateReleased(); | ||||||
| outputGateHoldSpan = kj::none; | ||||||
| } | ||||||
| void outputGateWaiterAdded() override { | ||||||
| metrics.outputGateWaiterAdded(); | ||||||
| if (IoContext::hasCurrent()) { | ||||||
| auto& ioContext = IoContext::current(); | ||||||
| outputGateWaitSpan = ioContext.makeTraceSpan("actor_output_gate_wait"_kjc); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is naively overwriting any existing span, but it's possible for an OutputGate to have multiple waiters. I'll look more closely in a minute, but I'd expect us to want to attach a span to each (traced) waiter
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I'd think we could hold these WaitSpan variables in the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested with one request and this works, but or input gates the IoContext is not set at the point where the gates are held/waited, so have to use the parent's IoContext or pass in a parent span. I am working on that change now, will mostly switch to same model for outpute gate too |
||||||
| } | ||||||
| } | ||||||
| void outputGateWaiterRemoved() override { | ||||||
| metrics.outputGateWaiterRemoved(); | ||||||
| outputGateWaitSpan = kj::none; | ||||||
| } | ||||||
|
|
||||||
| // Implements ActorCache::Hooks | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.