Skip to content

Commit

Permalink
Merge pull request #47 from edanalytics/feature/structured_log_succes…
Browse files Browse the repository at this point in the history
…ses_by_status_code

This adds a successes section to the structured log results file to report how many payloads resulted in a 200, 201, etc.
  • Loading branch information
tomreitz authored Jul 18, 2024
2 parents 0ac1535 + af042f1 commit c89b64c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,12 @@ A sample results file could be:
"count": 14
}
],
"successes": [
{
"status_code": 201,
"count": 28
}
],
"records_processed": 50,
"records_skipped": 0,
"records_failed": 22
Expand Down
7 changes: 7 additions & 0 deletions lightbeam/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ async def do_send(self, endpoint):
hashlog.save(hashlog_file, self.hashlog_data)

# update metadata counts for this endpoint
statuses = self.lightbeam.status_counts.keys()
successes = []
for status in statuses:
if status>=200 and status<300:
successes.append({"status_code": status, "count": self.lightbeam.status_counts[status]})
if len(successes)>0:
self.metadata["resources"][endpoint].update({"successes": successes})
self.metadata["resources"][endpoint].update({
"records_processed": total_counter,
"records_skipped": self.lightbeam.num_skipped,
Expand Down

0 comments on commit c89b64c

Please sign in to comment.