-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtag_info.go
36 lines (30 loc) · 932 Bytes
/
tag_info.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
//+build ignore
//go:generate go get github.com/cheekybits/genny
//go:generate genny -in=$GOFILE -out=gen-$GOFILE gen "ElementType=uint,uint8,uint16,uint32,uint64,int,int8,int16,int32,int64,float32,float64,string"
package evaluation
import (
"errors"
"github.com/cheekybits/genny/generic"
"github.com/spf13/cast"
json "github.com/uber/jaeger/model/json"
)
type ElementType generic.Type
func getTagValueAsElementType(span json.Span, key string) (ElementType, error) {
var res ElementType
if isZero(span) {
return res, errors.New("nil span")
}
for _, tag := range span.Tags {
if tag.Key == key {
return cast.ToElementTypeE(tag.Value)
}
}
return res, errors.New("tag not found")
}
func mustGetTagValueAsElementType(span json.Span, key string) ElementType {
val, err := getTagValueAsElementType(span, key)
if err != nil {
log.WithError(err).WithField("key", key).Fatal("failed to get tag")
}
return val
}