Merge pull request #3815 from pipecat-ai/fix/sentry-metrics-signatures
Fix SentryMetrics method signatures to match base class
This commit is contained in:
1
changelog/3808.fixed.md
Normal file
1
changelog/3808.fixed.md
Normal file
@@ -0,0 +1 @@
|
||||
- Fixed `SentryMetrics` method signatures to match updated `FrameProcessorMetrics` base class, resolving `TypeError` when using `start_time`/`end_time` keyword arguments.
|
||||
@@ -7,6 +7,7 @@
|
||||
"""Sentry integration for frame processor metrics."""
|
||||
|
||||
import asyncio
|
||||
from typing import Optional
|
||||
|
||||
from loguru import logger
|
||||
|
||||
@@ -70,13 +71,18 @@ class SentryMetrics(FrameProcessorMetrics):
|
||||
logger.trace(f"{self} Flushing Sentry metrics")
|
||||
sentry_sdk.flush(timeout=5.0)
|
||||
|
||||
async def start_ttfb_metrics(self, report_only_initial_ttfb):
|
||||
async def start_ttfb_metrics(
|
||||
self, *, start_time: Optional[float] = None, report_only_initial_ttfb: bool
|
||||
):
|
||||
"""Start tracking time-to-first-byte metrics.
|
||||
|
||||
Args:
|
||||
start_time: Optional start timestamp override.
|
||||
report_only_initial_ttfb: Whether to report only the initial TTFB measurement.
|
||||
"""
|
||||
await super().start_ttfb_metrics(report_only_initial_ttfb)
|
||||
await super().start_ttfb_metrics(
|
||||
start_time=start_time, report_only_initial_ttfb=report_only_initial_ttfb
|
||||
)
|
||||
|
||||
if self._should_report_ttfb and self._sentry_available:
|
||||
self._ttfb_metrics_tx = sentry_sdk.start_transaction(
|
||||
@@ -87,23 +93,25 @@ class SentryMetrics(FrameProcessorMetrics):
|
||||
f"{self} Sentry transaction started (ID: {self._ttfb_metrics_tx.span_id} Name: {self._ttfb_metrics_tx.name})"
|
||||
)
|
||||
|
||||
async def stop_ttfb_metrics(self):
|
||||
async def stop_ttfb_metrics(self, *, end_time: Optional[float] = None):
|
||||
"""Stop tracking time-to-first-byte metrics.
|
||||
|
||||
Queues the TTFB transaction for completion and transmission to Sentry.
|
||||
Args:
|
||||
end_time: Optional end timestamp override.
|
||||
"""
|
||||
await super().stop_ttfb_metrics()
|
||||
await super().stop_ttfb_metrics(end_time=end_time)
|
||||
|
||||
if self._sentry_available and self._ttfb_metrics_tx:
|
||||
await self._sentry_queue.put(self._ttfb_metrics_tx)
|
||||
self._ttfb_metrics_tx = None
|
||||
|
||||
async def start_processing_metrics(self):
|
||||
async def start_processing_metrics(self, *, start_time: Optional[float] = None):
|
||||
"""Start tracking frame processing metrics.
|
||||
|
||||
Creates a new Sentry transaction to track processing performance.
|
||||
Args:
|
||||
start_time: Optional start timestamp override.
|
||||
"""
|
||||
await super().start_processing_metrics()
|
||||
await super().start_processing_metrics(start_time=start_time)
|
||||
|
||||
if self._sentry_available:
|
||||
self._processing_metrics_tx = sentry_sdk.start_transaction(
|
||||
@@ -114,12 +122,13 @@ class SentryMetrics(FrameProcessorMetrics):
|
||||
f"{self} Sentry transaction started (ID: {self._processing_metrics_tx.span_id} Name: {self._processing_metrics_tx.name})"
|
||||
)
|
||||
|
||||
async def stop_processing_metrics(self):
|
||||
async def stop_processing_metrics(self, *, end_time: Optional[float] = None):
|
||||
"""Stop tracking frame processing metrics.
|
||||
|
||||
Queues the processing transaction for completion and transmission to Sentry.
|
||||
Args:
|
||||
end_time: Optional end timestamp override.
|
||||
"""
|
||||
await super().stop_processing_metrics()
|
||||
await super().stop_processing_metrics(end_time=end_time)
|
||||
|
||||
if self._sentry_available and self._processing_metrics_tx:
|
||||
await self._sentry_queue.put(self._processing_metrics_tx)
|
||||
|
||||
Reference in New Issue
Block a user