Release sessions not showing up in Sentry

Viewed 218

I have added Sentry to my Python program like this:

        sentry_sdk.init(
            "https://2de30dc7030a4a78a41fad327ba0acff@o1107570.ingest.sentry.io/6134822",
            traces_sample_rate=1.0,
            release=__version__,
            auto_session_tracking=True,
        )
        sentry_sdk.set_user(dict(id=get_user_id()))

This is supposed to also track user sessions, the auto_session_tracking would default to True anyway. When I take a look at the web interface, however, I see that my messages (send via sentry_sdk.capture_message(event)) show up, but there are no users tracked for the releases:

enter image description here

It refers to the documentation, but there is a gap there. This has already been reported. In that issue is stated that the feature is available, just the documentation is missing still.

Do I have to do anything special to get this tracked properly?

1 Answers

The auto_session_tracking config currently only applies to our WSGI middleware so it'll only be effective with a framework/integration that uses that WSGI middleware (Django being the obvious example).

If you wish to track a session yourself, we have a context manager that you can use as below.

import sentry_sdk
from sentry_sdk.sessions import auto_session_tracking

with auto_session_tracking(session_mode="request"):
    with sentry_sdk.push_scope():
        sentry_sdk.capture_message("foobar")

The session_mode argument can be either "request" or "application" with semantics documented here. Adding automatic session tracking more generally to other frameworks is on our roadmap. We will also update the docs to clarify this.

Related