mirror of
https://github.com/golang/go
synced 2024-11-19 02:34:44 -07:00
38 lines
722 B
Go
38 lines
722 B
Go
|
// Copyright 2019 The Go Authors. All rights reserved.
|
||
|
// Use of this source code is governed by a BSD-style
|
||
|
// license that can be found in the LICENSE file.
|
||
|
|
||
|
package telemetry
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
type SpanContext struct {
|
||
|
TraceID TraceID
|
||
|
SpanID SpanID
|
||
|
}
|
||
|
|
||
|
type Span struct {
|
||
|
Name string
|
||
|
ID SpanContext
|
||
|
ParentID SpanID
|
||
|
Start time.Time
|
||
|
Finish time.Time
|
||
|
Tags TagList
|
||
|
Events []Event
|
||
|
}
|
||
|
|
||
|
func (s *SpanContext) Format(f fmt.State, r rune) {
|
||
|
fmt.Fprintf(f, "%v:%v", s.TraceID, s.SpanID)
|
||
|
}
|
||
|
|
||
|
func (s *Span) Format(f fmt.State, r rune) {
|
||
|
fmt.Fprintf(f, "%v %v", s.Name, s.ID)
|
||
|
if s.ParentID.IsValid() {
|
||
|
fmt.Fprintf(f, "[%v]", s.ParentID)
|
||
|
}
|
||
|
fmt.Fprintf(f, " %v->%v", s.Start, s.Finish)
|
||
|
}
|