Skip to content

Instrument Cloudflare Clairic as gen_ai.extract spans #25615

Closed

Description

@andreiborza

The Extraction span spec adds gen_ai.extract spans. The JS SDK does not emit them.

Current behavior

getOperationName in packages/server-utils/src/ai/workers-ai/utils.ts sends only typesafe/jev and @cf/cloudflare/clef to decide. A Clairic call ({state, fields}, no messages / prompt / text) falls through to chat. The result is a chat @cf/cloudflare/clairic span with no input or output messages.

To do

  • Bump @sentry/conventions when it has GEN_AI_EXTRACT (it is not in the package yet).
  • Send @cf/cloudflare/clairic to an extract operation: op gen_ai.extract, name extract {model}, gen_ai.operation.name: "extract".
  • gen_ai.input.messages: the request body as the caller passed it, without model. Replace each image with "[Blob substitute]".
  • gen_ai.output.messages: the response body as the provider returned it, without model and usage. Keep truncated.
  • Set gen_ai.usage.input_tokens / output_tokens. Do not send the other Clairic usage counts (state_tokens, image_tokens, schema_tokens, passes).
  • Add an integration test, and add an extract call to the Workers AI e2e app.

Activity

  1. linear-code commented on Oct 21, 2026

    @linear-code
  2. self-assigned this
    on Oct 21, 2026
  3. github-actions commented on Oct 28, 2026

    @github-actions
    Contributor

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #25625, which was included in the 11.10.0 release.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions