tracing

package
v0.0.0-...-9518a5e Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package tracing provides common functions for attaching values to trace spans

Index

Constants

View Source
const (
	// Jaeger represents the popular distributed tracing server.
	Jaeger = "jaeger"
)

Variables

This section is empty.

Functions

func AttachAPIClientClientIDToSpan

func AttachAPIClientClientIDToSpan(span trace.Span, clientID string)

AttachAPIClientClientIDToSpan is a consistent way to attach an API client's ID to a span.

func AttachAPIClientDatabaseIDToSpan

func AttachAPIClientDatabaseIDToSpan(span trace.Span, clientID string)

AttachAPIClientDatabaseIDToSpan is a consistent way to attach an API client's database row ID to a span.

func AttachAccountIDToSpan

func AttachAccountIDToSpan(span trace.Span, accountID string)

AttachAccountIDToSpan provides a consistent way to attach an account's ID to a span.

func AttachActiveAccountIDToSpan

func AttachActiveAccountIDToSpan(span trace.Span, accountID string)

AttachActiveAccountIDToSpan provides a consistent way to attach an account's ID to a span.

func AttachDatabaseQueryToSpan

func AttachDatabaseQueryToSpan(span trace.Span, queryDescription, query string, args []interface{})

AttachDatabaseQueryToSpan attaches a given search query to a span.

func AttachErrorToSpan

func AttachErrorToSpan(span trace.Span, description string, err error)

AttachErrorToSpan attaches a given error to a span.

func AttachFilterToSpan

func AttachFilterToSpan(span trace.Span, page uint64, limit uint8, sortBy string)

AttachFilterToSpan provides a consistent way to attach a filter's info to a span.

func AttachItemIDToSpan

func AttachItemIDToSpan(span trace.Span, itemID string)

AttachItemIDToSpan attaches an item ID to a given span.

func AttachQueryFilterToSpan

func AttachQueryFilterToSpan(span trace.Span, filter *types.QueryFilter)

AttachQueryFilterToSpan attaches a given query filter to a span.

func AttachRequestToSpan

func AttachRequestToSpan(span trace.Span, req *http.Request)

AttachRequestToSpan attaches a given *http.Request to a span.

func AttachRequestURIToSpan

func AttachRequestURIToSpan(span trace.Span, uri string)

AttachRequestURIToSpan attaches a given URI to a span.

func AttachRequestingUserIDToSpan

func AttachRequestingUserIDToSpan(span trace.Span, userID string)

AttachRequestingUserIDToSpan provides a consistent way to attach a user's ID to a span.

func AttachResponseToSpan

func AttachResponseToSpan(span trace.Span, res *http.Response)

AttachResponseToSpan attaches a given *http.Response to a span.

func AttachSearchQueryToSpan

func AttachSearchQueryToSpan(span trace.Span, query string)

AttachSearchQueryToSpan attaches a given search query to a span.

func AttachSessionContextDataToSpan

func AttachSessionContextDataToSpan(span trace.Span, sessionCtxData *types.SessionContextData)

AttachSessionContextDataToSpan provides a consistent way to attach a SessionContextData object to a span.

func AttachToSpan

func AttachToSpan(span trace.Span, key string, val interface{})

AttachToSpan allows a user to attach any value to a span.

func AttachURLToSpan

func AttachURLToSpan(span trace.Span, u *url.URL)

AttachURLToSpan attaches a given URI to a span.

func AttachUserAgentDataToSpan

func AttachUserAgentDataToSpan(span trace.Span, ua *useragent.UserAgent)

AttachUserAgentDataToSpan attaches a given search query to a span.

func AttachUserIDToSpan

func AttachUserIDToSpan(span trace.Span, userID string)

AttachUserIDToSpan provides a consistent way to attach a user's ID to a span.

func AttachUserToSpan

func AttachUserToSpan(span trace.Span, user *types.User)

AttachUserToSpan provides a consistent way to attach a user to a span.

func AttachUsernameToSpan

func AttachUsernameToSpan(span trace.Span, username string)

AttachUsernameToSpan provides a consistent way to attach a user's username to a span.

func AttachWebhookIDToSpan

func AttachWebhookIDToSpan(span trace.Span, webhookID string)

AttachWebhookIDToSpan provides a consistent way to attach a webhook's ID to a span.

func BuildTracedHTTPTransport

func BuildTracedHTTPTransport(timeout time.Duration) http.RoundTripper

BuildTracedHTTPTransport constructs a new http.Transport.

func FormatSpan

func FormatSpan(operation string, req *http.Request) string

FormatSpan formats a span.

func GetCallerName

func GetCallerName() string

GetCallerName is largely (and respectfully) inspired by/copied from https://stackoverflow.com/a/35213181

func NewInstrumentedSQLLogger

func NewInstrumentedSQLLogger(logger logging.Logger) instrumentedsql.Logger

NewInstrumentedSQLLogger wraps a logging.Logger for instrumentedsql.

func NewInstrumentedSQLTracer

func NewInstrumentedSQLTracer(name string) instrumentedsql.Tracer

NewInstrumentedSQLTracer wraps a Tracer for instrumentedsql.

func StartCustomSpan

func StartCustomSpan(ctx context.Context, name string) (context.Context, trace.Span)

StartCustomSpan starts an anonymous custom span.

func StartSpan

func StartSpan(ctx context.Context) (context.Context, trace.Span)

StartSpan starts an anonymous span.

Types

type Config

type Config struct {

	// Jaeger configures the Jaeger tracer.
	Jaeger   *JaegerConfig `json:"jaeger" mapstructure:"jaeger" toml:"jaeger,omitempty"`
	Provider string        `json:"provider" mapstructure:"provider" toml:"provider,omitempty"`
	// SpanCollectionProbability indicates the probability that a collected span will be reported.
	SpanCollectionProbability float64 `json:"span_collection_probability" mapstructure:"span_collection_probability" toml:"span_collection_probability,omitempty"`
	// contains filtered or unexported fields
}

Config contains settings related to tracing.

func (*Config) Initialize

func (c *Config) Initialize(l logging.Logger) (flushFunc func(), err error)

Initialize provides an instrumentation handler.

func (*Config) SetupJaeger

func (c *Config) SetupJaeger() (func(), error)

SetupJaeger creates a new trace provider instance and registers it as global trace provider.

func (*Config) ValidateWithContext

func (c *Config) ValidateWithContext(ctx context.Context) error

ValidateWithContext validates the config struct.

type JaegerConfig

type JaegerConfig struct {
	CollectorEndpoint string `json:"collector_endpoint" mapstructure:"collector_endpoint" toml:"collector_endpoint,omitempty"`
	ServiceName       string `json:"service_name" mapstructure:"service_name" toml:"service_name,omitempty"`
	// contains filtered or unexported fields
}

JaegerConfig contains settings related to tracing with Jaeger.

func (*JaegerConfig) ValidateWithContext

func (c *JaegerConfig) ValidateWithContext(ctx context.Context) error

ValidateWithContext validates the config struct.

type Span

type Span trace.Span

Span is a simple alias for the OpenTelemetry span interface.

type Tracer

type Tracer interface {
	StartSpan(ctx context.Context) (context.Context, Span)
	StartCustomSpan(ctx context.Context, name string) (context.Context, Span)
}

Tracer describes a tracer.

func NewTracer

func NewTracer(name string) Tracer

NewTracer creates a Tracer.

Jump to

Keyboard shortcuts

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