fix(cloudflare): Filter CREATE INDEX spans on cf_-prefixed tables - #22650
Merged
JPeer264 merged 2 commits intoJul 27, 2026
Conversation
`getSqlQuerySummary` follows the upstream OTel convention of summarizing `CREATE INDEX idx ON t (...)` as `CREATE INDEX idx` — the indexed table never appears in the summary, so `targetsCloudflareInternalTable` could not see that framework statements like `create index idx_stream_chunks_stream_id on cf_ai_chat_stream_chunks(...)` target internal tables. They leaked through as unfiltered `db.query` spans on every Durable Object boot. The filter now also receives the sanitized query text and, for `CREATE [UNIQUE] INDEX` statements, checks the ON-clause target against the `cf_` prefix and the `durableObjectSqlSpanAllowlist` option. The summary itself (and therefore span names) stays OTel-conformant. The tests were switched to run the same sanitize -> summarize -> filter pipeline as the instrumentation. Co-Authored-By: Claude <noreply@anthropic.com>
JPeer264
requested review from
andreiborza and
isaacs
and removed request for
a team
July 27, 2026 07:13
Contributor
size-limit report 📦
|
andreiborza
reviewed
Jul 27, 2026
Comment on lines
+5
to
+10
| // Runs the same sanitize -> summarize -> filter pipeline as `instrumentSqlStorage`, so the tests | ||
| // exercise the real detection path rather than hand-written summaries. | ||
| const check = (query: string, allowlist?: Array<string | RegExp>): boolean => { | ||
| const sanitized = _INTERNAL_sanitizeSqlQuery(query); | ||
| return targetsCloudflareInternalTable(_INTERNAL_getSqlQuerySummary(sanitized), allowlist, sanitized); | ||
| }; |
Member
There was a problem hiding this comment.
l: Not a fan of this, if implementation changes and we add extra steps to the actual code path we won't catch regressions heree.
Is there no way reproduce the actual path without having to code one up separately here?
Member
Author
There was a problem hiding this comment.
yeah you're right. I actually also moved the majority of the calls to instrumentSqlStorage where it made most sense
andreiborza
approved these changes
Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the
agentSDK there were still couple of SQL statements injected as spans which didn't give any value. With that PR they are now filtered out (like this one)getSqlQuerySummaryfollows the upstream OTel convention of summarizingCREATE INDEX idx ON t (...)asCREATE INDEX idx- the indexed table never appears in the summary, sotargetsCloudflareInternalTablecould not see that framework statements likecreate index idx_stream_chunks_stream_id on cf_ai_chat_stream_chunks(...)target internal tables. They leaked through as unfiltereddb.queryspans on every Durable Object boot.The filter now also receives the sanitized query text and, for
CREATE [UNIQUE] INDEXstatements, checks the ON-clause target against thecf_prefix and thedurableObjectSqlSpanAllowlistoption. The summary itself (and therefore span names) stays OTel-conformant. The tests were switched to run the same sanitize -> summarize -> filter pipeline as the instrumentation.