Metadata-Version: 2.4
Name: loongsuite-instrumentation-autogen
Version: 0.7.0
Summary: LoongSuite Microsoft AutoGen instrumentation
Project-URL: Homepage, https://github.com/alibaba/loongsuite-python/tree/main/instrumentation-loongsuite/loongsuite-instrumentation-autogen
Project-URL: Repository, https://github.com/alibaba/loongsuite-python
Author: LoongSuite Python Agent Authors
Author-email: OpenTelemetry Authors <cncf-opentelemetry-contributors@lists.cncf.io>
License-Expression: Apache-2.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Requires-Dist: loongsuite-otel-util-genai~=0.7.0
Requires-Dist: opentelemetry-api~=1.37
Requires-Dist: opentelemetry-instrumentation>=0.58b0
Requires-Dist: opentelemetry-semantic-conventions>=0.58b0
Requires-Dist: wrapt<2.0.0,>=1.14
Provides-Extra: instruments
Requires-Dist: autogen-agentchat<0.8.0,>=0.7.0; extra == 'instruments'
Provides-Extra: test
Requires-Dist: pytest-cov~=4.1.0; extra == 'test'
Requires-Dist: pytest~=8.0; extra == 'test'
Description-Content-Type: text/markdown

# LoongSuite Microsoft AutoGen Instrumentation

This package instruments Microsoft AutoGen 0.7.x AgentChat flows.

It follows the AutoGen 0.7 native telemetry boundary:

- AutoGen core already emits native GenAI-style spans for `invoke_agent`,
  `create_agent`, and `execute_tool`.
- This instrumentation registers a span processor that converts those native
  spans to LoongSuite GenAI attributes by setting `gen_ai.span.kind`, replacing
  `gen_ai.system=autogen` with `gen_ai.provider.name=autogen`, and normalizing
  span kinds.
- AgentChat `AssistantAgent.on_messages_stream` is wrapped with
  `ExtendedTelemetryHandler.invoke_agent()` when no native AutoGen agent span is
  already active.
- AgentChat `AssistantAgent._call_llm` is wrapped with
  `ExtendedTelemetryHandler.llm()` so model calls produce LoongSuite LLM spans
  for any AutoGen `ChatCompletionClient`.

## Usage

```python
from opentelemetry.instrumentation.autogen import AutoGenInstrumentor

AutoGenInstrumentor().instrument()
```

Environment switches:

- `ARMS_AUTOGEN_INSTRUMENTATION_ENABLED=false` disables the instrumentation.
- `ARMS_AUTOGEN_AGENT_SPAN_ENABLED=false` disables the AgentChat agent wrapper.
- `ARMS_AUTOGEN_LLM_SPAN_ENABLED=false` disables the AgentChat LLM wrapper.
- `ARMS_AUTOGEN_NATIVE_SPAN_PROCESSOR_ENABLED=false` disables native span
  normalization.

The package uses `opentelemetry-util-genai` and respects the shared GenAI
content-capture environment variables.
