Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0

pull_request:

Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ name: "CodeQL"

on:
push:
branches: [ master ]
branches:
- master
- sentry-sdk-2.0
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
branches:
- master
- sentry-sdk-2.0
schedule:
- cron: '18 18 * * 3'

Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/enforce-license-compliance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@ name: Enforce License Compliance

on:
push:
branches: [master, main, release/*]
branches:
- master
- main
- release/*
- sentry-sdk-2.0
pull_request:
branches: [master, main]
branches:
- master
- main
- sentry-sdk-2.0

jobs:
enforce-license-compliance:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-integrations-aws-lambda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
# XXX: We are using `pull_request_target` instead of `pull_request` because we want
# this to run on forks with access to the secrets necessary to run the test suite.
# Prefer to use `pull_request` when possible.
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-integrations-cloud-computing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-integrations-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-integrations-data-processing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-integrations-databases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-integrations-graphql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-integrations-miscellaneous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-integrations-networking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-integrations-web-frameworks-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-integrations-web-frameworks-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 1.39.1

### Various fixes & improvements

- Fix psycopg2 detection in the Django integration (#2593) by @sentrivana
- Filter out empty string releases (#2591) by @sentrivana
- Fixed local var not present when there is an error in a user's `error_sampler` function (#2511) by @antonpirker
- Fixed typing in `aiohttp` (#2590) by @antonpirker

## 1.39.0

### Various fixes & improvements
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
copyright = "2019-{}, Sentry Team and Contributors".format(datetime.now().year)
author = "Sentry Team and Contributors"

release = "1.39.0"
release = "1.39.1"
version = ".".join(release.split(".")[:2]) # The short X.Y version.


Expand Down
2 changes: 1 addition & 1 deletion linter-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mypy
black
flake8==5.0.4 # flake8 depends on pyflakes>=3.0.0 and this dropped support for Python 2 "# type:" comments
types-certifi
types-protobuf
types-protobuf==4.24.0.4 # newer raises an error on mypy sentry_sdk
types-redis
types-setuptools
pymongo # There is no separate types module.
Expand Down
1 change: 1 addition & 0 deletions scripts/split-tox-gh-actions/templates/base.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
branches:
- master
- release/**
- sentry-sdk-2.0

{% if needs_github_secrets %}
# XXX: We are using `pull_request_target` instead of `pull_request` because we want
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"internal",
"profile",
"statsd",
"check_in",
"monitor",
]
SessionStatus = Literal["ok", "exited", "crashed", "abnormal"]
EndpointType = Literal["store", "envelope"]
Expand Down
8 changes: 7 additions & 1 deletion sentry_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,13 @@ def _setup_instrumentation(self, functions_to_trace):
module_obj = import_module(module_name)
class_obj = getattr(module_obj, class_name)
function_obj = getattr(class_obj, function_name)
setattr(class_obj, function_name, trace(function_obj))
function_type = type(class_obj.__dict__[function_name])
traced_function = trace(function_obj)

if function_type in (staticmethod, classmethod):
traced_function = staticmethod(traced_function)

setattr(class_obj, function_name, traced_function)
setattr(module_obj, class_name, class_obj)
logger.debug("Enabled tracing for %s", function_qualname)

Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,4 @@ def _get_default_options():
del _get_default_options


VERSION = "1.39.0"
VERSION = "1.39.1"
2 changes: 1 addition & 1 deletion sentry_sdk/envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def data_category(self):
elif ty == "statsd":
return "statsd"
elif ty == "check_in":
return "check_in"
return "monitor"
else:
return "default"

Expand Down
6 changes: 3 additions & 3 deletions sentry_sdk/integrations/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ async def sentry_app_handle(self, request, *args, **kwargs):
transaction.set_http_status(response.status)
return response

Application._handle = sentry_app_handle # type: ignore[method-assign]
Application._handle = sentry_app_handle

old_urldispatcher_resolve = UrlDispatcher.resolve

Expand Down Expand Up @@ -173,7 +173,7 @@ async def sentry_urldispatcher_resolve(self, request):

return rv

UrlDispatcher.resolve = sentry_urldispatcher_resolve # type: ignore[method-assign]
UrlDispatcher.resolve = sentry_urldispatcher_resolve

old_client_session_init = ClientSession.__init__

Expand All @@ -190,7 +190,7 @@ def init(*args, **kwargs):
kwargs["trace_configs"] = client_trace_configs
return old_client_session_init(*args, **kwargs)

ClientSession.__init__ = init # type: ignore[method-assign]
ClientSession.__init__ = init


def create_trace_config():
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/arq.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ async def _sentry_coroutine(ctx, *args, **kwargs):
# type: (Dict[Any, Any], *Any, **Any) -> Any
hub = Hub.current
if hub.get_integration(ArqIntegration) is None:
return await coroutine(*args, **kwargs)
return await coroutine(ctx, *args, **kwargs)

hub.scope.add_event_processor(
_make_event_processor({**ctx, "job_name": name}, *args, **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/integrations/django/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ def _set_db_data(span, cursor_or_db):
is_psycopg2 = (
hasattr(cursor_or_db, "connection")
and hasattr(cursor_or_db.connection, "get_dsn_parameters")
and inspect.isfunction(cursor_or_db.connection.get_dsn_parameters)
and inspect.isroutine(cursor_or_db.connection.get_dsn_parameters)
)
if is_psycopg2:
connection_params = cursor_or_db.connection.get_dsn_parameters()
Expand All @@ -706,7 +706,7 @@ def _set_db_data(span, cursor_or_db):
hasattr(cursor_or_db, "connection")
and hasattr(cursor_or_db.connection, "info")
and hasattr(cursor_or_db.connection.info, "get_parameters")
and inspect.isfunction(cursor_or_db.connection.info.get_parameters)
and inspect.isroutine(cursor_or_db.connection.info.get_parameters)
)
if is_psycopg3:
connection_params = cursor_or_db.connection.info.get_parameters()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_file_text(file_name):

setup(
name="sentry-sdk",
version="1.39.0",
version="1.39.1",
author="Sentry Team and Contributors",
author_email="hello@sentry.io",
url="https://github.com/getsentry/sentry-python",
Expand Down
34 changes: 33 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import socket
from threading import Thread
from contextlib import contextmanager

import pytest
import jsonschema
Expand All @@ -27,8 +28,13 @@
from http.server import BaseHTTPRequestHandler, HTTPServer


try:
from unittest import mock
except ImportError:
import mock

import sentry_sdk
from sentry_sdk._compat import iteritems, reraise, string_types
from sentry_sdk._compat import iteritems, reraise, string_types, PY2
from sentry_sdk.envelope import Envelope
from sentry_sdk.integrations import _processed_integrations # noqa: F401
from sentry_sdk.profiler import teardown_profiler
Expand All @@ -37,6 +43,12 @@

from tests import _warning_recorder, _warning_recorder_mgr

from sentry_sdk._types import TYPE_CHECKING

if TYPE_CHECKING:
from typing import Optional
from collections.abc import Iterator


SENTRY_EVENT_SCHEMA = "./checkouts/data-schemas/relay/event.schema.json"

Expand Down Expand Up @@ -620,3 +632,23 @@ def werkzeug_set_cookie(client, servername, key, value):
client.set_cookie(servername, key, value)
except TypeError:
client.set_cookie(key, value)


@contextmanager
def patch_start_tracing_child(fake_transaction_is_none=False):
# type: (bool) -> Iterator[Optional[mock.MagicMock]]
if not fake_transaction_is_none:
fake_transaction = mock.MagicMock()
fake_start_child = mock.MagicMock()
fake_transaction.start_child = fake_start_child
else:
fake_transaction = None
fake_start_child = None

version = "2" if PY2 else "3"

with mock.patch(
"sentry_sdk.tracing_utils_py%s.get_current_span" % version,
return_value=fake_transaction,
):
yield fake_start_child
20 changes: 19 additions & 1 deletion tests/integrations/arq/test_arq.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
import pytest

from sentry_sdk import start_transaction
from sentry_sdk import start_transaction, Hub
from sentry_sdk.integrations.arq import ArqIntegration

import arq.worker
Expand Down Expand Up @@ -234,3 +234,21 @@ async def dummy_job(_):
assert len(event["spans"])
assert event["spans"][0]["op"] == "queue.submit.arq"
assert event["spans"][0]["description"] == "dummy_job"


@pytest.mark.asyncio
async def test_execute_job_without_integration(init_arq):
async def dummy_job(_ctx):
pass

dummy_job.__qualname__ = dummy_job.__name__

pool, worker = init_arq([dummy_job])
# remove the integration to trigger the edge case
Hub.current.client.integrations.pop("arq")

job = await pool.enqueue_job("dummy_job")

await worker.run_job(job.job_id, timestamp_ms())

assert await job.result() is None
Loading