Metadata-Version: 2.5
Name: opentelemetry-instrumentation-kedi
Version: 0.1.1
Summary: OpenTelemetry instrumentation for the Kedi programming language
Project-URL: Homepage, https://github.com/kedi-lang/kedi-otel
Project-URL: Repository, https://github.com/kedi-lang/kedi-otel
Project-URL: Issues, https://github.com/kedi-lang/kedi-otel/issues
Author: Mert Sırakaya, Doğukan Yiğit Polat
Author-email: mert@kedi-lang.org, yigit@neurograph.net
License: MIT
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: kedi<0.2,>=0.1.1
Requires-Dist: opentelemetry-api<1.46,>=1.45.2
Requires-Dist: opentelemetry-instrumentation<0.67,>=0.66b2
Requires-Dist: pydantic-ai-slim<2.67,>=2.66.0
Provides-Extra: httpx
Requires-Dist: opentelemetry-instrumentation-httpx<0.67,>=0.66b2; extra == 'httpx'
Provides-Extra: test
Requires-Dist: opentelemetry-sdk<1.46,>=1.45.2; extra == 'test'
Requires-Dist: pytest-cov==7.1.0; extra == 'test'
Requires-Dist: pytest==9.2.0; extra == 'test'
Description-Content-Type: text/markdown

# Kedi OpenTelemetry Instrumentation

`opentelemetry-instrumentation-kedi` connects Kedi's dependency-free telemetry seam to
OpenTelemetry. Importing Kedi remains a no-op; telemetry starts only after the
instrumentor is enabled.

## Installation

From a Kedi source checkout with its submodules initialized:

```sh
uv sync --project kedi-otel --locked
```

This installs the checked-out Kedi runtime and instrumentor into
`kedi-otel/.venv`. Run the application in that environment. Add `--extra httpx`
when using HTTPX instrumentation. To install into an existing compatible
environment instead, use `python -m pip install -e ./kedi-otel` from the Kedi
repository root. Kedi `>=0.1.1,<0.2` must already be available in that environment
or from the package index.

## Usage

```python
from opentelemetry.instrumentation.kedi import KediInstrumentor

KediInstrumentor().instrument()
```

Configure the application's tracer and meter providers with
`service.name=kedi`. Kedi does not replace the application's SDK, sampler,
resource, exporter, or Logfire configuration.

## Configuration

All boolean options require actual `bool` values. Unknown option names and invalid
types raise immediately instead of silently weakening telemetry policy.

```python
KediInstrumentor().instrument(
    runtime_detail="lifecycle",  # "off", "lifecycle", or "detailed"
    agent_enabled=True,
    artifacts_enabled=True,
    capture_content=False,
    capture_binary_content=False,
    capture_source_paths=False,
    capture_source_snippets=False,
    capture_model_request_parameters=False,
    capture_tool_definitions=False,
    capture_exception_messages=False,
    capture_exception_stacktraces=False,
    max_metric_instruments=128,
    instrument_pydantic_ai=True,
    instrument_httpx=False,
    tracer_provider=tracer_provider,
    meter_provider=meter_provider,
)
```

`agent_enabled` controls the complete agent surface, including model and tool
calls, MCP initialization, approvals, subagents, dynamic workflows, and
CodeMode discovery and execution. CodeMode emits payload-free `search tools`,
`get tool schema`, and `execute code` spans in the `kedi.agent` instrumentation
scope, plus `kedi.codemode.operations` and `kedi.codemode.duration` metrics.

Content, binary content, source paths, source snippets, model request parameters,
tool definitions, exception messages, and exception stack traces are separate
privacy classes. All are disabled by default. Exception type remains observable;
message and stack data require their respective explicit opt-ins and are bounded.

Pydantic AI instrumentation is enabled by default. Kedi filters model request
parameters and tool definitions before they reach the configured tracer provider
unless their dedicated capture options are enabled. Pydantic's process-wide
instrumentation setting is restored only while Kedi still owns the exact setting;
a newer application owner is never overwritten.

HTTPX instrumentation requires the `httpx` extra and explicit
`instrument_httpx=True`. Enabling it is a one-way, application-owned setup action.
Kedi deliberately does not call global HTTPX `uninstrument()` because the upstream
instrumentor exposes no owner token and teardown could remove another library's
instrumentation.

## Lifecycle

Instrumentation transitions are serialized and idempotent. Teardown attempts every
owned cleanup step even when one fails, restores the Kedi backend with an
owner-aware compare-and-restore operation, and raises
`KediInstrumentationCleanupError` with all cleanup causes. If setup itself fails,
the setup exception remains primary and any rollback failure is chained beneath it.
