-
Notifications
You must be signed in to change notification settings - Fork 965
/
handle_agent_udp.go
39 lines (36 loc) · 1 KB
/
handle_agent_udp.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
package service
import (
"fmt"
"github.com/imdevlab/g"
"github.com/imdevlab/tracing/proto/pinpoint/thrift"
"github.com/imdevlab/tracing/proto/pinpoint/thrift/pinpoint"
"github.com/imdevlab/tracing/proto/pinpoint/thrift/trace"
"github.com/imdevlab/tracing/util"
"go.uber.org/zap"
)
func handleAgentUDP(data []byte) (*util.SpanDataModel, error) {
spanModel := util.NewSpanDataModel()
tStruct := thrift.Deserialize(data)
switch m := tStruct.(type) {
case *trace.TSpan:
spanModel.Type = util.TypeOfTSpan
spanModel.Spans = data
break
case *trace.TSpanChunk:
spanModel.Type = util.TypeOfTSpanChunk
spanModel.Spans = data
break
case *pinpoint.TAgentStat:
spanModel.Type = util.TypeOfTAgentStat
spanModel.Spans = data
break
case *pinpoint.TAgentStatBatch:
spanModel.Type = util.TypeOfTAgentStatBatch
spanModel.Spans = data
break
default:
g.L.Warn("unknown type", zap.String("type", fmt.Sprintf("unknow type %t", m)))
return nil, fmt.Errorf("unknow type %t", m)
}
return spanModel, nil
}