Answer: Import `metrics`, `trace` from `@opentelemetry/api` and `logs` from `@opentelemetry/api-logs`, then create a tracer, meter counter, and logger; to tag a whole turn, call `ctx.telemetry` from a tool with `setTraceAttributes`, `setMetricAttributes`, and `setLogAttributes`. Status: Confirmed Entry: tool/cursor/integrations/record-custom-telemetry Revision: 1 Digest: sha256:350968c3bca6c86b (changes whenever the content changes) Timeline: Created: 2026-11-13T12:21:56Z Last changed: 2026-11-13T12:21:56Z Last verified: 2026-11-20T12:33:11Z Next check: 2026-11-21T12:33:11Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Unit | Source | As of import source | @opentelemetry/api | | [1] | 2026-11-20 logs import source | @opentelemetry/api-logs | | [1] | 2026-11-20 conversation id helper | currentConversationId | | [1] | 2026-11-20 tag whole turn | ctx.telemetry | | [1] | 2026-11-20 outside tool telemetry import | @grok/agent-sdk/telemetry | | [1] | 2026-11-20 max keys per kind | 32 | keys | [1] | 2026-11-20 max key length | 128 | characters | [1] | 2026-11-20 max value length | 256 | characters | [1] | 2026-11-20 Sources: [1] Anysphere. "cursor.com/docs/agent-sdk/guides/opentelemetry.md". https://cursor.com/docs/agent-sdk/guides/opentelemetry.md Role: primary. Accessed: 2026-11-20T12:33:11Z Quote: "import { metrics, trace } from "@opentelemetry/api";" (Supports: import source) Quote: "import { logs } from "@opentelemetry/api-logs";" (Supports: logs import source) Quote: "import { currentConversationId } from "@grok/agent-sdk/otel";" (Supports: conversation id helper) Quote: "To tag a whole turn, call `ctx.telemetry` from a tool." (Supports: tag whole turn) Quote: "Outside a tool, use `telemetry` from `@grok/agent-sdk/telemetry`." (Supports: outside tool telemetry import) Quote: "A session holds up to 32 keys of each kind, with keys up to 128" (Supports: max keys per kind) Quote: "with keys up to 128 characters and values up to 256." (Supports: max key length) Quote: "characters and values up to 256." (Supports: max value length) Snapshot SHA-256: 1e7da9d4f116cf6156761fd4b7677b72e91a74b20c35d8a02d40f351147f667d (captured 2026-11-13T03:08:37Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. On this check the text of [1] was unchanged since 2026-11-13T12:21:56Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T12:33:11Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:33:11Z Last attempt: 2026-11-20T12:33:11Z Notes and limitations: Extracted automatically from a single official source (section "Record and tag"). Related: https://latestn.com/tool/cursor/integrations/security-review-source-control-support Which source control providers does Cursor Security Review support? https://latestn.com/tool/cursor/integrations/self-hosted-integration-requirements What does every Cursor self-hosted integration require? https://latestn.com/tool/cursor/integrations/self-hosted-partner-guides Which infrastructure partners have guides for running Cursor self-hosted workers? https://latestn.com/tool/cursor/integrations/prebuilt-channels What prebuilt channels does Cursor's Agent SDK provide? https://latestn.com/tool/cursor/integrations/publish-origin-app-to-marketplace How do I make my Cursor Origin app public and submit it to the App Marketplace? https://latestn.com/tool/cursor/integrations/reconnect-mcp-connections How do I reconnect account-backed MCP server actions after converting a Cursor Automation? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-13T12:21:56Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/cursor/integrations/record-custom-telemetry/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/cursor/integrations/record-custom-telemetry POST: https://latestn.com/dispute/tool/cursor/integrations/record-custom-telemetry with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/cursor/integrations/record-custom-telemetry?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I record custom traces, metrics, or logs in Cursor Agent SDK using @opentelemetry/api? Revision 1, last verified 2026-11-20T12:33:11Z. https://latestn.com/tool/cursor/integrations/record-custom-telemetry (accessed 2026-11-21T09:53:58Z). @misc{LatestN_tool_cursor_integrations_record_custom_telemetry_r1, title = {How do I record custom traces, metrics, or logs in Cursor Agent SDK using @opentelemetry/api?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/cursor/integrations/record-custom-telemetry}}, note = {Revision 1; digest sha256:350968c3bca6c86b; last verified 2026-11-20T12:33:11Z; accessed 2026-11-21T09:53:58Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/cursor/integrations/record-custom-telemetry