Esempio n. 1
0
func (self *RemoteMsgTracer) TracePub(topic string, traceID uint64, msg *Message, diskOffset BackendOffset, currentCnt int64) {
	now := time.Now().UnixNano()
	detail := flume_log.NewDetailInfo(traceModule)
	var traceItem [1]TraceLogItemInfo
	traceItem[0].MsgID = uint64(msg.ID)
	traceItem[0].TraceID = msg.TraceID
	traceItem[0].Topic = topic
	traceItem[0].Timestamp = now
	traceItem[0].Action = "PUB"
	detail.SetExtraInfo(traceItem[:])

	l := fmt.Sprintf("[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, now)
	err := self.remoteLogger.Info(l, detail)
	if err != nil || nsqLog.Level() >= levellogger.LOG_DEBUG {
		if err != nil {
			nsqLog.Warningf("send log to remote error: %v", err)
		}
		self.localTracer.TracePub(topic, traceID, msg, diskOffset, currentCnt)
	}
}
Esempio n. 2
0
func (self *RemoteMsgTracer) TraceSub(topic string, channel string, state string, traceID uint64, msg *Message, clientID string) {
	now := time.Now().UnixNano()
	var traceItem [1]TraceLogItemInfo
	traceItem[0].MsgID = uint64(msg.ID)
	traceItem[0].TraceID = msg.TraceID
	traceItem[0].Topic = topic
	traceItem[0].Channel = channel
	traceItem[0].Timestamp = now
	traceItem[0].Action = state
	detail := flume_log.NewDetailInfo(traceModule)
	detail.SetExtraInfo(traceItem[:])

	l := fmt.Sprintf("[TRACE] topic %v channel %v trace id %v: message %v (offset: %v) consume state %v from client %v at time: %v, attempt: %v",
		topic, channel, msg.TraceID, msg.ID, msg.offset, state, clientID, time.Now().UnixNano(), msg.Attempts)
	err := self.remoteLogger.Info(l, detail)
	if err != nil || nsqLog.Level() >= levellogger.LOG_DEBUG {
		if err != nil {
			nsqLog.Warningf("send log to remote error: %v", err)
		}
		self.localTracer.TraceSub(topic, channel, state, traceID, msg, clientID)
	}
}