-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTraceable.php
More file actions
67 lines (63 loc) · 2.02 KB
/
Traceable.php
File metadata and controls
67 lines (63 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
declare(strict_types=1);
namespace ComplexHeart\Domain\Contracts\Events;
/**
* Interface Traceable
*
* Extends events with distributed tracing capabilities.
* Use when you need to trace event flows across microservices.
*
* Enables:
* - Distributed tracing across services
* - Event chain reconstruction
* - Root cause analysis
* - APM tool integration (Datadog, New Relic, Zipkin)
*
* @author Unay Santisteban <usantisteban@othercode.io>
*/
interface Traceable
{
/**
* The correlation ID that traces the entire request/workflow.
*
* The same correlation ID flows through all services and events
* in a single business transaction, enabling end-to-end tracing.
*
* Example flow:
* - HTTP Request (correlationId: abc-123)
* - OrderPlaced event (correlationId: abc-123)
* - PaymentRequested event (correlationId: abc-123)
* - PaymentProcessed event (correlationId: abc-123)
*
* Use cases:
* - Distributed tracing across microservices
* - Debugging async workflows
* - APM tools integration
* - Request flow visualization
*
* @return string UUID or custom trace ID
*/
public function correlationId(): string;
/**
* The causation ID - the immediate parent event that caused this event.
*
* Forms a causal chain showing parent-child relationships between events.
* Each event's causationId points to the eventId of its immediate parent.
*
* Example chain:
* - OrderPlaced (eventId: ev-001, causationId: null)
* ↓
* - PaymentRequested (eventId: ev-002, causationId: ev-001)
* ↓
* - PaymentProcessed (eventId: ev-003, causationId: ev-002)
*
* Use cases:
* - Event chain reconstruction
* - Root cause analysis (trace back to origin)
* - Understanding event dependencies
* - Building event graphs and visualizations
*
* @return string Event ID of the parent event that triggered this event
*/
public function causationId(): string;
}