Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed document issue and add more detail of span result for preview #32

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 106 additions & 4 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 @@ -40,7 +41,7 @@ func main() {
ctx := context.Background()

// enable tracing
ctx, root := minitrace.StartRootSpan(ctx, "root", 0, nil)
ctx, root := minitrace.StartRootSpan(ctx, "root", 10010, 0, nil)

root.AddProperty("k1", "v1")

Expand All @@ -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"
}
]
}
]
}
```
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.13
require (
github.com/opentracing/basictracer-go v1.1.0 // indirect
github.com/opentracing/opentracing-go v1.1.0
github.com/silentred/gid v1.0.0
github.com/tinylib/msgp v1.1.5
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ github.com/philhofer/fwd v1.1.1 h1:GdGcTjf5RNAxwS4QLsiMzJYj5KEvPJD3Abr261yRQXQ=
github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/silentred/gid v1.0.0 h1:JdsH8McqPUeY8IN4C0gxENnJG2zysvh+/xDJWhPvGVQ=
github.com/silentred/gid v1.0.0/go.mod h1:DMQPn66uY+3ed7rWfzOVET7VbDBAhjz+6AmmlixUK08=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
Expand Down