tracing

package
v3.3.7 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2022 License: BSD-3-Clause Imports: 3 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 any
}

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 {
	// WithMetadata wraps the logger with the transaction metadata.
	WithMetadata(log logging.Logger) logging.Logger

	// 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)

	// InsertDistributedTraceHeaders links transactions by adding Distributed
	// Trace headers into the headers so that a child transaction can accept
	// them.
	InsertDistributedTraceHeaders(h http.Header)

	// AcceptDistributedTraceHeaders links transactions by accepting Distributed
	// Trace headers from the parent transaction.
	AcceptDistributedTraceHeaders(t TransportType, h http.Header)

	// 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.

type TransportType added in v3.2.5

type TransportType string

TransportType is used in Transaction.AcceptDistributedTraceHeaders to represent the type of connection that the trace payload was transported over.

const (
	// TransportQueue represents that the transaction was performed over a queue.
	TransportQueue TransportType = "Queue"
)

Jump to

Keyboard shortcuts

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