Metadata-Version: 2.4
Name: langchain-instrumentation
Version: 0.1.0
Summary: OpenTelemetry instrumentation for LangChain and LangGraph spans and metrics.
Author: Onlykh
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/Onlykh/openTelemetry-instrumentation-langchain
Project-URL: Repository, https://github.com/Onlykh/openTelemetry-instrumentation-langchain
Project-URL: Issues, https://github.com/Onlykh/openTelemetry-instrumentation-langchain/issues
Keywords: opentelemetry,langchain,langgraph,observability,tracing,genai
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: System :: Monitoring
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: opentelemetry-api>=1.20.0
Requires-Dist: opentelemetry-sdk>=1.20.0
Requires-Dist: opentelemetry-instrumentation>=0.43b0
Requires-Dist: opentelemetry-semantic-conventions>=0.43b0
Requires-Dist: wrapt>=1.14.0
Requires-Dist: langchain-core>=0.2.0
Provides-Extra: langgraph
Requires-Dist: langgraph>=0.2.0; extra == "langgraph"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: build>=1.2.2; extra == "dev"
Requires-Dist: twine>=5.1.1; extra == "dev"
Dynamic: license-file

# langchain-instrumentation

OpenTelemetry instrumentation SDK for LangChain and LangGraph.

## Install

```bash
pip install langchain-instrumentation
```

## Quickstart

```python
from langchain_instrumentation import LangChainConfig, LangChainInstrumentor

instrumentor = LangChainInstrumentor(LangChainConfig())
instrumentor.instrument()

# Optional manual handler injection in custom callback manager flows
handler = instrumentor.handler

# Shutdown or test cleanup
instrumentor.uninstrument()
```

## What it instruments

- LangChain callback lifecycle spans
- Optional LangGraph tracing hooks
- Optional agent factory tracing hooks
- Metrics and structured log emission

## Configuration

`LangChainConfig` controls behavior. Most-used flags:

- `emit_metrics`, `emit_logs`
- `patch_callback_manager`, `patch_langgraph`, `patch_langchain_factories`
- `record_content`, `record_raw_payloads`, `redact_keys`
