Skip to content

Commit

Permalink
Add span content for preview result before use.
Browse files Browse the repository at this point in the history
Signed-off-by: helloworlde <hellowoodes@gmail.com>
  • Loading branch information
helloworlde committed Sep 6, 2022
1 parent 1bb176f commit 1627aa7
Showing 1 changed file with 105 additions and 3 deletions.
108 changes: 105 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ package main

import (
"context"
"fmt"
"encoding/json"
"fmt"
"strconv"

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

// do something with `spans`
fmt.Printf("%+v", spans)
// print `spans` content in JSON format
spanContent, _ := json.MarshalIndent(spans, "", " ")
fmt.Println(string(spanContent))
}
```

The output of spans in JSON format like this:

```json
{
"TraceID": 10010,
"Spans": [
{
"ID": 15352856648520921629,
"ParentID": 8674665223082153551,
"BeginUnixTimeNs": 1662446668306972169,
"DurationNs": 87,
"Event": "2",
"Properties": null
},
{
"ID": 13260572831089785859,
"ParentID": 8674665223082153551,
"BeginUnixTimeNs": 1662446668306973148,
"DurationNs": 61,
"Event": "3",
"Properties": null
},
{
"ID": 3916589616287113937,
"ParentID": 8674665223082153551,
"BeginUnixTimeNs": 1662446668306979536,
"DurationNs": 63,
"Event": "4",
"Properties": null
},
{
"ID": 6334824724549167320,
"ParentID": 8674665223082153551,
"BeginUnixTimeNs": 1662446668306983182,
"DurationNs": 63,
"Event": "5",
"Properties": null
},
{
"ID": 9828766684487745566,
"ParentID": 8674665223082153551,
"BeginUnixTimeNs": 1662446668306983484,
"DurationNs": 59,
"Event": "6",
"Properties": null
},
{
"ID": 10667007354186551956,
"ParentID": 8674665223082153551,
"BeginUnixTimeNs": 1662446668306987321,
"DurationNs": 61,
"Event": "7",
"Properties": null
},
{
"ID": 894385949183117216,
"ParentID": 8674665223082153551,
"BeginUnixTimeNs": 1662446668306987618,
"DurationNs": 61,
"Event": "8",
"Properties": null
},
{
"ID": 11998794077335055257,
"ParentID": 8674665223082153551,
"BeginUnixTimeNs": 1662446668306987898,
"DurationNs": 60,
"Event": "9",
"Properties": null
},
{
"ID": 8674665223082153551,
"ParentID": 5577006791947779410,
"BeginUnixTimeNs": 1662446668306967492,
"DurationNs": 20570,
"Event": "1",
"Properties": [
{
"Key": "k2",
"Value": "v2"
}
]
},
{
"ID": 5577006791947779410,
"ParentID": 0,
"BeginUnixTimeNs": 1662446668306966615,
"DurationNs": 24319,
"Event": "root",
"Properties": [
{
"Key": "k1",
"Value": "v1"
}
]
}
]
}
```

0 comments on commit 1627aa7

Please sign in to comment.