Skip to main content

Respan Cursor SDK instrumentation

Trace Cursor hook events through the Respan OpenTelemetry runtime.

Cursor sends structured JSON to configured hook commands. This package converts those hook events into canonical Respan spans and injects them into the active respan-tracing pipeline.

Install

pip install respan-ai respan-instrumentation-cursor-sdk

Cursor hook command

Set Respan configuration in the environment used by Cursor:

export RESPAN_API_KEY="..."
export RESPAN_BASE_URL="https://api.respan.ai/api"

Then configure Cursor hooks to call the packaged runner:

{
  "version": 1,
  "hooks": {
    "beforeSubmitPrompt": [{ "command": "respan-cursor-hook" }],
    "afterAgentThought": [{ "command": "respan-cursor-hook" }],
    "afterShellExecution": [{ "command": "respan-cursor-hook" }],
    "afterFileEdit": [{ "command": "respan-cursor-hook" }],
    "afterMCPExecution": [{ "command": "respan-cursor-hook" }],
    "afterAgentResponse": [{ "command": "respan-cursor-hook" }],
    "stop": [{ "command": "respan-cursor-hook" }]
  }
}

The runner reads one Cursor hook JSON payload from stdin, stores prompt state between hook calls, emits child spans as they happen, and emits the root agent span when afterAgentResponse arrives.

Programmatic usage

from respan import Respan
from respan_instrumentation_cursor_sdk import CursorSDKInstrumentor

respan = Respan(
    instrumentations=[CursorSDKInstrumentor()],
    app_name="cursor-sdk",
)

processor = CursorSDKInstrumentor.create_processor()
processor.process_event(
    {
        "hook_event_name": "afterAgentThought",
        "conversation_id": "conv_123",
        "generation_id": "gen_456",
        "text": "I need to inspect the repository.",
        "duration_ms": 320,
    }
)
respan.telemetry.flush()

Supported Cursor events

  • beforeSubmitPrompt
  • afterAgentThought
  • afterShellExecution
  • afterFileEdit
  • afterMCPExecution
  • afterAgentResponse
  • stop

Cursor-specific raw field names stay inside this package. The emitted spans use canonical Respan attributes for log type, entity input/output, workflow name, thread identifier, trace group, and metadata.

Metadata

Release files for respan-instrumentation-cursor-sdk 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for respan-instrumentation-cursor-sdk 0.1.1
File Size Uploaded
respan_instrumentation_cursor_sdk-0.1.1.tar.gz 7.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for respan-instrumentation-cursor-sdk 0.1.1
File Interpreter ABI Platform
respan_instrumentation_cursor_sdk-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 17.6 kB

Release files / respan_instrumentation_cursor_sdk-0.1.1.tar.gz

Download URL respan_instrumentation_cursor_sdk-0.1.1.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5736335a260790dead560dc4616f9b4420cba055771d4567be447c717573b6a7
BLAKE2b-256 checksum
How to use checksums
ca3e33a16035111761acbe7d6317c701f8e66b28a4fd43c531bb75d0938cda2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / respan_instrumentation_cursor_sdk-0.1.1-py3-none-any.whl

Download URL respan_instrumentation_cursor_sdk-0.1.1-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d66bfe1c322f22cc6f4326cbc80188b47d3ae5e6da302cd7dfde9d5661e5fede
BLAKE2b-256 checksum
How to use checksums
49b6c8811a66c9daa10696d9ec58ae7ba6768d68ab4c61688a8fde8351b00157
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page