opentelemetry-sdk-workers
opentelemetry-sdk-workers copied to clipboard
Instrument Durable Objects
Hey there 👋
It would be nice if we can instrument the fetch
call to durable objects.
Like #11, an MVP should be the SDK taking the durable object stub, and returning a wrapper with the same fetch interface that makes sure the trace is propagated. I believe the "receive" end should just work as long as it's a normal fetch handler also.
This may be "done" via #21, but I haven't validated.
This is likely resolved with 0.6.0, however I'm not sure about the recieving end so keeping this open.
I'm afraid this won't work for Durable Objects because of slightly different syntax:
const id = env.DURABLE_OBJ.idFromName('xxx')
const stub = env.DURABLE_OBJ.get(id); // this method will fail with sdk
const response = await stub.fetch(request);
So, we canot just simply have sdk.env.DURABLE_OBJ.fetch
or sdk.env.DURABLE_OBJ.get(id).fetch
Maybe as an idea, it makes sense to make public methods to create spans so that Durable Object invocation can at least be manually 'wrapped':
sdk.createSpan();
durableObjects.get...fetch();
sdk.endSpan();
Ah darn, I thought it had the same syntax. I forgot it stubbed out. It should still be possible to proxy the stub however 🤔.
I could definitely add support for creating spans directly, though it might be a little weird due to the way the SDK currently works. #26 might help make that "just work"