tracing

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2021 License: BSD-3-Clause Imports: 2 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, txn Transaction) context.Context

NewContext associates the transaction with the provided context. FromContext can then be used to retrieve the transaction.

Types

type Arg

type Arg struct {
	Name  string
	Value interface{}
}

An Arg represents a name-value pair.

type Provider

type Provider interface {
	// StartTransaction starts a new Transaction with the provided name and
	// arguments.
	StartTransaction(name string, args ...Arg) Transaction

	// StartWebTransaction starts a new web Transaction with the provided name
	// and arguments.
	StartWebTransaction(
		name string,
		w http.ResponseWriter,
		r *http.Request,
		args ...Arg,
	) (Transaction, http.ResponseWriter, *http.Request)

	// WrapHandle is a convenience function for wrapping an http.Handler and
	// adding all necessary tracing information.
	WrapHandle(pattern string, handler http.Handler) (string, http.Handler)
}

Provider is the interface that can create Transactions.

func NewNoOpProvider

func NewNoOpProvider() Provider

NewNoOpProvider returns a new provider that does nothing.

type Segment

type Segment interface {
	// End marks the segment as finished.
	End()
}

A Segment is a part of a transaction used to instrument functions, methods, and blocks of code.

type Transaction

type Transaction interface {
	// SetName sets the current transaction's name.
	SetName(name string)

	// AddAttributes adds any attributes after the transaction was created.
	AddAttributes(args ...Arg)

	// StartSegment creates a new Segment inside the transaction.
	StartSegment(name string) Segment

	// NoticeError associates an error with the transaction.
	NoticeError(err error)

	// End marks the transaction as finished.
	End()
}

A Transaction represents one logical unit of work: either an inbound web request or background task.

func FromContext

func FromContext(ctx context.Context) Transaction

FromContext returns the current Transaction associated with the Context.

func NewNoOpTransaction

func NewNoOpTransaction() Transaction

NewNoOpTransaction returns a Transaction that does nothing. Useful for tests.

Jump to

Keyboard shortcuts

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