mirror of
https://github.com/golang/go
synced 2024-11-06 03:26:15 -07:00
d780ff7bdd
This is now the only package that is exposed to normal use, and should be the only thing to appear in libraries. Change-Id: I90ee47c6519f30db16ff5d5d2910be86e91e5df2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/222557 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
35 lines
784 B
Go
35 lines
784 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 event
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
func StartSpan(ctx context.Context, name string, tags ...Tag) (context.Context, func()) {
|
|
ctx = ProcessEvent(ctx, Event{
|
|
Type: StartSpanType,
|
|
Message: name,
|
|
At: time.Now(),
|
|
Tags: tags,
|
|
})
|
|
return ctx, func() {
|
|
ProcessEvent(ctx, Event{
|
|
Type: EndSpanType,
|
|
At: time.Now(),
|
|
})
|
|
}
|
|
}
|
|
|
|
// 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 ProcessEvent(ctx, Event{
|
|
Type: DetachType,
|
|
At: time.Now(),
|
|
})
|
|
}
|