本文整理汇总了Golang中golang.org/x/net/trace.Trace.SetMaxEvents方法的典型用法代码示例。如果您正苦于以下问题:Golang Trace.SetMaxEvents方法的具体用法?Golang Trace.SetMaxEvents怎么用?Golang Trace.SetMaxEvents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类golang.org/x/net/trace.Trace
的用法示例。
在下文中一共展示了Trace.SetMaxEvents方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: netTraceIntegrator
// netTraceIntegrator is passed into basictracer as NewSpanEventListener
// and causes all traces to be registered with the net/trace endpoint.
func netTraceIntegrator() func(basictracer.SpanEvent) {
var tr trace.Trace
return func(e basictracer.SpanEvent) {
switch t := e.(type) {
case basictracer.EventCreate:
tr = trace.New("tracing", t.OperationName)
tr.SetMaxEvents(maxLogsPerSpan)
case basictracer.EventFinish:
tr.Finish()
case basictracer.EventTag:
tr.LazyPrintf("%s:%v", t.Key, t.Value)
case basictracer.EventLogFields:
// TODO(radu): when LightStep supports arbitrary fields, we should make
// the formatting of the message consistent with that. Until then we treat
// legacy events that just have an "event" key specially.
if len(t.Fields) == 1 && t.Fields[0].Key() == "event" {
tr.LazyPrintf("%s", t.Fields[0].Value())
} else {
var buf bytes.Buffer
for i, f := range t.Fields {
if i > 0 {
buf.WriteByte(' ')
}
fmt.Fprintf(&buf, "%s:%v", f.Key(), f.Value())
}
tr.LazyPrintf("%s", buf.String())
}
case basictracer.EventLog:
panic("EventLog is deprecated")
}
}
}
示例2: netTraceIntegrator
// netTraceIntegrator is passed into basictracer as NewSpanEventListener
// and causes all traces to be registered with the net/trace endpoint.
func netTraceIntegrator() func(basictracer.SpanEvent) {
var tr trace.Trace
return func(e basictracer.SpanEvent) {
switch t := e.(type) {
case basictracer.EventCreate:
tr = trace.New("tracing", t.OperationName)
tr.SetMaxEvents(maxLogsPerSpan)
case basictracer.EventFinish:
tr.Finish()
case basictracer.EventTag:
tr.LazyPrintf("%s:%v", t.Key, t.Value)
case basictracer.EventLogFields:
var buf bytes.Buffer
for i, f := range t.Fields {
if i > 0 {
buf.WriteByte(' ')
}
fmt.Fprintf(&buf, "%s:%v", f.Key(), f.Value())
}
tr.LazyPrintf("%s", buf.String())
case basictracer.EventLog:
if t.Payload != nil {
tr.LazyPrintf("%s (payload %v)", t.Event, t.Payload)
} else {
tr.LazyPrintf("%s", t.Event)
}
}
}
}