forked from pipecat-ai/pipecat
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Sentry instrumentation for performance and error tracking #1
Open
cyrilS-dev
wants to merge
13
commits into
main
Choose a base branch
from
sentry-impl
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+169
−80
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This update add optional Sentry integration for performance tracking and error monitoring. Key changes include: - Add conditional Sentry import and initialization check - Implement Sentry spans in FrameProcessorMetrics to measure TTFB (Time To First Byte) and processing time when Sentry is available - Maintain existing metrics functionality with MetricsFrame regardless of Sentry availability
This commit enhances the DeepgramSTTService class to enable metrics generation for use with Sentry. Key changes include: 1. Enable general metrics generation: - Implement `can_generate_metrics` method, returning True when VAD is enabled - This allows metrics to be collected and used by both Sentry and the metrics system in frame_processor.py 2. Integrate Sentry-compatible performance tracking: - Add start_ttfb_metrics and start_processing_metrics calls in the VAD speech detection handler - Implement stop_ttfb_metrics call when receiving transcripts - Add stop_processing_metrics for final transcripts 3. Enhance VAD support for metrics: - Add `vad_enabled` property to check VAD event availability - Implement VAD-based speech detection handler for precise metric timing These changes enable detailed performance tracking via both Sentry and the general metrics system when VAD is active. This allows for better monitoring and analysis of the speech-to-text process, providing valuable insights through Sentry and any other metrics consumers in the pipeline.
- Modified the __init__ method to accept a metrics parameter that is either FrameProcessorMetrics or one of its subclasses - Updated the metrics initialization to create an instance with the processor's name - Moved all FrameProcessorMetrics-related logic to a new processors\metrics\base.py file
1. Created a new metrics module in processors/metrics/ 2. Implemented FrameProcessorMetrics base class in base.py: 3. Implemented SentryMetrics class in sentry.py: - Inherits from FrameProcessorMetrics - Integrates with Sentry SDK for advanced metrics tracking - Implements Sentry-specific span creation and management for TTFB and processing metrics - Handles cases where Sentry is not available or initialized
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This Pull Request introduces Sentry integration for performance tracking and error monitoring.
Key changes:
DeepgramSTTService:
Enable general metrics generation:
can_generate_metrics
method, returning True when VAD is enabledIntegrate Sentry-compatible performance tracking:
Enhance VAD support for metrics:
vad_enabled
property to check VAD event availabilityThese changes allow for comprehensive performance monitoring and analysis using Sentry, providing valuable insights into STT, LLM and TTS services. The integration is designed to be non-intrusive, maintaining existing functionality while adding custom performance instrumentation.
Testing:
To validate the Sentry integration, the following steps were taken:
examples/simple-chatbot/demo.py
:The
vad_events
parameter in the DeepgramSTTService configuration was set toTrue
The chatbot was run with this configuration, and the results were observed in the Sentry dashboard.
A screenshot of the Sentry performance monitoring results, demonstrating successful tracking of STT, LLM, and TTS services performance metrics :
These tests confirm that Sentry is correctly integrated and capable of monitoring both performance and errors across the pipeline components.
Notes:
It's crucial to initialize Sentry as early as possible in the application, and before from
pipecat.pipeline.pipeline import Pipeline
:sentry_sdk.is_initialized()
returns the correct state when called inframe_processor.py
.Future Improvements:
Usage Metrics in Sentry Spans:
I plan to enhance the Sentry integration by adding "usage_metrics" to Sentry spans as tags.
This improvement will provide more detailed and contextual information about resource usage within each service, allowing for better analysis and optimization of our pipeline components.
Review TTS Processing Time Measurement:
I need to review and potentially refine the way we measure processing time for the Text-to-Speech (TTS) service.