Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ dependencies = [
"mmh3>=4.0.0",
"msgspec>=0.19.0",
"msgpack>=1.1.0",
"objectstore-client>=0.1.1",
"objectstore-client>=0.1.5",
"openai>=1.3.5",
"orjson>=3.10.10",
"p4python>=2025.1.2767466",
Expand Down
31 changes: 27 additions & 4 deletions src/sentry/lang/native/symbolicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,21 @@ def __init__(
self.project = project
self.event_id = event_id

def _process(self, task_name: str, path: str, **kwargs):
def _process(
self,
task_name: str,
path: str,
kwargs_cb: Callable[[], dict[str, Any]] | None = None,
**kwargs: Any,
) -> Any:
"""
This function will submit a symbolication task to a Symbolicator and handle
polling it using the `SymbolicatorSession`.
It will also correctly handle `TaskIdNotFound` and `ServiceUnavailable` errors.

`kwargs_cb`, if provided, is called on every new task submission and its result
is merged over `kwargs`. Use this for values that must be fresh on each
(re)submission, such as expiring tokens.
"""
session = SymbolicatorSession(
url=self.base_url,
Expand All @@ -137,7 +147,8 @@ def _process(self, task_name: str, path: str, **kwargs):
try:
if not task_id:
# We are submitting a new task to Symbolicator
json_response = session.create_task(path, **kwargs)
create_kwargs = {**kwargs, **(kwargs_cb() if kwargs_cb else {})}
json_response = session.create_task(path, **create_kwargs)
else:
# The task has already been submitted to Symbolicator and we are polling
json_response = session.query_task(task_id)
Expand Down Expand Up @@ -201,7 +212,12 @@ def process_minidump(
"rewrite_first_module": rewrite_first_module,
},
}
res = self._process("process_minidump", "symbolicate-any", json=json)

def cb() -> dict[str, Any]:
json["symbolicate"]["storage_token"] = session.mint_token()
return {"json": json}

res = self._process("process_minidump", "symbolicate-any", kwargs_cb=cb)
return process_response(res)

data = {
Expand All @@ -223,6 +239,7 @@ def process_applecrashreport(self, platform: str, report: CachedAttachment):
if report.stored_id:
session = get_attachments_session(self.project.organization_id, self.project.id)
storage_url = get_symbolicator_url(session, report.stored_id)
storage_token = session.mint_token()
json: dict[str, Any] = {
"platform": platform,
"sources": sources,
Expand All @@ -231,9 +248,15 @@ def process_applecrashreport(self, platform: str, report: CachedAttachment):
"symbolicate": {
"type": "applecrashreport",
"storage_url": storage_url,
"storage_token": storage_token,
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
},
}
res = self._process("process_applecrashreport", "symbolicate-any", json=json)

def cb() -> dict[str, Any]:
json["symbolicate"]["storage_token"] = session.mint_token()
return {"json": json}

res = self._process("process_applecrashreport", "symbolicate-any", kwargs_cb=cb)
return process_response(res)

data = {
Expand Down
6 changes: 3 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading