зеркало из https://github.com/golang/tools.git
internal/telemetry: hide event.Type
Change-Id: I390102bbffaa242051cc131ef0659a6544aa89c6 Reviewed-on: https://go-review.googlesource.com/c/tools/+/224938 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
This commit is contained in:
Родитель
f207553f3c
Коммит
a49f79bcc2
|
@ -22,7 +22,7 @@ const (
|
|||
)
|
||||
|
||||
type Event struct {
|
||||
Type eventType
|
||||
typ eventType
|
||||
At time.Time
|
||||
Message string
|
||||
Error error
|
||||
|
@ -30,12 +30,12 @@ type Event struct {
|
|||
tags []Tag
|
||||
}
|
||||
|
||||
func (e Event) IsLog() bool { return e.Type == LogType }
|
||||
func (e Event) IsEndSpan() bool { return e.Type == EndSpanType }
|
||||
func (e Event) IsStartSpan() bool { return e.Type == StartSpanType }
|
||||
func (e Event) IsLabel() bool { return e.Type == LabelType }
|
||||
func (e Event) IsDetach() bool { return e.Type == DetachType }
|
||||
func (e Event) IsRecord() bool { return e.Type == RecordType }
|
||||
func (e Event) IsLog() bool { return e.typ == LogType }
|
||||
func (e Event) IsEndSpan() bool { return e.typ == EndSpanType }
|
||||
func (e Event) IsStartSpan() bool { return e.typ == StartSpanType }
|
||||
func (e Event) IsLabel() bool { return e.typ == LabelType }
|
||||
func (e Event) IsDetach() bool { return e.typ == DetachType }
|
||||
func (e Event) IsRecord() bool { return e.typ == RecordType }
|
||||
|
||||
func (e Event) Format(f fmt.State, r rune) {
|
||||
if !e.At.IsZero() {
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
// Label sends a label event to the exporter with the supplied tags.
|
||||
func Label(ctx context.Context, tags ...Tag) context.Context {
|
||||
return dispatch(ctx, Event{
|
||||
Type: LabelType,
|
||||
typ: LabelType,
|
||||
tags: tags,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
// Log sends a log event with the supplied tag list to the exporter.
|
||||
func Log(ctx context.Context, tags ...Tag) {
|
||||
dispatch(ctx, Event{
|
||||
Type: LogType,
|
||||
typ: LogType,
|
||||
tags: tags,
|
||||
})
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ func Log(ctx context.Context, tags ...Tag) {
|
|||
// before delivering them to the exporter.
|
||||
func Print(ctx context.Context, message string, tags ...Tag) {
|
||||
dispatch(ctx, Event{
|
||||
Type: LogType,
|
||||
typ: LogType,
|
||||
Message: message,
|
||||
tags: tags,
|
||||
})
|
||||
|
@ -36,7 +36,7 @@ func Error(ctx context.Context, message string, err error, tags ...Tag) {
|
|||
message = ""
|
||||
}
|
||||
dispatch(ctx, Event{
|
||||
Type: LogType,
|
||||
typ: LogType,
|
||||
Message: message,
|
||||
Error: err,
|
||||
tags: tags,
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
func Record(ctx context.Context, tags ...Tag) {
|
||||
dispatch(ctx, Event{
|
||||
Type: RecordType,
|
||||
typ: RecordType,
|
||||
tags: tags,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -10,19 +10,17 @@ import (
|
|||
|
||||
func StartSpan(ctx context.Context, name string, tags ...Tag) (context.Context, func()) {
|
||||
ctx = dispatch(ctx, Event{
|
||||
Type: StartSpanType,
|
||||
typ: StartSpanType,
|
||||
Message: name,
|
||||
tags: tags,
|
||||
})
|
||||
return ctx, func() {
|
||||
dispatch(ctx, Event{
|
||||
Type: EndSpanType,
|
||||
})
|
||||
dispatch(ctx, Event{typ: EndSpanType})
|
||||
}
|
||||
}
|
||||
|
||||
// Detach returns a context without an associated span.
|
||||
// This allows the creation of spans that are not children of the current span.
|
||||
func Detach(ctx context.Context) context.Context {
|
||||
return dispatch(ctx, Event{Type: DetachType})
|
||||
return dispatch(ctx, Event{typ: DetachType})
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче