-
Notifications
You must be signed in to change notification settings - Fork 105
/
tracer.go
48 lines (37 loc) · 1.52 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
package nsqd
import (
"time"
)
type IMsgTracer interface {
Start()
TracePub(topic string, traceID uint64, msg *Message, diskOffset BackendOffset, currentCnt int64)
// state will be READ_QUEUE, Start, Req, Fin, Timeout
TraceSub(topic string, state string, traceID uint64, msg *Message, clientID string)
}
var nsqMsgTracer = &LogMsgTracer{}
// just print the trace log
type LogMsgTracer struct {
MID string
}
func (self *LogMsgTracer) Start() {
}
func (self *LogMsgTracer) TracePub(topic string, traceID uint64, msg *Message, diskOffset BackendOffset, currentCnt int64) {
nsqLog.Logf("[TRACE] topic %v trace id %v: message %v put at offset: %v, current count: %v at time %v", topic, msg.TraceID,
msg.ID, diskOffset, currentCnt, time.Now().UnixNano())
}
func (self *LogMsgTracer) TraceSub(topic string, state string, traceID uint64, msg *Message, clientID string) {
nsqLog.Logf("[TRACE] topic %v trace id %v: message %v (offset: %v) consume state %v from client %v at time: %v, attempt: %v", topic, msg.TraceID,
msg.ID, msg.offset, state, clientID, time.Now().UnixNano(), msg.Attempts)
}
// this tracer will send the trace info to remote server for each seconds
type RemoteMsgTracer struct {
// local machine id
MID string
remoteAddr string
}
func (self *RemoteMsgTracer) Start() {
}
func (self *RemoteMsgTracer) TracePub(topic string, traceID uint64, msg *Message, diskOffset BackendOffset, currentCnt int64) {
}
func (self *RemoteMsgTracer) TraceSub(topic string, state string, traceID uint64, msg *Message, clientID string) {
}