Documentation ¶
Overview ¶
Package trace contains a helper interface that allows various tracing tools to be plugged in to components using this interface. If no plugin is registered, the default one makes all trace calls into no-ops.
Index ¶
- func AddGrpcClientOptions(...)
- func AddGrpcServerOptions(...)
- func AnnotateSQL(span Span, strippedSQL fmt.Stringer)
- func CopySpan(parentCtx, spanCtx context.Context) context.Context
- func LogErrorsWhenClosing(in io.Closer) func()
- func NewContext(parent context.Context, span Span) context.Context
- func RegisterFlags(fs *pflag.FlagSet)
- func StartTracing(serviceName string) io.Closer
- type NoopSpan
- type Span
- type TracerFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddGrpcClientOptions ¶
func AddGrpcClientOptions(addInterceptors func(s grpc.StreamClientInterceptor, u grpc.UnaryClientInterceptor))
AddGrpcClientOptions adds GRPC interceptors that add parent information to outgoing grpc packets
func AddGrpcServerOptions ¶
func AddGrpcServerOptions(addInterceptors func(s grpc.StreamServerInterceptor, u grpc.UnaryServerInterceptor))
AddGrpcServerOptions adds GRPC interceptors that read the parent span from the grpc packets
func AnnotateSQL ¶
AnnotateSQL annotates information about a sql query in the span. This is done in a way so as to not leak personally identifying information (PII), or sensitive personal information (SPI)
func CopySpan ¶
CopySpan creates a new context from parentCtx, with only the trace span copied over from spanCtx, if it has any. If not, parentCtx is returned.
func LogErrorsWhenClosing ¶
LogErrorsWhenClosing will close the provided Closer, and log any errors it generates
func NewContext ¶
NewContext returns a context based on parent with a new Span value.
func RegisterFlags ¶ added in v0.15.0
func StartTracing ¶
StartTracing enables tracing for a named service
Types ¶
type Span ¶
type Span interface { Finish() // Annotate records a key/value pair associated with a Span. It should be // called between Start and Finish. Annotate(key string, value any) }
Span represents a unit of work within a trace. After creating a Span with NewSpan(), call one of the Start methods to mark the beginning of the work represented by this Span. Call Finish() when that work is done to record the Span. A Span may be reused by calling Start again.
func FromContext ¶
FromContext returns the Span from a Context if present. The bool return value indicates whether a Span was present in the Context.
func NewFromString ¶
NewFromString creates a new Span with the currently installed tracing plugin, extracting the span context from the provided string.