trace

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2019 License: Apache-2.0 Imports: 12 Imported by: 12

Documentation

Overview

Copyright 2017 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2017 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddGrpcClientOptions added in v1.7.0

func AddGrpcClientOptions(addInterceptors func(s grpc.StreamClientInterceptor, u grpc.UnaryClientInterceptor))

func AddGrpcServerOptions added in v1.7.0

func AddGrpcServerOptions(addInterceptors func(s grpc.StreamServerInterceptor, u grpc.UnaryServerInterceptor))

func AnnotateSQL added in v1.7.0

func AnnotateSQL(span Span, sql string)

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

func CopySpan(parentCtx, spanCtx context.Context) context.Context

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 added in v1.7.0

func LogErrorsWhenClosing(in io.Closer) func()

LogErrorsWhenClosing will close the provided Closer, and log any errors it generates

func NewContext

func NewContext(parent context.Context, span Span) context.Context

NewContext returns a context based on parent with a new Span value.

func StartTracing added in v1.7.0

func StartTracing(serviceName string) io.Closer

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 interface{})
}

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

func FromContext(ctx context.Context) (Span, bool)

FromContext returns the Span from a Context if present. The bool return value indicates whether a Span was present in the Context.

func NewSpan

func NewSpan(inCtx context.Context, label string) (Span, context.Context)

NewSpan creates a new Span with the currently installed tracing plugin. If no tracing plugin is installed, it returns a fake Span that does nothing.

type TracerFactory added in v1.7.0

type TracerFactory func(serviceName string) (tracingService, io.Closer, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL