Skip to content

Releases: getsentry/sentry-python

2.16.0

08 Oct 12:39
9098601
Compare
Choose a tag to compare

Integrations

  • Bottle: Add failed_request_status_codes (#3618) by @szokeasaurusrex

    You can now define a set of integers that will determine which status codes
    should be reported to Sentry.

    sentry_sdk.init(
        integrations=[
            BottleIntegration(
                failed_request_status_codes={403, *range(500, 600)},
            )
        ]
    )

    Examples of valid failed_request_status_codes:

    • {500} will only send events on HTTP 500.
    • {400, *range(500, 600)} will send events on HTTP 400 as well as the 5xx range.
    • {500, 503} will send events on HTTP 500 and 503.
    • set() (the empty set) will not send events for any HTTP status code.

    The default is {*range(500, 600)}, meaning that all 5xx status codes are reported to Sentry.

  • Bottle: Delete never-reached code (#3605) by @szokeasaurusrex

  • Redis: Remove flaky test (#3626) by @sentrivana

  • Django: Improve getting psycopg3 connection info (#3580) by @nijel

  • Django: Add SpotlightMiddleware when Spotlight is enabled (#3600) by @BYK

  • Django: Open relevant error when SpotlightMiddleware is on (#3614) by @BYK

  • Django: Support http_methods_to_capture in ASGI Django (#3607) by @sentrivana

    ASGI Django now also supports the http_methods_to_capture integration option. This is a configurable tuple of HTTP method verbs that should create a transaction in Sentry. The default is ("CONNECT", "DELETE", "GET", "PATCH", "POST", "PUT", "TRACE",). OPTIONS and HEAD are not included by default.

    Here's how to use it:

    sentry_sdk.init(
        integrations=[
            DjangoIntegration(
                http_methods_to_capture=("GET", "POST"),
            ),
        ],
    )

Miscellaneous

2.15.0

01 Oct 14:12
65909ed
Compare
Choose a tag to compare

Integrations

  • Configure HTTP methods to capture in ASGI/WSGI middleware and frameworks (#3531) by @antonpirker

    We've added a new option to the Django, Flask, Starlette and FastAPI integrations called http_methods_to_capture. This is a configurable tuple of HTTP method verbs that should create a transaction in Sentry. The default is ("CONNECT", "DELETE", "GET", "PATCH", "POST", "PUT", "TRACE",). OPTIONS and HEAD are not included by default.

    Here's how to use it (substitute Flask for your framework integration):

    sentry_sdk.init(
        integrations=[
          FlaskIntegration(
              http_methods_to_capture=("GET", "POST"),
          ),
      ],
    )
  • Django: Allow ASGI to use drf_request in DjangoRequestExtractor (#3572) by @PakawiNz

  • Django: Don't let RawPostDataException bubble up (#3553) by @sentrivana

  • Django: Add sync_capable to SentryWrappingMiddleware (#3510) by @szokeasaurusrex

  • AIOHTTP: Add failed_request_status_codes (#3551) by @szokeasaurusrex

    You can now define a set of integers that will determine which status codes
    should be reported to Sentry.

    sentry_sdk.init(
        integrations=[
            AioHttpIntegration(
                failed_request_status_codes={403, *range(500, 600)},
            )
        ]
    )

    Examples of valid failed_request_status_codes:

    • {500} will only send events on HTTP 500.
    • {400, *range(500, 600)} will send events on HTTP 400 as well as the 5xx range.
    • {500, 503} will send events on HTTP 500 and 503.
    • set() (the empty set) will not send events for any HTTP status code.

    The default is {*range(500, 600)}, meaning that all 5xx status codes are reported to Sentry.

  • AIOHTTP: Delete test which depends on AIOHTTP behavior (#3568) by @szokeasaurusrex

  • AIOHTTP: Handle invalid responses (#3554) by @szokeasaurusrex

  • FastAPI/Starlette: Support new failed_request_status_codes (#3563) by @szokeasaurusrex

    The format of failed_request_status_codes has changed from a list
    of integers and containers to a set:

    sentry_sdk.init(
        integrations=StarletteIntegration(
            failed_request_status_codes={403, *range(500, 600)},
        ),
    )

    The old way of defining failed_request_status_codes will continue to work
    for the time being. Examples of valid new-style failed_request_status_codes:

    • {500} will only send events on HTTP 500.
    • {400, *range(500, 600)} will send events on HTTP 400 as well as the 5xx range.
    • {500, 503} will send events on HTTP 500 and 503.
    • set() (the empty set) will not send events for any HTTP status code.

    The default is {*range(500, 600)}, meaning that all 5xx status codes are reported to Sentry.

  • FastAPI/Starlette: Fix failed_request_status_codes=[] (#3561) by @szokeasaurusrex

  • FastAPI/Starlette: Remove invalid failed_request_status_code tests (#3560) by @szokeasaurusrex

  • FastAPI/Starlette: Refactor shared test parametrization (#3562) by @szokeasaurusrex

Miscellaneous

2.14.0

09 Sep 12:50
1e73ce9
Compare
Choose a tag to compare

Various fixes & improvements

2.13.0

13 Aug 14:33
570307c
Compare
Choose a tag to compare

Various fixes & improvements

  • New integration: Ray (#2400) (#2444) by @glowskir

    Usage: (add the RayIntegration to your sentry_sdk.init() call and make sure it is called in the worker processes)

    import ray
    
    import sentry_sdk
    from sentry_sdk.integrations.ray import RayIntegration
    
    def init_sentry():
        sentry_sdk.init(
            dsn="...",
            traces_sample_rate=1.0,
            integrations=[RayIntegration()],
        )
    
    init_sentry()
    
    ray.init(
        runtime_env=dict(worker_process_setup_hook=init_sentry), 
    )

    For more information, see the documentation for the Ray integration.

  • New integration: Litestar (#2413) (#3358) by @KellyWalker

    Usage: (add the LitestarIntegration to your sentry_sdk.init())

    from litestar import Litestar, get
    
    import sentry_sdk
    from sentry_sdk.integrations.litestar import LitestarIntegration
    
    sentry_sdk.init(
        dsn="...",
        traces_sample_rate=1.0,
        integrations=[LitestarIntegration()],
    )
    
    @get("/")
    async def index() -> str:
        return "Hello, world!"
    
    app = Litestar(...)

    For more information, see the documentation for the Litestar integration.

  • New integration: Dramatiq from @jacobsvante (#3397) by @antonpirker
    Usage: (add the DramatiqIntegration to your sentry_sdk.init())

    import dramatiq
    
    import sentry_sdk
    from sentry_sdk.integrations.dramatiq import DramatiqIntegration
    
    sentry_sdk.init(
        dsn="...",
        traces_sample_rate=1.0,
        integrations=[DramatiqIntegration()],
    )
    
    @dramatiq.actor(max_retries=0)
    def dummy_actor(x, y):
        return x / y
    
    dummy_actor.send(12, 0)

    For more information, see the documentation for the Dramatiq integration.

  • New config option: Expose custom_repr function that precedes safe_repr invocation in serializer (#3438) by @sl0thentr0py

    See: https://docs.sentry.io/platforms/python/configuration/options/#custom-repr

  • Profiling: Add client SDK info to profile chunk (#3386) by @Zylphrex

  • Serialize vars early to avoid living references (#3409) by @sl0thentr0py

  • Deprecate hub-based sessions.py logic (#3419) by @szokeasaurusrex

  • Deprecate is_auto_session_tracking_enabled (#3428) by @szokeasaurusrex

  • Add note to generated yaml files (#3423) by @sentrivana

  • Slim down PR template (#3382) by @sentrivana

  • Use new banner in readme (#3390) by @sentrivana

2.12.0

31 Jul 09:49
441c0f7
Compare
Choose a tag to compare

Various fixes & improvements

1.45.1

26 Jul 13:48
282b8f7
Compare
Choose a tag to compare

This is a security backport release.

2.11.0

24 Jul 07:56
065b23e
Compare
Choose a tag to compare

Various fixes & improvements

2.10.0

15 Jul 10:33
b026dbd
Compare
Choose a tag to compare

Various fixes & improvements

  • Add client cert and key support to HttpTransport (#3258) by @grammy-jiang

    Add cert_file and key_file to your sentry_sdk.init to use a custom client cert and key. Alternatively, the environment variables CLIENT_CERT_FILE and CLIENT_KEY_FILE can be used as well.

  • OpenAI: Lazy initialize tiktoken to avoid http at import time (#3287) by @colin-sentry

  • OpenAI, Langchain: Make tiktoken encoding name configurable + tiktoken usage opt-in (#3289) by @colin-sentry

    Fixed a bug where having certain packages installed along the Sentry SDK caused an HTTP request to be made to OpenAI infrastructure when the Sentry SDK was initialized. The request was made when the tiktoken package and at least one of the openai or langchain packages were installed.

    The request was fetching a tiktoken encoding in order to correctly measure token usage in some OpenAI and Langchain calls. This behavior is now opt-in. The choice of encoding to use was made configurable as well. To opt in, set the tiktoken_encoding_name parameter in the OpenAPI or Langchain integration.

    sentry_sdk.init(
        integrations=[
            OpenAIIntegration(tiktoken_encoding_name="cl100k_base"),
            LangchainIntegration(tiktoken_encoding_name="cl100k_base"),
        ],
    )
  • PyMongo: Send query description as valid JSON (#3291) by @0Calories

  • Remove Python 2 compatibility code (#3284) by @szokeasaurusrex

  • Fix sentry_sdk.init type hint (#3283) by @szokeasaurusrex

  • Deprecate hub in Profile (#3270) by @szokeasaurusrex

  • Stop using Hub in init (#3275) by @szokeasaurusrex

  • Delete _should_send_default_pii (#3274) by @szokeasaurusrex

  • Remove Hub usage in conftest (#3273) by @szokeasaurusrex

  • Rename debug logging filter (#3260) by @szokeasaurusrex

  • Update NoOpSpan.finish signature (#3267) by @szokeasaurusrex

  • Remove Hub in Transaction.finish (#3267) by @szokeasaurusrex

  • Remove Hub from capture_internal_exception logic (#3264) by @szokeasaurusrex

  • Improve Scope._capture_internal_exception type hint (#3264) by @szokeasaurusrex

  • Correct ExcInfo type (#3266) by @szokeasaurusrex

  • Stop using Hub in tracing_utils (#3269) by @szokeasaurusrex

2.9.0

10 Jul 08:16
af3c9c4
Compare
Choose a tag to compare

Various fixes & improvements

2.8.0

08 Jul 08:11
6f4685e
Compare
Choose a tag to compare

Various fixes & improvements