Skip to content
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

SentryMetrics always disabled even when Sentry is initialised #951

Open
james-cohen opened this issue Jan 9, 2025 · 1 comment
Open
Assignees

Comments

@james-cohen
Copy link

Description

Environment

  • pipecat-ai version: 0.0.52
  • python version: 3.10
  • OS: MacOS Ventura

Issue description

I am trying to use the SentryMetrics class to monitor performance as described in the docs here. However, even though I have Sentry installed and initialised at the point of server startup, I always get this warning:

2025-01-09 09:56:01.597 | WARNING  | pipecat.processors.metrics.sentry:<module>:16 - Sentry SDK not initialized. Sentry features will be disabled.

I have confirmed that sentry is initialised using sentry_sdk.is_initialized() just before instantiating the SentryMetrics class. I think the issue is that within the SentryMetrics class itself, the check to see whether Sentry is active occurs as soon as it is imported, not instantiated. As it is not a property of the class itself, it is impossible to change manually:

try:
    import sentry_sdk

    sentry_available = sentry_sdk.is_initialized()
    if not sentry_available:
        logger.warning("Sentry SDK not initialized. Sentry features will be disabled.")
except ImportError:
    sentry_available = False
    logger.warning("Sentry SDK not installed. Sentry features will be disabled.")

from pipecat.processors.metrics.frame_processor_metrics import FrameProcessorMetrics

Repro steps

  • Initiate sentry using sentry_sdk.init()
  • Set SentryMetrics as the _metrics property within a FrameProcessor class
  • Warning appears in logs

Expected behavior

SentryMetrics should check Sentry initialisation at the point of being instantiated

Actual behavior

Checks behaviour too early and is always disabled

Logs

2025-01-09 09:56:01.597 | WARNING  | pipecat.processors.metrics.sentry:<module>:16 - Sentry SDK not initialized. Sentry features will be disabled.
INFO:config.db:Connecting to dev main at *** as ***
INFO:config.db:Created connection pool to main at *** as ***
INFO:root:Sentry initialized for development environment. <-- Point of Sentry initialisation, even though it is before the Pipecat process is set up
@chadbailey59 chadbailey59 self-assigned this Jan 13, 2025
@fatwang2
Copy link

fatwang2 commented Jan 14, 2025

I have also met this problem before, than I moved the code before import pipecat, it works now, here is my code:

import sentry_sdk
from sentry_sdk.integrations.asyncio import AsyncioIntegration
from sentry_sdk.integrations.httpx import HttpxIntegration
sentry_sdk.init(
    dsn=os.getenv("SENTRY_DSN"),
    traces_sample_rate=1.0,
    enable_tracing=True,
    disabled_integrations=[HttpxIntegration()],
    integrations=[
        AsyncioIntegration(),
    ],
)

from pipecat.audio.vad.silero import SileroVADAnalyzer
from pipecat.audio.vad.vad_analyzer import VADParams
from pipecat.frames.frames import (
    EndFrame,
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants