Skip to content

Commit

Permalink
make telemetry helper resilient to exceptions (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-codecov authored May 16, 2024
1 parent 90cdb7b commit d1327d5
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions helpers/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,22 @@ def log_simple_metric(self, name: str, value: float):
# Timezone-aware timestamp in UTC
timestamp = django.utils.timezone.now()

self.populate()

PgSimpleMetric.objects.create(
timestamp=timestamp,
name=name,
value=value,
repo_id=self.repo_id,
owner_id=self.owner_id,
commit_id=self.commit_id,
)
try:
self.populate()
except Exception:
log.exception("Failed to populate metric context")

try:
PgSimpleMetric.objects.create(
timestamp=timestamp,
name=name,
value=value,
repo_id=self.repo_id,
owner_id=self.owner_id,
commit_id=self.commit_id,
)
except Exception:
log.exception("Failed to create telemetry_simple record")

@fire_and_forget
async def attempt_log_simple_metric(self, name: str, value: float):
Expand Down

0 comments on commit d1327d5

Please sign in to comment.