go-micro: github.com/micro/go-micro/debug/trace Index | Files | Directories

package trace

import "github.com/micro/go-micro/debug/trace"

Package trace provides an interface for distributed tracing


Package Files

options.go trace.go


const (
    // DefaultSize of the buffer
    DefaultSize = 64

func FromContext Uses

func FromContext(ctx context.Context) (traceID string, parentSpanID string, isFound bool)

FromContext returns a span from context

func ToContext Uses

func ToContext(ctx context.Context, traceID, parentSpanID string) context.Context

ToContext saves the trace and span ids in the context

type Option Uses

type Option func(o *Options)

type Options Uses

type Options struct {
    // Size is the size of ring buffer
    Size int

func DefaultOptions Uses

func DefaultOptions() Options

DefaultOptions returns default options

type ReadOption Uses

type ReadOption func(o *ReadOptions)

func ReadTrace Uses

func ReadTrace(t string) ReadOption

Read the given trace

type ReadOptions Uses

type ReadOptions struct {
    // Trace id
    Trace string

type Span Uses

type Span struct {
    // Id of the trace
    Trace string
    // name of the span
    Name string
    // id of the span
    Id  string
    // parent span id
    Parent string
    // Start time
    Started time.Time
    // Duration in nano seconds
    Duration time.Duration
    // associated data
    Metadata map[string]string
    // Type
    Type SpanType

Span is used to record an entry

type SpanType Uses

type SpanType int

SpanType describe the nature of the trace span

const (
    // SpanTypeRequestInbound is a span created when serving a request
    SpanTypeRequestInbound SpanType = iota
    // SpanTypeRequestOutbound is a span created when making a service call

type Tracer Uses

type Tracer interface {
    // Start a trace
    Start(ctx context.Context, name string) (context.Context, *Span)
    // Finish the trace
    Finish(*Span) error
    // Read the traces
    Read(...ReadOption) ([]*Span, error)

Tracer is an interface for distributed tracing

var (
    DefaultTracer Tracer = new(noop)



Package trace imports 3 packages (graph) and is imported by 4 packages. Updated 2020-02-18. Refresh now. Tools for package owners.