本文整理汇总了Golang中org/apache/htrace/common.Span.Duration方法的典型用法代码示例。如果您正苦于以下问题:Golang Span.Duration方法的具体用法?Golang Span.Duration怎么用?Golang Span.Duration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org/apache/htrace/common.Span
的用法示例。
在下文中一共展示了Span.Duration方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: DeleteSpan
// Delete a span from the shard. Note that leveldb may retain the data until
// compaction(s) remove it.
func (shd *shard) DeleteSpan(span *common.Span) error {
batch := levigo.NewWriteBatch()
defer batch.Close()
primaryKey :=
append([]byte{SPAN_ID_INDEX_PREFIX}, span.Id.Val()...)
batch.Delete(primaryKey)
for parentIdx := range span.Parents {
key := append(append([]byte{PARENT_ID_INDEX_PREFIX},
span.Parents[parentIdx].Val()...), span.Id.Val()...)
batch.Delete(key)
}
beginTimeKey := append(append([]byte{BEGIN_TIME_INDEX_PREFIX},
u64toSlice(s2u64(span.Begin))...), span.Id.Val()...)
batch.Delete(beginTimeKey)
endTimeKey := append(append([]byte{END_TIME_INDEX_PREFIX},
u64toSlice(s2u64(span.End))...), span.Id.Val()...)
batch.Delete(endTimeKey)
durationKey := append(append([]byte{DURATION_INDEX_PREFIX},
u64toSlice(s2u64(span.Duration()))...), span.Id.Val()...)
batch.Delete(durationKey)
err := shd.ldb.Write(shd.store.writeOpts, batch)
if err != nil {
return err
}
return nil
}
示例2: extractRelevantSpanData
// Get the values that this predicate cares about for a given span.
func (pred *predicateData) extractRelevantSpanData(span *common.Span) []byte {
switch pred.Field {
case common.SPAN_ID:
return span.Id.Val()
case common.DESCRIPTION:
return []byte(span.Description)
case common.BEGIN_TIME:
return u64toSlice(s2u64(span.Begin))
case common.END_TIME:
return u64toSlice(s2u64(span.End))
case common.DURATION:
return u64toSlice(s2u64(span.Duration()))
case common.TRACER_ID:
return []byte(span.TracerId)
default:
panic(fmt.Sprintf("Unknown field type %s.", pred.Field))
}
}
示例3: writeSpan
func (shd *shard) writeSpan(span *common.Span) error {
batch := levigo.NewWriteBatch()
defer batch.Close()
// Add SpanData to batch.
spanDataBuf := new(bytes.Buffer)
spanDataEnc := gob.NewEncoder(spanDataBuf)
err := spanDataEnc.Encode(span.SpanData)
if err != nil {
return err
}
primaryKey :=
append([]byte{SPAN_ID_INDEX_PREFIX}, span.Id.Val()...)
batch.Put(primaryKey, spanDataBuf.Bytes())
// Add this to the parent index.
for parentIdx := range span.Parents {
key := append(append([]byte{PARENT_ID_INDEX_PREFIX},
span.Parents[parentIdx].Val()...), span.Id.Val()...)
batch.Put(key, EMPTY_BYTE_BUF)
}
// Add to the other secondary indices.
beginTimeKey := append(append([]byte{BEGIN_TIME_INDEX_PREFIX},
u64toSlice(s2u64(span.Begin))...), span.Id.Val()...)
batch.Put(beginTimeKey, EMPTY_BYTE_BUF)
endTimeKey := append(append([]byte{END_TIME_INDEX_PREFIX},
u64toSlice(s2u64(span.End))...), span.Id.Val()...)
batch.Put(endTimeKey, EMPTY_BYTE_BUF)
durationKey := append(append([]byte{DURATION_INDEX_PREFIX},
u64toSlice(s2u64(span.Duration()))...), span.Id.Val()...)
batch.Put(durationKey, EMPTY_BYTE_BUF)
err = shd.ldb.Write(shd.store.writeOpts, batch)
if err != nil {
return err
}
shd.store.stats.IncrementWrittenSpans()
if shd.store.WrittenSpans != nil {
shd.store.WrittenSpans <- span
}
return nil
}