Skip to main content

Dakora Instrumentation

OTLP backend for LLM observability

PyPI version Python 3.11+ License

Dakora accepts OpenTelemetry traces via OTLP/HTTP. This package provides:

  1. Generic helper - Thin wrapper to configure OTEL exporters pointing to Dakora
  2. Framework integrations - Batteries-included support for Microsoft Agent Framework (MAF)
    • LangChain, CrewAI, and more coming soon

Features

✅ OTLP Backend - Point your existing OTEL setup at Dakora
✅ Multi-Export - Send traces to Dakora + Jaeger/Grafana/Azure Monitor
✅ BYO OpenTelemetry - Use your own OTEL versions, no dependency conflicts
✅ Framework Integrations - Batteries-included MAF support
✅ Template Linkage - Track Dakora prompts used in executions
✅ Budget Enforcement - Pre-execution checks with caching (MAF integration)


Architecture

Your App → OTEL SDK → Instrumentation → OTLP Exporter → Dakora API
                                                    ↓
                                            /api/v1/traces
                                         (with X-API-Key header)

Quick Start

1. With OpenTelemetry Collector (Recommended)

Already running a collector? Just add Dakora as an exporter:

# otel-collector-config.yaml
exporters:
  otlphttp/dakora:
    endpoint: ${DAKORA_BASE_URL}/api/v1/traces
    headers:
      X-API-Key: ${DAKORA_API_KEY}

service:
  pipelines:
    traces:
      exporters: [otlphttp/dakora, jaeger, ...] # Multi-export!

2. Direct Integration (Python)

Step 1: Install OpenTelemetry + Instrumentations

# Core OTEL
pip install opentelemetry-sdk opentelemetry-exporter-otlp-proto-http

# Provider instrumentations (choose what you need)
pip install opentelemetry-instrumentation-openai
pip install opentelemetry-instrumentation-anthropic

# Dakora helper (optional convenience)
pip install dakora-instrumentation

Step 2: Instrument Your Providers

# Do this once at application startup
from opentelemetry.instrumentation.openai import OpenAIInstrumentor
from opentelemetry.instrumentation.anthropic import AnthropicInstrumentor

OpenAIInstrumentor().instrument()
AnthropicInstrumentor().instrument()

Step 3: Configure Dakora Exporter

from dakora import Dakora
from dakora_instrumentation import setup_instrumentation

dakora = Dakora(api_key="dk_proj_...")
setup_instrumentation(dakora, service_name="my-app")

# That's it! All instrumented SDKs now export to Dakora

2. With Microsoft Agent Framework (Batteries Included)

pip install 'dakora-instrumentation[maf]'
from dakora import Dakora
from dakora_instrumentation.frameworks.maf import DakoraIntegration
from agent_framework.azure import AzureOpenAIChatClient

# Initialize Dakora
dakora = Dakora(api_key="dk_proj_...")

# One-line OTEL setup
middleware = DakoraIntegration.setup(dakora)

# Use with any MAF client
azure_client = AzureOpenAIChatClient(
    endpoint=...,
    deployment_name=...,
    api_key=...,
    middleware=[middleware],
)

agent = azure_client.create_agent(
    id="chat-v1",
    name="ChatBot",
    instructions="You are helpful.",
)

response = await agent.run("Hello!")

Package Structure

dakora_instrumentation/
├── frameworks/maf/          # Microsoft Agent Framework integration
├── generic.py               # Generic OTEL setup helper
└── _internal/               # Internal utilities (private)

Public API:

from dakora_instrumentation import setup_instrumentation
from dakora_instrumentation.frameworks.maf import DakoraIntegration

Examples

See examples/ directory for progressive examples:

  • 01_quickstart/ - Start here: basic setup and template usage
  • 02_providers/ - BYO OTEL patterns (OpenAI, Anthropic, multi-provider)
  • 03_maf_agents/ - MAF agent patterns (simple, tools, templates)
  • 04_maf_multi_agent/ - Multi-agent orchestration (sequential, parallel, workflows)
  • 05_advanced/ - Production patterns (dual export, budget checking, custom attributes)

FAQ

Q: Do I need to install dakora-instrumentation?

No! If you already have OTEL configured, point your exporter at Dakora's OTLP endpoint: ${DAKORA_BASE_URL}/api/v1/traces with X-API-Key header. This package provides convenience helpers.

Q: How do I install provider instrumentations?

Install them directly from the opentelemetry-instrumentation packages:

pip install opentelemetry-instrumentation-openai
pip install opentelemetry-instrumentation-anthropic

Q: When should I use which integration?

  • Generic setup_instrumentation() - For direct SDK calls (OpenAI, Anthropic, etc.)
  • MAF Integration - For Microsoft Agent Framework agents (batteries included)

Q: Do I need to instrument providers manually?

Yes, OpenTelemetry instrumentation is global:

OpenAIInstrumentor().instrument()  # Do once at startup

Q: Can I send traces to multiple backends?

Yes! Use additional_exporters parameter:

from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter

jaeger_exporter = OTLPSpanExporter(endpoint="http://localhost:4317")
setup_instrumentation(dakora, additional_span_exporters=[jaeger_exporter])

Q: Does this work with LangChain/CrewAI?

Not yet, but support is coming! Use generic setup_instrumentation() for now.


Links


License

Apache License 2.0

Release files for dakora-instrumentation 0.2.0

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

Source distribution (sdist)

Source distribution for dakora-instrumentation 0.2.0
File Size Uploaded
dakora_instrumentation-0.2.0.tar.gz 59.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dakora-instrumentation 0.2.0
File Interpreter ABI Platform
dakora_instrumentation-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 91.7 kB

Release files / dakora_instrumentation-0.2.0.tar.gz

Download URL dakora_instrumentation-0.2.0.tar.gz
Size 59.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4c5893f90caf52c92733d5d7f3ea46f90ead88e5941a0e646c4a7eb96818a9a2
BLAKE2b-256 checksum
How to use checksums
8a20bdd7ddbf55ba8ca11f6b35dbeb768beacf530376ebd90343684783ab09e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.4

Release files / dakora_instrumentation-0.2.0-py3-none-any.whl

Download URL dakora_instrumentation-0.2.0-py3-none-any.whl
Size 31.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
89915dab9c513212ddb2c2635704e33ad0cbff06b0d5360e48ca04e42fb897a7
BLAKE2b-256 checksum
How to use checksums
d12bef5a4f604da64c6747ff13bd7620302a8427441e639b3c85cb39beebdc9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.4

Release history Release notifications | RSS feed

This release

0.2.0 This release

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