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

Unable to configure #3017

Open
Yathushan opened this issue Apr 23, 2024 · 2 comments
Open

Unable to configure #3017

Yathushan opened this issue Apr 23, 2024 · 2 comments

Comments

@Yathushan
Copy link

Environment

SaaS (https://sentry.io/)

What are you trying to accomplish?

I want to monitor my Streamlit app with Sentry.io so that errors can be easily detected and key metrics are captured.

How are you getting stuck?

I created the following util logging file - logging.py

import streamlit as st
import sentry_sdk
import logging

sentry_sdk.init(
    dsn={my DSN URL},
    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for performance monitoring.
    traces_sample_rate=1.0,
    # Set profiles_sample_rate to 1.0 to profile 100%
    # of sampled transactions.
    # We recommend adjusting this value in production.
    profiles_sample_rate=1.0,
    enable_tracing=True
)

# Configure logging (adjust level as needed)
logging.basicConfig(level=logging.DEBUG)
st_logger = logging.getLogger('streamlit')
st_logger.setLevel(logging.INFO)

In every page and util script, I import this util file and I have seen that metrics are now captured. However, I have not noticed any errors appearing.

Errors will display in my app as Streamlit Exceptions (https://docs.streamlit.io/develop/api-reference/status/st.exception) but they are not captured as issues.

Where in the product are you?

Issues

Link

No response

DSN

No response

Version

No response

@getsantry
Copy link

getsantry bot commented Apr 23, 2024

Assigning to @getsentry/support for routing ⏲️

@dalnoki dalnoki transferred this issue from getsentry/sentry Apr 25, 2024
@antonpirker
Copy link
Member

Hey @Yathushan, thanks for writing in!

The errors do not show up in Sentry, because the Sentry SDK only captures unhandled errors and sends them to Sentry. Streamlit is handling the errors (and displays them) so the Sentry SDK never gets to see the errors.

Unfortunately we do not have a Streamlit integration that would do the sending of those handled Streamlit errors.

The solution would be to find the function in streamlit that handles errors and then wrap this function with a custom function that sends the error to Sentry and then calls the original Streamlit error handling function. (this is what our integrations for all the other Python frameworks do)

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

No branches or pull requests

2 participants