本文整理汇总了Golang中org/apache/htrace/common.SpanId.Val方法的典型用法代码示例。如果您正苦于以下问题:Golang SpanId.Val方法的具体用法?Golang SpanId.Val怎么用?Golang SpanId.Val使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org/apache/htrace/common.SpanId
的用法示例。
在下文中一共展示了SpanId.Val方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: loadPredicateData
func loadPredicateData(pred *common.Predicate) (*predicateData, error) {
p := predicateData{Predicate: pred}
// Parse the input value given to make sure it matches up with the field
// type.
switch pred.Field {
case common.SPAN_ID:
// Span IDs are sent as hex strings.
var id common.SpanId
if err := id.FromString(pred.Val); err != nil {
return nil, errors.New(fmt.Sprintf("Unable to parse span id '%s': %s",
pred.Val, err.Error()))
}
p.key = id.Val()
break
case common.DESCRIPTION:
// Any string is valid for a description.
p.key = []byte(pred.Val)
break
case common.BEGIN_TIME, common.END_TIME, common.DURATION:
// Parse a base-10 signed numeric field.
v, err := strconv.ParseInt(pred.Val, 10, 64)
if err != nil {
return nil, errors.New(fmt.Sprintf("Unable to parse %s '%s': %s",
pred.Field, pred.Val, err.Error()))
}
p.key = u64toSlice(s2u64(v))
break
case common.TRACER_ID:
// Any string is valid for a tracer ID.
p.key = []byte(pred.Val)
break
default:
return nil, errors.New(fmt.Sprintf("Unknown field %s", pred.Field))
}
// Validate the predicate operation.
switch pred.Op {
case common.EQUALS, common.LESS_THAN_OR_EQUALS,
common.GREATER_THAN_OR_EQUALS, common.GREATER_THAN:
break
case common.CONTAINS:
if p.fieldIsNumeric() {
return nil, errors.New(fmt.Sprintf("Can't use CONTAINS on a "+
"numeric field like '%s'", pred.Field))
}
default:
return nil, errors.New(fmt.Sprintf("Unknown predicate operation '%s'",
pred.Op))
}
return &p, nil
}
示例2: FindSpan
func (shd *shard) FindSpan(sid common.SpanId) *common.Span {
lg := shd.store.lg
primaryKey := append([]byte{SPAN_ID_INDEX_PREFIX}, sid.Val()...)
buf, err := shd.ldb.Get(shd.store.readOpts, primaryKey)
if err != nil {
if strings.Index(err.Error(), "NotFound:") != -1 {
return nil
}
lg.Warnf("Shard(%s): FindSpan(%s) error: %s\n",
shd.path, sid.String(), err.Error())
return nil
}
var span *common.Span
span, err = shd.decodeSpan(sid, buf)
if err != nil {
lg.Errorf("Shard(%s): FindSpan(%s) decode error: %s\n",
shd.path, sid.String(), err.Error())
return nil
}
return span
}
示例3: FindChildren
func (shd *shard) FindChildren(sid common.SpanId, childIds []common.SpanId,
lim int32) ([]common.SpanId, int32, error) {
searchKey := append([]byte{PARENT_ID_INDEX_PREFIX}, sid.Val()...)
iter := shd.ldb.NewIterator(shd.store.readOpts)
defer iter.Close()
iter.Seek(searchKey)
for {
if !iter.Valid() {
break
}
if lim == 0 {
break
}
key := iter.Key()
if !bytes.HasPrefix(key, searchKey) {
break
}
id := common.SpanId(key[17:])
childIds = append(childIds, id)
lim--
iter.Next()
}
return childIds, lim, nil
}