|
51 | 51 | from ..vad.events import VADAudioEvent |
52 | 52 | from . import events |
53 | 53 | from .conversation import Conversation |
| 54 | +from ..profiling import Profiler |
54 | 55 | from dataclasses import dataclass |
55 | 56 | from opentelemetry.trace import set_span_in_context |
56 | 57 | from opentelemetry.trace.propagation import Span, Context |
@@ -155,6 +156,7 @@ def __init__( |
155 | 156 | tracer: Tracer = trace.get_tracer("agents"), |
156 | 157 | # Configure the default logging for the sdk here. Pass None to leave the config intact. |
157 | 158 | log_level: Optional[int] = logging.INFO, |
| 159 | + profiler: Optional[Profiler] = None, |
158 | 160 | ): |
159 | 161 | if log_level is not None: |
160 | 162 | configure_default_logging(level=log_level) |
@@ -208,7 +210,7 @@ def __init__( |
208 | 210 | self._pending_user_transcripts: Dict[str, str] = {} |
209 | 211 |
|
210 | 212 | # Merge plugin events BEFORE subscribing to any events |
211 | | - for plugin in [stt, tts, turn_detection, vad, llm, edge]: |
| 213 | + for plugin in [stt, tts, turn_detection, vad, llm, edge, profiler]: |
212 | 214 | if plugin and hasattr(plugin, "events"): |
213 | 215 | self.logger.debug(f"Register events from plugin {plugin}") |
214 | 216 | self.events.merge(plugin.events) |
@@ -263,6 +265,8 @@ def end_tracing(self): |
263 | 265 | def __aexit__(self, exc_type, exc_val, exc_tb): |
264 | 266 | self.end_tracing() |
265 | 267 |
|
| 268 | + self.events.send(events.AgentInitEvent()) |
| 269 | + |
266 | 270 | async def simple_response( |
267 | 271 | self, text: str, participant: Optional[Participant] = None |
268 | 272 | ) -> None: |
@@ -557,6 +561,8 @@ async def on_ended(event: CallEndedEvent): |
557 | 561 | except asyncio.CancelledError: |
558 | 562 | running_event.clear() |
559 | 563 |
|
| 564 | + self.events.send(events.AgentFinishEvent()) |
| 565 | + |
560 | 566 | await asyncio.shield(self.close()) |
561 | 567 |
|
562 | 568 | async def close(self): |
|
0 commit comments