feat(core): Instrument workers-ai-provider#22119
Conversation
size-limit report 📦
|
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a22515d. Configure here.
| }) as T; | ||
|
|
||
| instrumentedClients.add(instrumented); | ||
| return instrumented; |
There was a problem hiding this comment.
WeakSet misses original client
Medium Severity
instrumentWorkersAiClient only registers the proxy in instrumentedClients, not the binding passed in. A second call with the same original env.AI (or manual wrap after auto instrumentation) is not recognized and wraps again, so each run can emit nested spans.
Reviewed by Cursor Bugbot for commit a22515d. Configure here.
|
|
||
| instrumentedClients.add(instrumented); | ||
| return instrumented; | ||
| } |
There was a problem hiding this comment.
Missing integration or E2E test
Low Severity
This feature PR adds Workers AI instrumentation with unit tests only. Per SDK review guidelines, a feat change should include at least one integration or E2E test exercising the new tracing behavior end-to-end.
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit a22515d. Configure here.


closes #20839
closes JS-2449
This is instrumenting
workers-ai, but it needs to be wrapped, as in Cloudflare there is no monkey patching for bindings. In a follow-up PR this will be included in theinstrumentEnvwithin Cloudflare.Tbh I would have added this into
packages/cloudflare, but all AI integrations do live in core, and there are also some utils which are only there and would have needed to export, such asendStreamSpanand all the gen-ai-attributes. The downside of this is that the workers-ai types needed to be vendored in (in thepackages/cloudflarewe could have taken them from the@cloudflare/workers-typespackage.