Skip to content

Commit

Permalink
Merge branch 'potel-base' into potel-base-run-all-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sl0thentr0py committed Dec 5, 2024
2 parents fdb2cfa + 9d8c0b7 commit de89a71
Show file tree
Hide file tree
Showing 15 changed files with 367 additions and 38 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## 2.19.1

### Various fixes & improvements

- Fix errors when instrumenting Django cache (#3855) by @BYK
- Copy `scope.client` reference as well (#3857) by @sl0thentr0py
- Don't give up on Spotlight on 3 errors (#3856) by @BYK
- Add missing stack frames (#3673) by @antonpirker
- Fix wrong metadata type in async gRPC interceptor (#3205) by @fdellekart
- Rename launch darkly hook to match JS SDK (#3743) by @aliu39
- Script for checking if our instrumented libs are Python 3.13 compatible (#3425) by @antonpirker
- Improve Ray tests (#3846) by @antonpirker
- Test with Celery `5.5.0rc3` (#3842) by @sentrivana
- Fix asyncio testing setup (#3832) by @sl0thentr0py
- Bump `codecov/codecov-action` from `5.0.2` to `5.0.7` (#3821) by @dependabot
- Fix CI (#3834) by @sentrivana
- Use new ClickHouse GH action (#3826) by @antonpirker

## 2.19.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 @@ -31,7 +31,7 @@
copyright = "2019-{}, Sentry Team and Contributors".format(datetime.now().year)
author = "Sentry Team and Contributors"

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


Expand Down
124 changes: 124 additions & 0 deletions scripts/ready_yet/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import time
import re
import sys

import requests

from collections import defaultdict

from pathlib import Path

from tox.config.cli.parse import get_options
from tox.session.state import State
from tox.config.sets import CoreConfigSet
from tox.config.source.tox_ini import ToxIni

PYTHON_VERSION = "3.13"

MATCH_LIB_SENTRY_REGEX = r"py[\d\.]*-(.*)-.*"

PYPI_PROJECT_URL = "https://pypi.python.org/pypi/{project}/json"
PYPI_VERSION_URL = "https://pypi.python.org/pypi/{project}/{version}/json"


def get_tox_envs(tox_ini_path: Path) -> list:
tox_ini = ToxIni(tox_ini_path)
conf = State(get_options(), []).conf
tox_section = next(tox_ini.sections())
core_config_set = CoreConfigSet(
conf, tox_section, tox_ini_path.parent, tox_ini_path
)
(
core_config_set.loaders.extend(
tox_ini.get_loaders(
tox_section,
base=[],
override_map=defaultdict(list, {}),
conf=core_config_set,
)
)
)
return core_config_set.load("env_list")


def get_libs(tox_ini: Path, regex: str) -> set:
libs = set()
for env in get_tox_envs(tox_ini):
match = re.match(regex, env)
if match:
libs.add(match.group(1))

return sorted(libs)


def main():
"""
Check if libraries in our tox.ini are ready for Python version defined in `PYTHON_VERSION`.
"""
print(f"Checking libs from tox.ini for Python {PYTHON_VERSION} compatibility:")

ready = set()
not_ready = set()
not_found = set()

tox_ini = Path(__file__).parent.parent.parent.joinpath("tox.ini")

libs = get_libs(tox_ini, MATCH_LIB_SENTRY_REGEX)

for lib in libs:
print(".", end="")
sys.stdout.flush()

# Get latest version of lib
url = PYPI_PROJECT_URL.format(project=lib)
pypi_data = requests.get(url)

if pypi_data.status_code != 200:
not_found.add(lib)
continue

latest_version = pypi_data.json()["info"]["version"]

# Get supported Python version of latest version of lib
url = PYPI_PROJECT_URL.format(project=lib, version=latest_version)
pypi_data = requests.get(url)

if pypi_data.status_code != 200:
continue

classifiers = pypi_data.json()["info"]["classifiers"]

if f"Programming Language :: Python :: {PYTHON_VERSION}" in classifiers:
ready.add(lib)
else:
not_ready.add(lib)

# cut pypi some slack
time.sleep(0.1)

# Print report
print("\n")
print(f"\nReady for Python {PYTHON_VERSION}:")
if len(ready) == 0:
print("- None ")

for x in sorted(ready):
print(f"- {x}")

print(f"\nNOT ready for Python {PYTHON_VERSION}:")
if len(not_ready) == 0:
print("- None ")

for x in sorted(not_ready):
print(f"- {x}")

print("\nNot found on PyPI:")
if len(not_found) == 0:
print("- None ")

for x in sorted(not_found):
print(f"- {x}")


if __name__ == "__main__":
main()
3 changes: 3 additions & 0 deletions scripts/ready_yet/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
requests
pathlib
tox
16 changes: 16 additions & 0 deletions scripts/ready_yet/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# exit on first error
set -xe

reset

# create and activate virtual environment
python -m venv .venv
source .venv/bin/activate

# Install (or update) requirements
python -m pip install -r requirements.txt

# Run the script
python main.py
7 changes: 6 additions & 1 deletion sentry_sdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
# up top to prevent circular import due to integration import
DEFAULT_MAX_VALUE_LENGTH = 1024

DEFAULT_MAX_STACK_FRAMES = 100
DEFAULT_ADD_FULL_STACK = False


# Also needs to be at the top to prevent circular import
class EndpointType(Enum):
Expand Down Expand Up @@ -537,6 +540,8 @@ def __init__(
cert_file=None, # type: Optional[str]
key_file=None, # type: Optional[str]
custom_repr=None, # type: Optional[Callable[..., Optional[str]]]
add_full_stack=DEFAULT_ADD_FULL_STACK, # type: bool
max_stack_frames=DEFAULT_MAX_STACK_FRAMES, # type: Optional[int]
):
# type: (...) -> None
pass
Expand All @@ -562,4 +567,4 @@ def _get_default_options():
del _get_default_options


VERSION = "2.19.0"
VERSION = "2.19.1"
7 changes: 4 additions & 3 deletions sentry_sdk/integrations/django/caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ def _instrument_call(
span.set_data(SPANDATA.CACHE_HIT, True)
else:
span.set_data(SPANDATA.CACHE_HIT, False)
else:
try:
else: # TODO: We don't handle `get_or_set` which we should
arg_count = len(args)
if arg_count >= 2:
# 'set' command
item_size = len(str(args[1]))
except IndexError:
elif arg_count == 1:
# 'set_many' command
item_size = len(str(args[0]))

Expand Down
23 changes: 10 additions & 13 deletions sentry_sdk/integrations/grpc/aio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
ClientCallDetails,
UnaryUnaryCall,
UnaryStreamCall,
Metadata,
)
from google.protobuf.message import Message

Expand All @@ -19,23 +20,19 @@ class ClientInterceptor:
def _update_client_call_details_metadata_from_scope(
client_call_details: ClientCallDetails,
) -> ClientCallDetails:
metadata = (
list(client_call_details.metadata) if client_call_details.metadata else []
)
if client_call_details.metadata is None:
client_call_details = client_call_details._replace(metadata=Metadata())
elif not isinstance(client_call_details.metadata, Metadata):
# This is a workaround for a GRPC bug, which was fixed in grpcio v1.60.0
# See https://github.com/grpc/grpc/issues/34298.
client_call_details = client_call_details._replace(
metadata=Metadata.from_tuple(client_call_details.metadata)
)
for (
key,
value,
) in sentry_sdk.get_current_scope().iter_trace_propagation_headers():
metadata.append((key, value))

client_call_details = ClientCallDetails(
method=client_call_details.method,
timeout=client_call_details.timeout,
metadata=metadata,
credentials=client_call_details.credentials,
wait_for_ready=client_call_details.wait_for_ready,
)

client_call_details.metadata.add(key, value)
return client_call_details


Expand Down
1 change: 1 addition & 0 deletions sentry_sdk/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def __copy__(self):
rv = object.__new__(self.__class__) # type: Scope

rv._type = self._type
rv.client = self.client
rv._level = self._level
rv._name = self._name
rv._fingerprint = self._fingerprint
Expand Down
7 changes: 1 addition & 6 deletions sentry_sdk/spotlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ def __init__(self, url):

def capture_envelope(self, envelope):
# type: (Envelope) -> None
if self.tries > 3:
sentry_logger.warning(
"Too many errors sending to Spotlight, stop sending events there."
)
return
body = io.BytesIO()
envelope.serialize_into(body)
try:
Expand All @@ -60,7 +55,7 @@ def capture_envelope(self, envelope):
)
req.close()
except Exception as e:
self.tries += 1
# TODO: Implement buffering and retrying with exponential backoff
sentry_logger.warning(str(e))


Expand Down
Loading

0 comments on commit de89a71

Please sign in to comment.