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

Add tracing span parameters to getActor operations #1007

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/workerd/io/io-channels.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,16 @@ class IoChannelFactory {
};

virtual kj::Own<ActorChannel> getGlobalActor(uint channel, const ActorIdFactory::ActorId& id,
kj::Maybe<kj::String> locationHint, ActorGetMode mode) = 0;
kj::Maybe<kj::String> locationHint, ActorGetMode mode, SpanParent parentSpan) = 0;
// Get an actor stub from the given namespace for the actor with the given ID.
//
// `id` must have been constructed using one of the `ActorIdFactory` instances corresponding to
// one of the worker's bindings, however it doesn't necessarily have to be from the the correct
// `ActorIdFactory` -- if it's from some other factory, the method will throw an appropriate
// exception.

virtual kj::Own<ActorChannel> getColoLocalActor(uint channel, kj::StringPtr id) = 0;
virtual kj::Own<ActorChannel> getColoLocalActor(uint channel, kj::StringPtr id,
SpanParent parentSpan) = 0;
// Get an actor stub from the given namespace for the actor with the given name.
};

Expand Down
5 changes: 3 additions & 2 deletions src/workerd/io/io-context.h
Original file line number Diff line number Diff line change
Expand Up @@ -809,10 +809,11 @@ class IoContext final: public kj::Refcounted, private kj::TaskSet::ErrorHandler
kj::Own<IoChannelFactory::ActorChannel> getGlobalActorChannel(
uint channel, const ActorIdFactory::ActorId& id, kj::Maybe<kj::String> locationHint,
ActorGetMode mode) {
return getIoChannelFactory().getGlobalActor(channel, id, kj::mv(locationHint), mode);
return getIoChannelFactory().getGlobalActor(channel, id, kj::mv(locationHint), mode,
getCurrentTraceSpan());
}
kj::Own<IoChannelFactory::ActorChannel> getColoLocalActorChannel(uint channel, kj::StringPtr id) {
return getIoChannelFactory().getColoLocalActor(channel, id);
return getIoChannelFactory().getColoLocalActor(channel, id, getCurrentTraceSpan());
}

kj::Own<CacheClient> getCacheClient();
Expand Down
5 changes: 3 additions & 2 deletions src/workerd/server/server.c++
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,7 @@ private:
}

kj::Own<ActorChannel> getGlobalActor(uint channel, const ActorIdFactory::ActorId& id,
kj::Maybe<kj::String> locationHint, ActorGetMode mode) override {
kj::Maybe<kj::String> locationHint, ActorGetMode mode, SpanParent parentSpan) override {
JSG_REQUIRE(mode == ActorGetMode::GET_OR_CREATE, Error,
"workerd only supports GET_OR_CREATE mode for getting actor stubs");
auto& channels = KJ_REQUIRE_NONNULL(ioChannels.tryGet<LinkedIoChannels>(),
Expand All @@ -1721,7 +1721,8 @@ private:
return ns.getActorChannel(id.clone());
}

kj::Own<ActorChannel> getColoLocalActor(uint channel, kj::StringPtr id) override {
kj::Own<ActorChannel> getColoLocalActor(uint channel, kj::StringPtr id,
SpanParent parentSpan) override {
auto& channels = KJ_REQUIRE_NONNULL(ioChannels.tryGet<LinkedIoChannels>(),
"link() has not been called");

Expand Down
5 changes: 3 additions & 2 deletions src/workerd/tests/test-fixture.c++
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ struct DummyIoChannelFactory final: public IoChannelFactory {
}

kj::Own<ActorChannel> getGlobalActor(uint channel, const ActorIdFactory::ActorId& id,
kj::Maybe<kj::String> locationHint, ActorGetMode mode) override {
kj::Maybe<kj::String> locationHint, ActorGetMode mode, SpanParent parentSpan) override {
KJ_FAIL_REQUIRE("no actor channels");
}

kj::Own<ActorChannel> getColoLocalActor(uint channel, kj::StringPtr id) override {
kj::Own<ActorChannel> getColoLocalActor(uint channel, kj::StringPtr id,
SpanParent parentSpan) override {
KJ_FAIL_REQUIRE("no actor channels");
}

Expand Down