trace

package
v0.0.0-...-335d32b Latest Latest
Warning

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

Go to latest
Published: May 29, 2018 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package trace provides functions for configuring custom trace identifiers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(ctx context.Context) string

Get returns the trace identifier from ctx, or an empty string if none is present.

func With

func With(parent context.Context, t string) context.Context

With returns a new context derived from parent that includes an application-defined "trace ID" value.

Any operations (such as command calls, session notifications, etc) that use the returned context will include the trace ID in log output on both the sending and receiving peer.

The trace ID is also present in the ctx supplied to command and notification handlers. This allows very easy propagation of the trace identifier to all "sub-requests" of the initial operation.

The trace ID is rendered surrounded by square brackets in log output.

If an operation is performed with ctx that does not contain a trace ID, the operation's message ID is used. This includes sufficient information to identify the peer, session and revision of the initial operation.

func WithRoot

func WithRoot(parent context.Context, t string) (ctx context.Context, id string, ok bool)

WithRoot returns a new context derived from parent that includes an application-defined "trace ID" value, only if the parent does not already contain such a trace ID.

If parent already contains a trace ID, ctx is parent, id is the trace ID from parent and ok is false. Otherwise, ctx is the derived context containing t as the trace ID, id is t and ok is true.

Types

This section is empty.

Jump to

Keyboard shortcuts

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