Skip to main content

raindrop-azure-openai

Raindrop observability integration for Azure OpenAI (Python). Automatically captures chat.completions.create() calls by wrapping AzureOpenAI and AsyncAzureOpenAI clients.

Installation

pip install raindrop-azure-openai openai

Quick Start

from raindrop_azure_openai import RaindropAzureOpenAI
from openai import AzureOpenAI

raindrop = RaindropAzureOpenAI(
    api_key="rk_...",
    user_id="user-123",
    debug=False,  # set True for verbose logging
)

client = AzureOpenAI(
    azure_endpoint="https://your-resource.openai.azure.com",
    api_key="...",
    api_version="2024-10-21",
)
wrapped = raindrop.wrap(client)

response = wrapped.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello!"}],
)

raindrop.shutdown()

Projects

Route events to a specific project by passing its slug as project_id:

raindrop = RaindropAzureOpenAI(
    api_key="rk_...",
    project_id="support-prod",
)

project_id sets the X-Raindrop-Project-Id header on every event. Omit it (or pass "default") to use your org's default Production project, which is the existing behavior. The same option is accepted by the create_raindrop_azure_openai(...) factory. Invalid slugs are ignored with a warning and no header is sent.

Debug Mode

raindrop = RaindropAzureOpenAI(api_key="rk_...", debug=True)

When debug=True, verbose logs are emitted to the raindrop_azure_openai logger at DEBUG level.

Async Support

from raindrop_azure_openai import RaindropAzureOpenAI
from openai import AsyncAzureOpenAI

raindrop = RaindropAzureOpenAI(api_key="rk_...", user_id="user-123")

client = AsyncAzureOpenAI(
    azure_endpoint="https://your-resource.openai.azure.com",
    api_key="...",
    api_version="2024-10-21",
)
wrapped = raindrop.wrap(client)

response = await wrapped.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello!"}],
)

raindrop.shutdown()

User Identification

raindrop.identify("user-123", traits={"plan": "pro", "name": "Alice"})

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

Factory Function (Backwards-Compatible)

from raindrop_azure_openai import create_raindrop_azure_openai

raindrop = create_raindrop_azure_openai(api_key="rk_...", user_id="user-123")
# raindrop is now a RaindropAzureOpenAI instance with .wrap(), .flush(), .shutdown()

What Gets Captured

  • Chat completions — input messages, output text, model, token usage
  • Finish reasonazure_openai.finish_reason (stop, length, content_filter, tool_calls)
  • Extended tokensai.usage.cached_tokens (prompt cache hits) and ai.usage.thoughts_tokens (reasoning tokens for o1/o3 models)
  • Errors — error type and message captured as properties, then re-raised to the caller
  • Async support — both sync (AzureOpenAI) and async (AsyncAzureOpenAI) clients are instrumented

Configuration

Option Type Default Description
api_key str | None None Raindrop API key. None disables telemetry shipping
user_id str | None None Associate all events with a user (falls back to "unknown")
convo_id str | None None Group events into a conversation
project_id str | None None Route events to a specific project (slug); omit for the default Production project
tracing_enabled bool True Enable OTEL-based tracing
bypass_otel_for_tools bool True Bypass OTEL for tool calls
disable_auto_instrument bool True Library auto-instrumentation is opt-in (see below)
debug bool False Enable verbose debug logging

Library auto-instrumentation is opt-in

As of 0.0.4, disable_auto_instrument defaults to True: the integration no longer lets Traceloop monkey-patch every LLM client library it recognizes in your process (the OpenAI client itself, Anthropic, botocore, etc.). The wrapper captures input/output, token usage, model name, and finish_reason directly from the wrapped client's responses, so no library patching is needed for full dashboards.

If you specifically want LLM-call-level spans from library instrumentation and have verified compatibility in your environment, opt back in with disable_auto_instrument=False.

Double-Wrap Protection

Calling wrap() on an already-instrumented client is a safe no-op — the client is returned unchanged.

Full Documentation

See the Raindrop docs for the complete reference.

Testing

cd packages/azure-openai-python
pip install -e ".[dev]"
python -m pytest tests/ -v

License

MIT

Release files for raindrop-azure-openai 0.0.9

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

Source distribution (sdist)

Source distribution for raindrop-azure-openai 0.0.9
File Size Uploaded
raindrop_azure_openai-0.0.9.tar.gz 27.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for raindrop-azure-openai 0.0.9
File Interpreter ABI Platform
raindrop_azure_openai-0.0.9-py3-none-any.whl Python 3 none any Details

Total release size: 38.9 kB

Release files / raindrop_azure_openai-0.0.9.tar.gz

Download URL raindrop_azure_openai-0.0.9.tar.gz
Size 27.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d58f776e3b2719788b68945eb57da017709db9b078caf83e3f96b317c810cf76
BLAKE2b-256 checksum
How to use checksums
76a2b707ad861f28ea449fc9f92be9ecb2e8a21c88cd83dfc39ae2079fdfe036
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / raindrop_azure_openai-0.0.9-py3-none-any.whl

Download URL raindrop_azure_openai-0.0.9-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
393bab2235984e99d095fc0f0bdd98265a004dda033f3d22bddb3f7ff6a94208
BLAKE2b-256 checksum
How to use checksums
a0fb6d0c992f6796ce000f3f4944f14414dd43dca539de88d009b39eb4f6d000
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

0.0.11

2 release files

0.0.10

2 release files

This release

0.0.9 This release

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

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