Use structured logging for FetchFulfillment errors#3153
Merged
jonathangreen merged 1 commit intomainfrom Mar 18, 2026
Merged
Conversation
Replace the unstructured error message with palace_-prefixed extra fields so fulfillment failures are easier to query in CloudWatch. The response body is attempted as JSON first for deeper inspection, falling back to the raw string. Response headers are also included.
b776db8 to
c301e60
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3153 +/- ##
==========================================
- Coverage 93.26% 93.26% -0.01%
==========================================
Files 493 493
Lines 45581 45586 +5
Branches 6252 6252
==========================================
+ Hits 42513 42517 +4
- Misses 1982 1983 +1
Partials 1086 1086 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Replace the unstructured error log message in
FetchFulfillmentwith structuredpalace_-prefixed fields, making fulfillment failures much easier to query and aggregate in CloudWatch Logs Insights.Previously, the upstream response body, status code, and URL were all embedded in a single log message string, requiring
parseexpressions to extract in CloudWatch. Now they are emitted as separate structured fields:fulfillment_url— the upstream URL that failedfulfillment_status_code— the HTTP status code from upstreamfulfillment_response— the response body, parsed as a JSON object when possible, raw string otherwisefulfillment_headers— the full response headers as a dictThe human-readable log message still includes the URL and status code for quick scanning.
Motivation and Context
While investigating audiobook fulfillment failures reported via Crashlytics, we found that the existing log format made it difficult to query and aggregate errors in CloudWatch. Extracting the upstream response from the log message required fragile
parseexpressions, and the response body couldn't be inspected structurally when it was JSON (e.g., OPDS problem detail documents).How Has This Been Tested?
Checklist