-
Notifications
You must be signed in to change notification settings - Fork 37
/
many.go
60 lines (48 loc) · 1.57 KB
/
many.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"time"
instana "github.com/instana/go-sensor"
ot "github.com/opentracing/opentracing-go"
ext "github.com/opentracing/opentracing-go/ext"
"github.com/opentracing/opentracing-go/log"
"golang.org/x/net/context"
)
const (
Service = "golang-many"
)
func simple(ctx context.Context) {
parentSpan, _ := ot.StartSpanFromContext(ctx, "parent")
parentSpan.SetTag(string(ext.Component), Service)
parentSpan.SetTag(string(ext.SpanKind), string(ext.SpanKindRPCServerEnum))
parentSpan.SetTag(string(ext.PeerHostname), "localhost")
parentSpan.SetTag(string(ext.HTTPUrl), "/golang/many/one")
parentSpan.SetTag(string(ext.HTTPMethod), "GET")
parentSpan.SetTag(string(ext.HTTPStatusCode), 200)
parentSpan.LogFields(log.String("foo", "bar"))
childSpan := ot.StartSpan("child", ot.ChildOf(parentSpan.Context()))
childSpan.SetTag(string(ext.SpanKind), string(ext.SpanKindRPCClientEnum))
childSpan.SetTag(string(ext.PeerHostname), "localhost")
childSpan.SetTag(string(ext.HTTPUrl), "/golang/many/two")
childSpan.SetTag(string(ext.HTTPMethod), "POST")
childSpan.SetTag(string(ext.HTTPStatusCode), 204)
childSpan.SetBaggageItem("someBaggage", "someValue")
time.Sleep(1 * time.Millisecond)
childSpan.Finish()
time.Sleep(2 * time.Millisecond)
parentSpan.Finish()
}
func main() {
ot.InitGlobalTracer(instana.NewTracerWithOptions(&instana.Options{
Service: Service,
ForceTransmissionStartingAt: 10000,
LogLevel: instana.Debug,
}))
go forever()
go forever()
select {}
}
func forever() {
for {
simple(context.Background())
}
}