Skip to content

Commit

Permalink
Add error metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-codecov committed Nov 22, 2023
1 parent 12e1795 commit 3de8687
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions services/ai_pr_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from shared.torngit.base import TokenType, TorngitBaseAdapter

from database.models.core import Repository
from helpers.metrics import metrics
from services.archive import ArchiveService
from services.repository import get_repo_provider_service

Expand Down Expand Up @@ -263,6 +264,7 @@ async def perform(self) -> Optional[int]:
try:
data = json.loads(res)
except json.decoder.JSONDecodeError:
metrics.incr("ai_pr_review.non_json_completion")
log.error(

Check warning on line 268 in services/ai_pr_review.py

View check run for this annotation

Codecov - Staging / codecov/patch

services/ai_pr_review.py#L266-L268

Added lines #L266 - L268 were not covered by tests

Check warning on line 268 in services/ai_pr_review.py

View check run for this annotation

Codecov - QA / codecov/patch

services/ai_pr_review.py#L266-L268

Added lines #L266 - L268 were not covered by tests

Check warning on line 268 in services/ai_pr_review.py

View check run for this annotation

Codecov / codecov/patch

services/ai_pr_review.py#L266-L268

Added lines #L266 - L268 were not covered by tests
"OpenAI completion was expected to be JSON but wasn't",
extra=dict(res=res),
Expand All @@ -281,6 +283,7 @@ async def perform(self) -> Optional[int]:
},
)
except KeyError:
metrics.incr("ai_pr_review.malformed_completion")
log.error(

Check warning on line 287 in services/ai_pr_review.py

View check run for this annotation

Codecov - Staging / codecov/patch

services/ai_pr_review.py#L285-L287

Added lines #L285 - L287 were not covered by tests

Check warning on line 287 in services/ai_pr_review.py

View check run for this annotation

Codecov - QA / codecov/patch

services/ai_pr_review.py#L285-L287

Added lines #L285 - L287 were not covered by tests

Check warning on line 287 in services/ai_pr_review.py

View check run for this annotation

Codecov / codecov/patch

services/ai_pr_review.py#L285-L287

Added lines #L285 - L287 were not covered by tests
"OpenAI completion JSON was not formed as expected",
extra=dict(data=data),
Expand Down

0 comments on commit 3de8687

Please sign in to comment.