Skip to content

Commit 1627aa7

Browse files
committed
Add span content for preview result before use.
Signed-off-by: helloworlde <hellowoodes@gmail.com>
1 parent 1bb176f commit 1627aa7

File tree

1 file changed

+105
-3
lines changed

1 file changed

+105
-3
lines changed

README.md

Lines changed: 105 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ package main
1111

1212
import (
1313
"context"
14-
"fmt"
14+
"encoding/json"
15+
"fmt"
1516
"strconv"
1617

1718
"github.com/tikv/minitrace-go"
@@ -50,7 +51,108 @@ func main() {
5051
// collect tracing results into `spans`
5152
spans, _ := root.Collect()
5253

53-
// do something with `spans`
54-
fmt.Printf("%+v", spans)
54+
// print `spans` content in JSON format
55+
spanContent, _ := json.MarshalIndent(spans, "", " ")
56+
fmt.Println(string(spanContent))
57+
}
58+
```
59+
60+
The output of spans in JSON format like this:
61+
62+
```json
63+
{
64+
"TraceID": 10010,
65+
"Spans": [
66+
{
67+
"ID": 15352856648520921629,
68+
"ParentID": 8674665223082153551,
69+
"BeginUnixTimeNs": 1662446668306972169,
70+
"DurationNs": 87,
71+
"Event": "2",
72+
"Properties": null
73+
},
74+
{
75+
"ID": 13260572831089785859,
76+
"ParentID": 8674665223082153551,
77+
"BeginUnixTimeNs": 1662446668306973148,
78+
"DurationNs": 61,
79+
"Event": "3",
80+
"Properties": null
81+
},
82+
{
83+
"ID": 3916589616287113937,
84+
"ParentID": 8674665223082153551,
85+
"BeginUnixTimeNs": 1662446668306979536,
86+
"DurationNs": 63,
87+
"Event": "4",
88+
"Properties": null
89+
},
90+
{
91+
"ID": 6334824724549167320,
92+
"ParentID": 8674665223082153551,
93+
"BeginUnixTimeNs": 1662446668306983182,
94+
"DurationNs": 63,
95+
"Event": "5",
96+
"Properties": null
97+
},
98+
{
99+
"ID": 9828766684487745566,
100+
"ParentID": 8674665223082153551,
101+
"BeginUnixTimeNs": 1662446668306983484,
102+
"DurationNs": 59,
103+
"Event": "6",
104+
"Properties": null
105+
},
106+
{
107+
"ID": 10667007354186551956,
108+
"ParentID": 8674665223082153551,
109+
"BeginUnixTimeNs": 1662446668306987321,
110+
"DurationNs": 61,
111+
"Event": "7",
112+
"Properties": null
113+
},
114+
{
115+
"ID": 894385949183117216,
116+
"ParentID": 8674665223082153551,
117+
"BeginUnixTimeNs": 1662446668306987618,
118+
"DurationNs": 61,
119+
"Event": "8",
120+
"Properties": null
121+
},
122+
{
123+
"ID": 11998794077335055257,
124+
"ParentID": 8674665223082153551,
125+
"BeginUnixTimeNs": 1662446668306987898,
126+
"DurationNs": 60,
127+
"Event": "9",
128+
"Properties": null
129+
},
130+
{
131+
"ID": 8674665223082153551,
132+
"ParentID": 5577006791947779410,
133+
"BeginUnixTimeNs": 1662446668306967492,
134+
"DurationNs": 20570,
135+
"Event": "1",
136+
"Properties": [
137+
{
138+
"Key": "k2",
139+
"Value": "v2"
140+
}
141+
]
142+
},
143+
{
144+
"ID": 5577006791947779410,
145+
"ParentID": 0,
146+
"BeginUnixTimeNs": 1662446668306966615,
147+
"DurationNs": 24319,
148+
"Event": "root",
149+
"Properties": [
150+
{
151+
"Key": "k1",
152+
"Value": "v1"
153+
}
154+
]
155+
}
156+
]
55157
}
56158
```

0 commit comments

Comments
 (0)