Skip to content

Drop the stringified data point from Analytics Engine query text - #241

Open
ayaangazali wants to merge 1 commit into
pydantic:mainfrom
ayaangazali:ae-query-text-object
Open

Drop the stringified data point from Analytics Engine query text#241
ayaangazali wants to merge 1 commit into
pydantic:mainfrom
ayaangazali:ae-query-text-object

Conversation

@ayaangazali

Copy link
Copy Markdown
Contributor

Defect

Every Analytics Engine span carries db.query.text: "writeDataPoint [object Object]". writeDataPoint is the only method on AnalyticsEngineDataset, so this is on 100% of AE spans, not an edge case.

Evidence

instrumentAEFn built the query text by interpolating the first argument:

span.setAttribute(ATTR_DB_QUERY_TEXT, `${operation} ${argArray[0]}`)

For KV and Durable Object storage that argument is a key string, so the same line reads sensibly there. For Analytics Engine it is an AnalyticsEngineDataPoint object, and a template literal stringifies it to [object Object].

Verified on current main with the file's existing InMemorySpanExporter harness. writeDataPoint({ blobs: ['b'], doubles: [1], indexes: ['idx'] }) produced exactly writeDataPoint [object Object].

Fix

Remove the attribute rather than reformat it. A data point write has no query text to report, db.operation.name already carries writeDataPoint, and the data point's contents are already summarised by db.cf.ae.indexes, db.cf.ae.index, db.cf.ae.doubles and db.cf.ae.blobs. Setting db.query.text to the bare operation name would only duplicate db.operation.name.

The new test asserts the span's complete attribute set, so it fails if the placeholder returns and also if an unexpected attribute appears. Restoring the old line fails it with + "db.query.text": "writeDataPoint [object Object]".

If you would rather AE spans keep a db.query.text for consistency with KV and DO storage, say so and I will set it to the operation name instead.

Built this with Claude Code's help and reviewed the diff myself.

Copilot AI lite review requested due to automatic review settings August 17, 2026 18:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ayaangazali

Copy link
Copy Markdown
Contributor Author

Still reproduces on 118b480: analytics-engine.ts:47 writes db.query.text as ${operation} ${argArray[0]}, and the argument is a data point object, so every Analytics Engine span carries the literal string writeDataPoint [object Object]. Green and conflict free since it was opened.

This is the smallest of the Cloudflare PRs I have open and it deletes a line rather than adding behaviour, so it is easy to say no to. Happy to close it if you would rather keep the attribute present, even with that value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants