You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+90-38Lines changed: 90 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -110,13 +110,15 @@ class StripePaymentService
110
110
111
111
**What it does:** Monitors critical operations with automatic start/end logging, exception-specific handling, DB transactions, circuit breakers, and true escalation for uncaught exceptions.
112
112
113
+
**Note:** The second parameter `$origin` (usually `$this`) is optional and automatically provides origin context to the structured logger used by the controlled block, eliminating the need for a separate `->from()` call.
Circuit breakers prevent cascading failures by temporarily stopping requests to a failing service, allowing it time to recover. They automatically "open" after a threshold of failures and "close" once the service is healthy again, protecting your application from wasting resources on operations likely to fail.
-**Auto-Recovery**: Circuits automatically close when services recover
231
+
232
+
**Response Headers When Circuit is Open:**
233
+
```
234
+
HTTP/1.1 503 Service Unavailable
235
+
Retry-After: 45
236
+
X-Circuit-Breaker: payment_gateway
237
+
X-Circuit-Breaker-Status: open
238
+
```
239
+
240
+
The `Retry-After` header includes intelligent jitter - instead of all clients retrying at the exact same time, it provides a random delay between 0 and the remaining decay time, preventing overwhelming the recovering service.
241
+
190
242
#### **Tracing & Logging**
191
243
192
244
```php
193
-
->overrideTraceId('custom-trace-12345')
194
-
->from('PaymentService') // Custom logger origin
245
+
Monitor::controlled('payment_processing', $this)
246
+
->overrideTraceId('custom-trace-12345')
247
+
// Origin is automatically set from the second parameter ($this)
0 commit comments