Skip to content

Commit 8cd118a

Browse files
committed
Create execution boxes for consumer spans
1 parent 251b2d6 commit 8cd118a

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

src/atlas/domain/sequence_diagram.clj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
(defn- server-span? [{:keys [tags]}] (has-tag? "span.kind" "server" tags))
2525

26+
(defn- consumer-span? [{:keys [tags]}] (has-tag? "span.kind" "consumer" tags))
27+
2628
(defn- client-span? [{:keys [tags]}] (has-tag? "span.kind" "client" tags))
2729

2830
(defn- producer-span? [{:keys [tags]}] (has-tag? "span.kind" "producer" tags))
@@ -88,8 +90,9 @@
8890

8991
(s/defn execution-boxes :- [s-sequence-diagram/ExecutionBox]
9092
[trace :- s-jaeger/Trace]
91-
(let [server-spans (->> trace :spans (filter server-span?))]
92-
(map (span->execution-box trace) server-spans)))
93+
(let [server-spans (->> trace :spans (filter server-span?))
94+
consumer-spans (->> trace :spans (filter consumer-span?))]
95+
(map (span->execution-box trace) (concat server-spans consumer-spans))))
9396

9497
(s/defn arrows :- [s-sequence-diagram/Arrow]
9598
[trace :- s-jaeger/Trace]

test/atlas/domain/sequence_diagram_test.clj

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,21 @@
7171
:tags [{:key "span.kind"
7272
:type "string"
7373
:value "producer"}
74+
{:key "message_bus.destination"
75+
:type "string"
76+
:value "PROCESS_ORDER"}]}
77+
{:trace-id "1"
78+
:span-id "5"
79+
:process-id :p2
80+
:operation-name "kafka.in PROCESS_ORDER"
81+
:start-time 1500000000350000
82+
:duration 50
83+
:references [{:ref-type :child-of
84+
:trace-id "1"
85+
:span-id "4"}]
86+
:tags [{:key "span.kind"
87+
:type "string"
88+
:value "consumer"}
7489
{:key "message_bus.destination"
7590
:type "string"
7691
:value "PROCESS_ORDER"}]}]
@@ -104,6 +119,10 @@
104119
{:id "3"
105120
:start-time #epoch 1500000000200
106121
:duration-ms 100
122+
:lifeline "orders"}
123+
{:id "5"
124+
:start-time #epoch 1500000000350
125+
:duration-ms 50
107126
:lifeline "orders"}]
108127
(nut/execution-boxes trace)))))
109128

test/flows/get_sequence_diagram.clj

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,21 @@
7272
"tags" [{"key" "span.kind"
7373
"type" "string"
7474
"value" "producer"}
75+
{"key" "message_bus.destination"
76+
"type" "string"
77+
"value" "PROCESS_ORDER"}]}
78+
{"traceID" "1"
79+
"spanID" "5"
80+
"processID" "p2"
81+
"operationName" "kafka.in PROCESS_ORDER"
82+
"startTime" 1500000000350000
83+
"duration" 50
84+
"references" [{"ref-type" "CHILD_OF"
85+
"traceID" "1"
86+
"spanID" "4"}]
87+
"tags" [{"key" "span.kind"
88+
"type" "string"
89+
"value" "consumer"}
7590
{"key" "message_bus.destination"
7691
"type" "string"
7792
"value" "PROCESS_ORDER"}]}]
@@ -97,6 +112,10 @@
97112
{"id" "3"
98113
"start_time" 1500000000200
99114
"duration_ms" 100
115+
"lifeline" "orders"}
116+
{"id" "5"
117+
"start_time" 1500000000350
118+
"duration_ms" 50
100119
"lifeline" "orders"}]
101120
"arrows" [{"id" "2"
102121
"from" "bff"

0 commit comments

Comments
 (0)