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
{{ message }}
Repository navigation
Commit bde0c89
Browse filesBrowse the repository at this point in the historyBrowse files
|**`flowchart`**| Visualizing processes or logic flows. |**Newest engine**: Supports subgraphs, better styling, and more shapes. | Use `flowchart TD` or `flowchart LR`. |
14
+
|**`graph`**| Legacy version of the flowchart. | Older engine with fewer features and more rigid layouts. | Often used interchangeably but lacks `flowchart`'s flexibility. |
15
+
|**`stateDiagram-v2`**| Modeling system behavior/states. |**UML-compliant**: Focuses on "States" and "Transitions." | Uses `[*] ->` for start/end points. |
13
16
14
-
section Cache
15
-
cache.get :a2, 5, 15
17
+
## flowchart LR
16
18
17
-
section Database
18
-
db.query orders :a3, 20, 80
19
+
```text
20
+
flowchart LR
21
+
subgraph correct[Correct: 1-100 spans]
22
+
B1[batch.process] --> E1[item.failed event]
23
+
B1 --> E2[item.failed event]
24
+
B1 --> A1[batch.successful: 9998]
25
+
end
19
26
20
-
section Enrichment
21
-
enrichOrder :a4, 85, 140
22
-
http.get /customers/456 :a5, 90, 120
23
-
http.get /products/789 :a6, 90, 110
27
+
subgraph wrong[Wrong: 10,000 spans]
28
+
I1[process.item] --> I2[process.item]
29
+
I2 --> I3[process.item]
30
+
I3 --> I4[...9,997 more...]
31
+
end
32
+
33
+
style correct fill:#9f9,color:#000
34
+
style wrong fill:#f96,color:#000
24
35
```
25
-
Figure: Readable trace waterfall with clear hierarchy.
26
36
27
37
```mermaid
38
+
flowchart LR
39
+
subgraph correct[Correct: 1-100 spans]
40
+
B1[batch.process] --> E1[item.failed event]
41
+
B1 --> E2[item.failed event]
42
+
B1 --> A1[batch.successful: 9998]
43
+
end
44
+
45
+
subgraph wrong[Wrong: 10,000 spans]
46
+
I1[process.item] --> I2[process.item]
47
+
I2 --> I3[process.item]
48
+
I3 --> I4[...9,997 more...]
49
+
end
50
+
51
+
style correct fill:#9f9,color:#000
52
+
style wrong fill:#f96,color:#000
53
+
```
54
+
55
+
## flowchart TD
56
+
57
+
```text
28
58
flowchart TD
29
59
A[Incoming Request] --> B{Head Sampling?}
30
60
@@ -46,42 +76,87 @@ flowchart TD
46
76
style H fill:#f96,color:#000
47
77
style G fill:#9f9,color:#000
48
78
```
49
-
Figure: Head sampling reduces overhead; tail sampling preserves interesting traces.
50
79
51
80
```mermaid
52
-
gantt
53
-
title Trace Waterfall (over-instrumented)
54
-
dateFormat X
55
-
axisFormat %L ms
81
+
flowchart TD
82
+
A[Incoming Request] --> B{Head Sampling?}
56
83
57
-
section Request
58
-
HTTP GET /orders/123 :a1, 0, 150
84
+
B -->|Yes| C[Create Spans]
85
+
B -->|No| D[No Spans Created]
59
86
60
-
section Validation
61
-
validate.request :a2, 2, 5
62
-
parse.json :a3, 5, 8
63
-
validate.orderId :a4, 8, 10
87
+
C --> E[Export to Collector]
88
+
E --> F{Tail Sampling?}
64
89
65
-
section Cache
66
-
cache.get :a5, 10, 12
67
-
serialize.key :a6, 10, 11
68
-
redis.get :a7, 11, 12
69
-
deserialize.result :a8, 12, 13
90
+
F -->|Error?| G[Keep]
91
+
F -->|Slow?| G
92
+
F -->|High-value?| G
93
+
F -->|Random 5%| G
94
+
F -->|Otherwise| H[Drop]
70
95
71
-
section Database
72
-
db.getConnection :a9, 15, 18
73
-
db.query orders :a10, 18, 75
74
-
db.releaseConnection :a11, 75, 77
75
-
map.toEntity :a12, 77, 79
96
+
G --> I[Storage Backend]
76
97
77
-
section Response
78
-
serialize.json :a13, 140, 145
79
-
set.headers :a14, 145, 147
80
-
send.response :a15, 147, 150
98
+
style D fill:#f96,color:#000
99
+
style H fill:#f96,color:#000
100
+
style G fill:#9f9,color:#000
101
+
```
102
+
103
+
## graph TD
104
+
105
+
```text
106
+
graph TD
107
+
subgraph CP[Control Plane]
108
+
A[API Server] --> B[State Store]
109
+
A --> C[Controllers]
110
+
end
111
+
112
+
D[Isolation Boundary]
113
+
114
+
subgraph DP[Data Plane]
115
+
F[Worker Node 1]
116
+
G[Worker Node 2]
117
+
H[Worker Node 3]
118
+
end
119
+
120
+
C -->|"Desired State"| D
121
+
D --> F
122
+
D --> G
123
+
D --> H
124
+
125
+
F -->|"Actual State"| D
126
+
G -->|"Actual State"| D
127
+
H -->|"Actual State"| D
128
+
D --> C
81
129
```
82
-
Figure: Over-instrumented trace—wall of spans obscures the critical path.
83
130
84
131
```mermaid
132
+
graph TD
133
+
subgraph CP[Control Plane]
134
+
A[API Server] --> B[State Store]
135
+
A --> C[Controllers]
136
+
end
137
+
138
+
D[Isolation Boundary]
139
+
140
+
subgraph DP[Data Plane]
141
+
F[Worker Node 1]
142
+
G[Worker Node 2]
143
+
H[Worker Node 3]
144
+
end
145
+
146
+
C -->|"Desired State"| D
147
+
D --> F
148
+
D --> G
149
+
D --> H
150
+
151
+
F -->|"Actual State"| D
152
+
G -->|"Actual State"| D
153
+
H -->|"Actual State"| D
154
+
D --> C
155
+
```
156
+
157
+
## sequenceDiagram
158
+
159
+
```text
85
160
sequenceDiagram
86
161
participant Client
87
162
participant API as API Service
@@ -108,51 +183,154 @@ sequenceDiagram
108
183
API-->>Client: Enriched order
109
184
Note over API: Root span ends
110
185
```
111
-
Figure: Request instrumentation sequence.
112
186
113
187
```mermaid
114
-
flowchart LR
115
-
subgraph correct[Correct: 1-100 spans]
116
-
B1[batch.process] --> E1[item.failed event]
117
-
B1 --> E2[item.failed event]
118
-
B1 --> A1[batch.successful: 9998]
119
-
end
188
+
sequenceDiagram
189
+
participant Client
190
+
participant API as API Service
191
+
participant Cache
192
+
participant DB as Database
193
+
participant Customers as Customers Service
120
194
121
-
subgraph wrong[Wrong: 10,000 spans]
122
-
I1[process.item] --> I2[process.item]
123
-
I2 --> I3[process.item]
124
-
I3 --> I4[...9,997 more...]
125
-
end
195
+
Client->>API: GET /orders/123
196
+
Note over API: Root span: HTTP GET /orders/{id}
126
197
127
-
style correct fill:#9f9,color:#000
128
-
style wrong fill:#f96,color:#000
198
+
API->>Cache: Get order:123
199
+
Note over API: Child span: cache.get
200
+
Cache-->>API: Miss
201
+
202
+
API->>DB: SELECT * FROM orders
203
+
Note over API: Child span: db.query orders
204
+
DB-->>API: Order data
205
+
206
+
API->>Customers: GET /customers/456
207
+
Note over API: Child span: HTTP GET customers-service
208
+
Note over Customers: Continues trace
209
+
Customers-->>API: Customer data
210
+
211
+
API-->>Client: Enriched order
212
+
Note over API: Root span ends
129
213
```
130
-
Figure: Batch instrumentation approaches—events vs spans.
0 commit comments