Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions ak-py/src/agentkernel/adk/adk.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,16 @@ class GoogleADKModule(Module):
GoogleADKModule class provides a module for Google ADK-based agents.
"""

def __init__(self, agents: list[BaseAgent]):
def __init__(self, agents: list[BaseAgent], runner: GoogleADKRunner = None):
"""
Initializes a Google ADK Module instance.
:param agents: List of agents in the module.
:param runner: Custom runner associated with the module.
"""
super().__init__()
if AKConfig.get().trace.enabled:
if runner is not None:
self.runner = runner
elif AKConfig.get().trace.enabled:
self.runner = Trace.get().adk()
else:
self.runner = GoogleADKRunner()
Expand Down
7 changes: 5 additions & 2 deletions ak-py/src/agentkernel/crewai/crewai.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,16 @@ class CrewAIModule(Module):
CrewAIModule class provides a module for CrewAI based agents.
"""

def __init__(self, agents: list[Agent]):
def __init__(self, agents: list[Agent], runner: CrewAIRunner = None):
"""
Initializes a CrewAIModule instance.
:param agents: List of agents in the module.
:param runner: Custom runner associated with the module.
"""
super().__init__()
if AKConfig.get().trace.enabled:
if runner is not None:
self.runner = runner
elif AKConfig.get().trace.enabled:
self.runner = Trace.get().crewai()
else:
self.runner = CrewAIRunner()
Expand Down
7 changes: 5 additions & 2 deletions ak-py/src/agentkernel/langgraph/langgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,16 @@ class LangGraphModule(BaseModule):
LangGraphModule class provides a module for LangGraph Agent SDK-based agents.
"""

def __init__(self, agents: list[CompiledStateGraph]):
def __init__(self, agents: list[CompiledStateGraph], runner: LangGraphRunner = None):
"""
Initializes a LangGraphModule instance.
:param agents: List of agents in the module.
:param runner: Custom runner associated with the module.
"""
super().__init__()
if AKConfig.get().trace.enabled:
if runner is not None:
self.runner = runner
elif AKConfig.get().trace.enabled:
self.runner = Trace.get().langgraph()
else:
self.runner = LangGraphRunner()
Expand Down
7 changes: 5 additions & 2 deletions ak-py/src/agentkernel/openai/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,16 @@ class OpenAIModule(Module):
OpenAIModule class provides a module for OpenAI Agents SDK based agents.
"""

def __init__(self, agents: list[Agent]):
def __init__(self, agents: list[Agent], runner: OpenAIRunner = None):
"""
Initializes an OpenAIModule instance.
:param agents: List of agents in the module.
:param runner: Custom runner associated with the module.
"""
super().__init__()
if AKConfig.get().trace.enabled:
if runner is not None:
self.runner = runner
elif AKConfig.get().trace.enabled:
self.runner = Trace.get().openai()
else:
self.runner = OpenAIRunner()
Expand Down
53 changes: 5 additions & 48 deletions docs/blog/2025-11-17-observability-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,42 +323,8 @@ Agent Kernel's plugin architecture makes it easy to integrate your own observabi

### How to Add Your Own Platform

1. **Implement the BaseTrace Interface**

Create a new class that extends `BaseTrace` and implements the required methods:

```python
from agentkernel.trace.base import BaseTrace
from agentkernel.core import Runner

class MyCustomTrace(BaseTrace):
def __init__(self):
self._client = None

def init(self):
# Initialize your tracing client
self._client = MyTracingClient(
api_key=os.getenv("MY_TRACE_API_KEY")
)

def openai(self) -> Runner:
from .openai_runner import MyCustomOpenAIRunner
return MyCustomOpenAIRunner(self._client)

def langgraph(self) -> Runner:
from .langgraph_runner import MyCustomLangGraphRunner
return MyCustomLangGraphRunner(self._client)

def crewai(self) -> Runner:
from .crewai_runner import MyCustomCrewAIRunner
return MyCustomCrewAIRunner(self._client)

def adk(self) -> Runner:
from .adk_runner import MyCustomADKRunner
return MyCustomADKRunner(self._client)
```

2. **Create Framework-Specific Runners**
1. **Create Framework-Specific Runners**

Each runner wraps the framework's execution with your tracing logic:

Expand All @@ -384,24 +350,15 @@ class MyCustomOpenAIRunner(OpenAIRunner):
return result
```

3. **Register Your Implementation**
2. **Initialize the module with the custom runner**

Add your platform to the Trace factory in `agentkernel/trace/trace.py`:
Initialize the module with your custom runner

```python
if trace_type == "mycustom":
from .mycustom.mycustom import MyCustomTrace
instance = MyCustomTrace()
OpenAIModule([general_agent], runner=MyCustomOpenAIRunner())
```

4. **Configure and Use**

```yaml
# config.yaml
trace:
enabled: true
type: mycustom
```
Custom runner supersedes all other trace configurations

```bash
export MY_TRACE_API_KEY=your-api-key
Expand Down
59 changes: 59 additions & 0 deletions docs/docs/advanced/traceability.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,65 @@ export TRACELOOP_BASE_URL=http://your-otel-collector:4318

See [OpenLLMetry documentation](https://www.traceloop.com/docs/openllmetry/integrations) for more backend options.


## Integrate with Your Own Traceability Platform

Agent Kernel's plugin architecture makes it easy to integrate your own observability platform. If you're already using a different monitoring solution or have specific requirements, you can add support in just a few steps.

### How to Add Your Own Platform


1. **Create Framework-Specific Runners**

Runner wraps the framework's execution with your tracing logic:

```python
from agentkernel.openai.openai import OpenAIRunner
from agentkernel.core import Session

class MyCustomOpenAIRunner(OpenAIRunner):
def __init__(self, client):
super().__init__()
self._client = client

async def run(self, agent, session: Session, prompt):
# Start a trace span
with self._client.start_span("agent-execution") as span:
span.set_attribute("session_id", session.id)
span.set_attribute("prompt", prompt)

# Run the agent
result = await super().run(agent=agent, prompt=prompt, session=session)

span.set_attribute("result", result)
return result
```

2. **Initialize the module with the custom runner**

Initialize the module with your custom runner

```python
OpenAIModule([general_agent], runner=MyCustomOpenAIRunner())
```

Custom runner supersedes all other trace configurations

```bash
export MY_TRACE_API_KEY=your-api-key
```

Your custom observability platform is now integrated with Agent Kernel.

### Example Use Cases

- **Proprietary Monitoring Systems**: Integrate with your company's internal monitoring tools
- **Compliance Requirements**: Route traces to approved, compliant systems
- **Custom Aggregation**: Combine multiple backends or add custom processing
- **Cost Optimization**: Use cheaper or self-hosted alternatives

The extensible architecture ensures you're never locked into a specific platform.

## Roadmap

Upcoming observability features:
Expand Down
Loading