Skip to content

Commit

Permalink
chore(sentry): update start_span to use name istead of description arg
Browse files Browse the repository at this point in the history
This was introduced in
getsentry/sentry-python#3524 and description
immediatelly started to throw depreciation error.
  • Loading branch information
nijel committed Oct 2, 2024
1 parent c779db0 commit e23f390
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ dependencies = [
"redis>=5.0.2,<5.2.0",
"requests>=2.32.2,<2.33",
"ruamel.yaml>=0.17.2,<0.19.0",
"sentry-sdk>=2.8,<3.0",
"sentry-sdk>=2.15.0,<3.0",
"siphashc>=2.1,<3.0",
"social-auth-app-django>=5.4.1,<6.0.0",
"social-auth-core>=4.5.0,<5.0.0",
Expand Down
4 changes: 1 addition & 3 deletions weblate/addons/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,7 @@ def execute_addon_event(

try:
# Execute event in senty span to track performance
with sentry_sdk.start_span(
op=f"addon.{event.name}", description=addon.name
):
with sentry_sdk.start_span(op=f"addon.{event.name}", name=addon.name):
if isinstance(method, str):
log_result = getattr(addon.addon, method)(*args)
else:
Expand Down
2 changes: 1 addition & 1 deletion weblate/auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ def _fetch_permissions(self) -> None:
"""Fetch all user permissions into a dictionary."""
projects: PermissionCacheType = defaultdict(list)
components: SimplePermissionCacheType = defaultdict(list)
with sentry_sdk.start_span(op="permissions", description=self.username):
with sentry_sdk.start_span(op="permissions", name=self.username):
for group in self.cached_groups:
# Skip permissions for not verified users
if group.enforced_2fa and not self.profile.has_2fa:
Expand Down
2 changes: 1 addition & 1 deletion weblate/checks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def check_component(self, component: Component) -> Iterable[Unit]:
raise NotImplementedError

def perform_batch(self, component: Component) -> None:
with sentry_sdk.start_span(op="check.perform_batch", description=self.check_id):
with sentry_sdk.start_span(op="check.perform_batch", name=self.check_id):
self._perform_batch(component)

def _perform_batch(self, component: Component) -> None:
Expand Down
4 changes: 2 additions & 2 deletions weblate/glossary/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_glossary_sources(component):
def get_glossary_automaton(project):
from weblate.trans.models.component import prefetch_glossary_terms

with sentry_sdk.start_span(op="glossary.automaton", description=project.slug):
with sentry_sdk.start_span(op="glossary.automaton", name=project.slug):
# Chain terms
prefetch_glossary_terms(project.glossaries)
terms = set(
Expand Down Expand Up @@ -107,7 +107,7 @@ def get_glossary_terms(
automaton = project.glossary_automaton
positions: dict[str, list[tuple[int, int]]] = defaultdict(list)
# Extract terms present in the source
with sentry_sdk.start_span(op="glossary.match", description=project.slug):
with sentry_sdk.start_span(op="glossary.match", name=project.slug):
for _termno, start, end in automaton.find_matches_as_indexes(
source, overlapping=True
):
Expand Down
8 changes: 4 additions & 4 deletions weblate/screenshots/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def ensure_tesseract_language(lang: str) -> None:

LOGGER.debug("downloading tesseract data %s", url)

with sentry_sdk.start_span(op="ocr.download", description=url):
with sentry_sdk.start_span(op="ocr.download", name=url):
response = request("GET", url, allow_redirects=True)

with open(full_name, "xb") as handle:
Expand Down Expand Up @@ -384,14 +384,14 @@ def ocr_get_strings(api, image: str, resolution: int = 72):
else:
api.SetSourceResolution(resolution)

with sentry_sdk.start_span(op="ocr.recognize", description=image):
with sentry_sdk.start_span(op="ocr.recognize", name=image):
api.Recognize()

with sentry_sdk.start_span(op="ocr.iterate", description=image):
with sentry_sdk.start_span(op="ocr.iterate", name=image):
iterator = api.GetIterator()
level = RIL.TEXTLINE
for r in iterate_level(iterator, level):
with sentry_sdk.start_span(op="ocr.text", description=image):
with sentry_sdk.start_span(op="ocr.text", name=image):
try:
yield r.GetUTF8Text(level)
except RuntimeError:
Expand Down
2 changes: 1 addition & 1 deletion weblate/trans/models/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -3816,7 +3816,7 @@ def all_repo_components(self):
return [self]

def start_sentry_span(self, op: str):
return sentry_sdk.start_span(op=op, description=self.full_slug)
return sentry_sdk.start_span(op=op, name=self.full_slug)

@cached_property
def key_filter_re(self) -> re.Pattern:
Expand Down
6 changes: 3 additions & 3 deletions weblate/trans/models/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def get_filename(self) -> None | str:
def load_store(self, fileobj=None, force_intermediate=False):
"""Load translate-toolkit storage from disk."""
# Use intermediate store as template for source translation
with sentry_sdk.start_span(op="load_store", description=self.get_filename()):
with sentry_sdk.start_span(op="load_store", name=self.get_filename()):
if force_intermediate or (self.is_template and self.component.intermediate):
template = self.component.intermediate_store
else:
Expand Down Expand Up @@ -329,7 +329,7 @@ def sync_unit(
is_new = True

with sentry_sdk.start_span(
op="update_from_unit", description=f"{self.full_slug}:{pos}"
op="update_from_unit", name=f"{self.full_slug}:{pos}"
):
newunit.update_from_unit(unit, pos, is_new)

Expand All @@ -338,7 +338,7 @@ def sync_unit(

def check_sync(self, force=False, request=None, change=None) -> None: # noqa: C901
"""Check whether database is in sync with git and possibly updates."""
with sentry_sdk.start_span(op="check_sync", description=self.full_slug):
with sentry_sdk.start_span(op="check_sync", name=self.full_slug):
if change is None:
change = Change.ACTION_UPDATE
user = None if request is None else request.user
Expand Down
4 changes: 2 additions & 2 deletions weblate/trans/views/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def display_fixups(request: AuthenticatedHttpRequest, fixups) -> None:

def get_other_units(unit):
"""Return other units to show while translating."""
with sentry_sdk.start_span(op="unit.others", description=unit.pk):
with sentry_sdk.start_span(op="unit.others", name=unit.pk):
result: dict[str, Any] = {
"total": 0,
"skipped": False,
Expand Down Expand Up @@ -240,7 +240,7 @@ def search(
name = ""
search_items = ()

with sentry_sdk.start_span(op="unit.search", description=search_url):
with sentry_sdk.start_span(op="unit.search", name=search_url):
search_result = {
"form": form,
"offset": cleaned_data.get("offset", 1),
Expand Down
2 changes: 1 addition & 1 deletion weblate/utils/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __enter__(self):
self._depth += 1
if self._depth > 1:
return
with sentry_sdk.start_span(op="lock.wait", description=self._name):
with sentry_sdk.start_span(op="lock.wait", name=self._name):
self._enter_implementation()

def __exit__(self, exc_type, exc_value, traceback):
Expand Down
4 changes: 1 addition & 3 deletions weblate/utils/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,7 @@ def update_stats(self, update_parents: bool = True) -> None:
self.save(update_parents=update_parents)

def calculate_basic(self) -> None:
with sentry_sdk.start_span(
op="stats", description=f"CALCULATE {self.cache_key}"
):
with sentry_sdk.start_span(op="stats", name=f"CALCULATE {self.cache_key}"):
self.ensure_loaded()
self._calculate_basic()

Expand Down
2 changes: 1 addition & 1 deletion weblate/vcs/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ def request(
next_api_time = cache.get(cache_id)
now = time()
if next_api_time is not None and now < next_api_time:
with sentry_sdk.start_span(op="api_sleep", description=vcs_id):
with sentry_sdk.start_span(op="api_sleep", name=vcs_id):
sleep(next_api_time - now)
try:
response = requests.request(
Expand Down

0 comments on commit e23f390

Please sign in to comment.