Raindrop observability integration for DSPy
Project description
raindrop-dspy
Raindrop observability integration for DSPy. Wraps DSPy modules (Predict, ChainOfThought, etc.) to automatically capture input fields, output fields, model name, and token usage.
Installation
pip install raindrop-dspy dspy
Quick Start
import dspy
from raindrop_dspy import RaindropDSPy
raindrop = RaindropDSPy(api_key="rk_...", user_id="user-123")
lm = dspy.LM("openai/gpt-4o-mini")
dspy.configure(lm=lm)
predict = dspy.Predict("question -> answer")
wrapped = raindrop.wrap(predict)
result = wrapped(question="What is the capital of France?")
print(result.answer)
raindrop.shutdown()
Debug Mode
Enable verbose logging to troubleshoot issues:
raindrop = RaindropDSPy(api_key="rk_...", debug=True)
Factory Function (Legacy)
The create_raindrop_dspy factory function is still available for backwards compatibility:
from raindrop_dspy import create_raindrop_dspy
raindrop = create_raindrop_dspy(
api_key="rk_...",
user_id="user-123",
tracing_enabled=True,
bypass_otel_for_tools=True,
)
wrapped = raindrop.wrap(predict)
What Gets Captured
| Data | Description |
|---|---|
| Input fields | All keyword arguments passed to forward() |
| Output fields | Extracted from the DSPy Prediction result |
| Model name | From the active dspy.settings.lm configuration |
| Token usage | Prompt and completion tokens (when available) |
| Errors | Exception type and message captured in event properties |
| Finish reason | Completion finish reason (e.g. stop, length) from the LM history |
API Reference
RaindropDSPy(api_key=None, user_id=None, convo_id=None, tracing_enabled=True, bypass_otel_for_tools=True, debug=False)
Create a new Raindrop DSPy integration instance.
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key |
str | None |
None |
Raindrop API key. If omitted, telemetry is disabled. |
user_id |
str | None |
None |
Associate all events with a user |
convo_id |
str | None |
None |
Group events into a conversation |
tracing_enabled |
bool |
True |
Enable OpenTelemetry tracing |
bypass_otel_for_tools |
bool |
True |
Bypass OTEL instrumentation for tool calls |
debug |
bool |
False |
Enable debug logging (sets logger to DEBUG level) |
Methods
| Method | Description |
|---|---|
wrap(module) |
Instrument a DSPy module (sync and async forward supported) |
flush() |
Flush buffered events to Raindrop |
shutdown() |
Flush and shut down the client |
identify(user_id, traits=None) |
Identify a user with optional traits |
track_signal(event_id, name, signal_type="default", ...) |
Track a signal on an AI event (e.g. thumbs up/down, feedback) |
Identifying Users
raindrop.identify("user-123", traits={"name": "Alice", "plan": "pro"})
Tracking Signals
raindrop.track_signal(
event_id="evt-abc",
name="thumbs_up",
signal_type="feedback",
sentiment="POSITIVE",
comment="Great response!",
)
Flushing and Shutdown
raindrop.flush() # flush pending data
raindrop.shutdown() # flush + release resources
Async Support
DSPy modules with async forward methods are automatically detected and wrapped:
import dspy
from raindrop_dspy import RaindropDSPy
raindrop = RaindropDSPy(api_key="rk_...")
class AsyncPredict(dspy.Module):
async def forward(self, question: str) -> dspy.Prediction:
...
wrapped = raindrop.wrap(AsyncPredict())
result = await wrapped(question="Hello")
Double-Wrap Protection
Calling wrap() on an already-wrapped module is a no-op — the module is returned unchanged.
Development
cd packages/dspy-python
pip install -e ".[dev]"
python -m pytest tests/ -v
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file raindrop_dspy-0.0.3.tar.gz.
File metadata
- Download URL: raindrop_dspy-0.0.3.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dde5d459cfd0acea297bbd25da31e5a311f51eb171805d5a3670ac0319ff0635
|
|
| MD5 |
0883e79348e1304d8f6364d11ab1832a
|
|
| BLAKE2b-256 |
d76d097cfda428d0083e0f7de0616fd9a0dcfb8dfe1f65bb942d7c64115e9690
|
File details
Details for the file raindrop_dspy-0.0.3-py3-none-any.whl.
File metadata
- Download URL: raindrop_dspy-0.0.3-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85c11b02ea1c4cc0d9a9b4e9a34fa9881b857e26f59c6010896647bbc6231bb1
|
|
| MD5 |
ba61ddbf471c394c856c98fed563c556
|
|
| BLAKE2b-256 |
79d718ecfb6d2933a31803ccaf6906e073ba7761129eff59c71e2b8f4e1903de
|