trace

package
v0.0.0-...-284234c Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2016 License: Apache-2.0 Imports: 10 Imported by: 0

README

Trace - Tracing interface

Provides a pluggable distributed tracing interface

type Trace interface {
	// New span with certain fields preset.
	// Provide parent span if you have it.
	NewSpan(*Span) *Span
	// New context with span
	NewContext(context.Context, *Span) context.Context
	// Return a span from context
	FromContext(context.Context) (*Span, bool)
	// Span to Header
	NewHeader(map[string]string, *Span) map[string]string
	// Get span from header
	FromHeader(map[string]string) (*Span, bool)

	// Collect spans
	Collect(*Span) error
	// Start the collector
	Start() error
	// Stop the collector
	Stop() error
}

Supported

  • Platform
  • Zipkin
  • ?

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultBatchSize     = 100
	DefaultBatchInterval = time.Second * 5

	TraceTopic   = "micro.trace.span"
	TraceHeader  = "X-Micro-Trace-Id"
	SpanHeader   = "X-Micro-Span-Id"
	ParentHeader = "X-Micro-Parent-Id"
	DebugHeader  = "X-Micro-Trace-Debug"
)

Functions

func ClientWrapper

func ClientWrapper(t Trace, s *registry.Service) client.Wrapper

func HandlerWrapper

func HandlerWrapper(t Trace, s *registry.Service) server.HandlerWrapper

func NewContext

func NewContext(ctx context.Context, c Trace) context.Context

Types

type Annotation

type Annotation struct {
	Timestamp time.Time // Microseconds from epoch
	Type      AnnotationType
	Key       string
	Value     []byte
	Debug     map[string]string
	Service   *registry.Service // Annotator
}

type AnnotationType

type AnnotationType int32
const (
	AnnUnknown            AnnotationType = 0
	AnnStart              AnnotationType = 1
	AnnEnd                AnnotationType = 2
	AnnTimeout            AnnotationType = 3
	AnnClientRequest      AnnotationType = 4
	AnnClientResponse     AnnotationType = 5
	AnnClientPublication  AnnotationType = 6
	AnnServerRequest      AnnotationType = 7
	AnnServerResponse     AnnotationType = 8
	AnnServerSubscription AnnotationType = 9
)

type Option

type Option func(o *Options)

func BatchInterval

func BatchInterval(b time.Duration) Option

func BatchSize

func BatchSize(b int) Option

func Client

func Client(c client.Client) Option

func CollectTimeout

func CollectTimeout(t time.Duration) Option

func Collectors

func Collectors(c []string) Option

func Service

func Service(s *registry.Service) Option

func Topic

func Topic(t string) Option

type Options

type Options struct {
	BatchSize      int
	BatchInterval  time.Duration
	CollectTimeout time.Duration
	Collectors     []string
	Topic          string

	Client  client.Client
	Service *registry.Service
}

type Span

type Span struct {
	Name      string        // Topic / RPC Method
	Id        string        // id of this span
	TraceId   string        // The root trace id
	ParentId  string        // Parent span id
	Timestamp time.Time     // Microseconds from epoch. When span started.
	Duration  time.Duration // Microseconds. Duration of the span.
	Debug     bool          // Should persist no matter what.

	Source      *registry.Service // Originating service
	Destination *registry.Service // Destination service

	sync.Mutex
	Annotations []*Annotation
}

type Trace

type Trace interface {
	// New span with certain fields preset.
	// Provide parent span if you have it.
	NewSpan(*Span) *Span
	// New context with span
	NewContext(context.Context, *Span) context.Context
	// Return a span from context
	FromContext(context.Context) (*Span, bool)
	// Span to Header
	NewHeader(map[string]string, *Span) map[string]string
	// Get span from header
	FromHeader(map[string]string) (*Span, bool)

	// Collect spans
	Collect(*Span) error
	// Start the collector
	Start() error
	// Stop the collector
	Stop() error
	// Name
	String() string
}

func FromContext

func FromContext(ctx context.Context) (Trace, bool)

func NewTrace

func NewTrace(opts ...Option) Trace

Directories

Path Synopsis
Package go_micro_platform_trace is a generated protocol buffer package.
Package go_micro_platform_trace is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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