trace

package module
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: MIT Imports: 6 Imported by: 0

README

Go Reference

Documentation

Index

Constants

View Source
const (
	CorrelationIDHeader        = "X-Correlation-Id"
	WorkflowIDHeader           = "X-Workflow-Id"
	CorrelationIDField         = "x_correlation_id"
	CorrelationIDMissing       = "x_correlation_id.missing"
	WorkflowIDField            = "x_workflow_id"
	WorkflowIDMissing          = "x_workflow_id.missing"
	SpanMissingTag             = "span.missing"
	StartIgnoredTag            = "start.ignored"
	ContextDeadlineTag         = "context_deadline"
	ContextDeadlineDurationTag = "context_deadline_duration"
	ContextDeadlineExistsTag   = "context_deadline_exists"
)

Variables

This section is empty.

Functions

func AddCorrelationTags

func AddCorrelationTags(span opentracing.Span, cor *Correlation)

AddCorrelationTags add Correlation related tags to the span. It will add Correlation-Id and Workflow-Id if they are exists or a related "*.missing" tag if they don't.

func Error

func Error(span opentracing.Span, err error)

Error marks the span as failed and set 'sampling.priority' to 1. Also collect the fields from the error and log them to the span, along with the error itself. The error will be logged under the 'error.object' tag.

func NewCorrelationID

func NewCorrelationID() string

NewCorrelationID generates a new correlation id consisting of 32 random hexadecimal characters.

func ValidateOption

func ValidateOption(t Option) error

func WithCorrelation

func WithCorrelation(ctx context.Context, c *Correlation) context.Context

WithCorrelation create a new context with the passed correlation in it. If the ctx parameter is nil, context.Background() used instead, but it's a good practice to never pass nil context, use context.Background() instead.

Types

type ContextMapper

type ContextMapper interface {
	Values(ctx context.Context) map[string]string
}

ContextMapper used to extract values from a context.

func Mapper

func Mapper() ContextMapper

Mapper returns a ContextMapper which will extract Correlation-Id and Workflow-Id from context.

type Correlation

type Correlation struct {
	CorrelationID string
	WorkflowID    string
}

func CorrelationFrom

func CorrelationFrom(ctx context.Context) *Correlation

CorrelationFrom returns the Correlation from context or an empty Correlation if not exists.

func NewCorrelation

func NewCorrelation() *Correlation

NewCorrelation returns a new Correlation object with generated CorrelationID and empty WorkflowID.

type Logger

type Logger interface {
	Error(ctx context.Context, msg string, keysAndValues ...interface{})
	Warn(ctx context.Context, msg string, keysAndValues ...interface{})
}

Logger is a simplified interface for logging, mainly used to decouple tracing from logging.

type Option

type Option uint8
const (
	// When parent trace not found, it will start a new root span, without any warning log.
	Start Option = iota
	// When parent trace not found, it will start a new root span and create warning log, that we don't found a parent.
	// This is the default behaviour.
	StartWithWarning
	// When parent trace not found, it won't start a root span and doesn't log any warning
	Ignore
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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