33// https://opensource.org/licenses/Apache-2.0
44
55#include " actor-cache.h"
6+ #include " workerd/io/io-gate.h"
67
78#include < workerd/api/actor-state.h>
89#include < workerd/api/global-scope.h>
@@ -3441,15 +3442,25 @@ struct Worker::Actor::Impl {
34413442
34423443 void inputGateLocked () override {
34433444 metrics.inputGateLocked ();
3445+ if (IoContext::hasCurrent ()) {
3446+ auto & ioContext = IoContext::current ();
3447+ inputGateHoldSpan = ioContext.makeTraceSpan (" actor_input_gate_hold" _kjc);
3448+ }
34443449 }
34453450 void inputGateReleased () override {
34463451 metrics.inputGateReleased ();
3452+ inputGateHoldSpan = kj::none;
34473453 }
34483454 void inputGateWaiterAdded () override {
34493455 metrics.inputGateWaiterAdded ();
3456+ if (IoContext::hasCurrent ()) {
3457+ auto & ioContext = IoContext::current ();
3458+ inputGateWaitSpan = ioContext.makeTraceSpan (" actor_input_gate_wait" _kjc);
3459+ }
34503460 }
34513461 void inputGateWaiterRemoved () override {
34523462 metrics.inputGateWaiterRemoved ();
3463+ inputGateWaitSpan = kj::none;
34533464 }
34543465 // Implements InputGate::Hooks.
34553466
@@ -3469,15 +3480,25 @@ struct Worker::Actor::Impl {
34693480
34703481 void outputGateLocked () override {
34713482 metrics.outputGateLocked ();
3483+ if (IoContext::hasCurrent ()) {
3484+ auto & ioContext = IoContext::current ();
3485+ outputGateHoldSpan = ioContext.makeTraceSpan (" actor_output_gate_hold" _kjc);
3486+ }
34723487 }
34733488 void outputGateReleased () override {
34743489 metrics.outputGateReleased ();
3490+ outputGateHoldSpan = kj::none;
34753491 }
34763492 void outputGateWaiterAdded () override {
34773493 metrics.outputGateWaiterAdded ();
3494+ if (IoContext::hasCurrent ()) {
3495+ auto & ioContext = IoContext::current ();
3496+ outputGateWaitSpan = ioContext.makeTraceSpan (" actor_output_gate_wait" _kjc);
3497+ }
34783498 }
34793499 void outputGateWaiterRemoved () override {
34803500 metrics.outputGateWaiterRemoved ();
3501+ outputGateWaitSpan = kj::none;
34813502 }
34823503
34833504 // Implements ActorCache::Hooks
0 commit comments