Skip to content

Commit

Permalink
chore(issues): trace all the things in the occurence_consumer (#74382)
Browse files Browse the repository at this point in the history
Adding more instrumentation for INC-811 debugging.
  • Loading branch information
Bartek Ogryczak authored Jul 16, 2024
1 parent f412d2d commit e0935e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/sentry/issues/occurrence_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class EventLookupError(Exception):
pass


@sentry_sdk.tracing.trace
def save_event_from_occurrence(
data: dict[str, Any],
**kwargs: Any,
Expand All @@ -59,6 +60,7 @@ def save_event_from_occurrence(
return event


@sentry_sdk.tracing.trace
def lookup_event(project_id: int, event_id: str) -> Event:
data = nodestore.backend.get(Event.generate_node_id(project_id, event_id))
if data is None:
Expand All @@ -68,6 +70,7 @@ def lookup_event(project_id: int, event_id: str) -> Event:
return event


@sentry_sdk.tracing.trace
def create_event(project_id: int, event_id: str, event_data: dict[str, Any]) -> Event:
return Event(
event_id=event_id,
Expand All @@ -85,6 +88,7 @@ def create_event(project_id: int, event_id: str, event_data: dict[str, Any]) ->
)


@sentry_sdk.tracing.trace
def create_event_and_issue_occurrence(
occurrence_data: IssueOccurrenceData, event_data: dict[str, Any]
) -> tuple[IssueOccurrence, GroupInfo | None]:
Expand All @@ -108,6 +112,7 @@ def create_event_and_issue_occurrence(
return save_issue_occurrence(occurrence_data, event)


@sentry_sdk.tracing.trace
def process_event_and_issue_occurrence(
occurrence_data: IssueOccurrenceData, event_data: dict[str, Any]
) -> tuple[IssueOccurrence, GroupInfo | None]:
Expand All @@ -124,6 +129,7 @@ def process_event_and_issue_occurrence(
return save_issue_occurrence(occurrence_data, event)


@sentry_sdk.tracing.trace
def lookup_event_and_process_issue_occurrence(
occurrence_data: IssueOccurrenceData,
) -> tuple[IssueOccurrence, GroupInfo | None]:
Expand All @@ -141,6 +147,7 @@ def lookup_event_and_process_issue_occurrence(
return save_issue_occurrence(occurrence_data, event)


@sentry_sdk.tracing.trace
def _get_kwargs(payload: Mapping[str, Any]) -> Mapping[str, Any]:
"""
Processes the incoming message payload into a format we can use.
Expand Down Expand Up @@ -276,6 +283,7 @@ def _get_kwargs(payload: Mapping[str, Any]) -> Mapping[str, Any]:
raise InvalidEventPayloadError(e)


@sentry_sdk.tracing.trace
@metrics.wraps("occurrence_consumer.process_occurrence_message")
def process_occurrence_message(
message: Mapping[str, Any], txn: Transaction | NoOpSpan | Span
Expand Down Expand Up @@ -331,6 +339,7 @@ def process_occurrence_message(
return lookup_event_and_process_issue_occurrence(kwargs["occurrence_data"])


@sentry_sdk.tracing.trace
@metrics.wraps("occurrence_consumer.process_message")
def _process_message(
message: Mapping[str, Any]
Expand Down Expand Up @@ -367,6 +376,7 @@ def _process_message(
return None


@sentry_sdk.tracing.trace
@metrics.wraps("occurrence_consumer.process_batch")
def _process_batch(worker: ThreadPoolExecutor, message: Message[ValuesBatch[KafkaPayload]]) -> None:
"""
Expand Down
1 change: 1 addition & 0 deletions src/sentry/nodestore/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def get_bytes(self, id: str) -> bytes | None:
def _get_bytes(self, id: str) -> bytes | None:
raise NotImplementedError

@metrics.wraps("nodestore.get.duration")
def get(self, id: str, subkey: str | None = None) -> Any:
"""
>>> nodestore.get('key1')
Expand Down

0 comments on commit e0935e3

Please sign in to comment.