forked from pinpoint-apm/pinpoint-go-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tracer.go
97 lines (80 loc) · 2.29 KB
/
tracer.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package pinpoint
import (
"fmt"
"time"
)
type TransactionId struct {
AgentId string
StartTime int64
Sequence int64
}
func (tid TransactionId) String() string {
return fmt.Sprintf("%s^%d^%d", tid.AgentId, tid.StartTime, tid.Sequence)
}
type Tracer interface {
NewSpanEvent(operationName string) Tracer
NewAsyncSpan() Tracer
EndSpan()
EndSpanEvent()
Inject(writer DistributedTracingContextWriter)
Extract(reader DistributedTracingContextReader)
TransactionId() TransactionId
SpanId() int64
Span() SpanRecorder
SpanEvent() SpanEventRecorder
}
type SpanRecorder interface {
SetApiId(id int32)
SetServiceType(typ int32)
SetError(e error)
SetRpcName(rpc string)
SetRemoteAddress(remoteAddress string)
SetEndPoint(endPoint string)
SetAcceptorHost(host string)
Annotations() Annotation
SetLogging(logInfo int32)
}
type SpanEventRecorder interface {
SetApiId(id int32)
SetServiceType(typ int32)
SetDestination(id string)
SetEndPoint(endPoint string)
SetError(e error)
SetSQL(sql string)
Annotations() Annotation
FixDuration(start time.Time, end time.Time)
}
type Annotation interface {
AppendInt(key int32, i int32)
AppendString(key int32, s string)
AppendStringString(key int32, s1 string, s2 string)
AppendIntStringString(key int32, i int32, s1 string, s2 string)
AppendLongIntIntByteByteString(key int32, l int64, i1 int32, i2 int32, b1 int32, b2 int32, s string)
}
type DistributedTracingContextReader interface {
Get(key string) string
}
type DistributedTracingContextWriter interface {
Set(key string, value string)
}
const (
HttpTraceId = "Pinpoint-TraceID"
HttpSpanId = "Pinpoint-SpanID"
HttpParentSpanId = "Pinpoint-pSpanID"
HttpSampled = "Pinpoint-Sampled"
HttpFlags = "Pinpoint-Flags"
HttpParentApplicationName = "Pinpoint-pAppName"
HttpParentApplicationType = "Pinpoint-pAppType"
HttpParentApplicationNamespace = "Pinpoint-pAppNamespace"
HttpHost = "Pinpoint-Host"
LogTransactionIdKey = "PtxId"
LogSpanIdKey = "PspanId"
Logged = 1
NotLogged = 0
ServiceTypeGoApp = 1800
ServiceTypeGoFunction = 1801
ServiceTypeGoHttpClient = 9401
ApiTypeWebRequest = 100
ApiTypeInvocation = 200
MaxAgentIdLength = 23
)