model

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package model describes the internal data model for Trace and Span

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DurationAsMicroseconds

func DurationAsMicroseconds(d time.Duration) uint64

DurationAsMicroseconds converts time.Duration to microseconds, which is the format the Duration field is stored in the Span.

func EpochMicrosecondsAsTime

func EpochMicrosecondsAsTime(ts uint64) time.Time

EpochMicrosecondsAsTime converts microseconds since epoch to time.Time value.

func HashCode

func HashCode(o Hashable) (uint64, error)

HashCode calcualtes a FNV-1a hash code for a Hashable object.

func MicrosecondsAsDuration

func MicrosecondsAsDuration(v uint64) time.Duration

MicrosecondsAsDuration converts duration in microseconds to time.Duration value.

func SortSpan added in v0.5.2

func SortSpan(span *Span)

SortSpan deep sorts a span: this sorts its tags, logs by timestamp, tags in logs, and tags in process.

func SortTrace added in v0.5.2

func SortTrace(trace *Trace)

SortTrace deep sorts a trace's spans by SpanID.

func SortTraces added in v0.5.2

func SortTraces(traces []*Trace)

SortTraces deep sorts a list of traces by TraceID.

func TimeAsEpochMicroseconds

func TimeAsEpochMicroseconds(t time.Time) uint64

TimeAsEpochMicroseconds converts time.Time to microseconds since epoch, which is the format the StartTime field is stored in the Span.

Types

type DependencyLink struct {
	Parent    string `json:"parent"`
	Child     string `json:"child"`
	CallCount uint64 `json:"callCount"`
}

DependencyLink shows dependencies between services

type Flags

type Flags uint32

Flags is a bit map of flags for a span

func (Flags) IsDebug

func (f Flags) IsDebug() bool

IsDebug returns true if the Flags denote debugging Debugging can be useful in testing tracing availability or correctness

func (Flags) IsSampled

func (f Flags) IsSampled() bool

IsSampled returns true if the Flags denote sampling

func (*Flags) SetDebug

func (f *Flags) SetDebug()

SetDebug set the Flags as sampled

func (*Flags) SetSampled

func (f *Flags) SetSampled()

SetSampled sets the Flags as sampled

type Hashable

type Hashable interface {
	Hash(w io.Writer) error
}

Hashable interface is for type that can participate in a hash computation by writing their data into io.Writer, which is usually an instance of hash.Hash.

type KeyValue

type KeyValue struct {
	Key   string    `json:"key"`
	VType ValueType `json:"vType"`
	VStr  string    `json:"vStr,omitempty"`
	VNum  int64     `json:"vNum,omitempty"`
	VBlob []byte    `json:"vBlob,omitempty"`
}

KeyValue describes a tag or a log field that consists of a key and a typed value. Before accessing a value, the caller must check the type. Boolean and numeric values should be accessed via accessor methods Bool(), Int64(), and Float64().

This struct is designed to minimize heap allocations.

func Binary

func Binary(key string, value []byte) KeyValue

Binary creates a Binary-typed KeyValue

func Bool

func Bool(key string, value bool) KeyValue

Bool creates a Bool-typed KeyValue

func Float64

func Float64(key string, value float64) KeyValue

Float64 creates a Float64-typed KeyValue

func Int64

func Int64(key string, value int64) KeyValue

Int64 creates a Int64-typed KeyValue

func String

func String(key string, value string) KeyValue

String creates a String-typed KeyValue

func (*KeyValue) AsString

func (kv *KeyValue) AsString() string

AsString returns a potentially lossy string representation of the value.

func (*KeyValue) Binary

func (kv *KeyValue) Binary() []byte

Binary returns the blob ([]byte) value stored in this KeyValue or nil if it stores a different type. The caller must check VType before using this method.

func (*KeyValue) Bool

func (kv *KeyValue) Bool() bool

Bool returns the Boolean value stored in this KeyValue or false if it stores a different type. The caller must check VType before using this method.

func (*KeyValue) Equal

func (kv *KeyValue) Equal(other *KeyValue) bool

Equal compares KeyValue object with another KeyValue.

func (*KeyValue) Float64

func (kv *KeyValue) Float64() float64

Float64 returns the Float64 value stored in this KeyValue or 0 if it stores a different type. The caller must check VType before using this method.

func (KeyValue) Hash

func (kv KeyValue) Hash(w io.Writer) error

Hash implements Hash from Hashable.

func (*KeyValue) Int64

func (kv *KeyValue) Int64() int64

Int64 returns the Int64 value stored in this KeyValue or 0 if it stores a different type. The caller must check VType before using this method.

func (*KeyValue) IsLess

func (kv *KeyValue) IsLess(two *KeyValue) bool

IsLess compares KeyValue object with another KeyValue. The order is based first on the keys, then on type, and finally on the value.

func (*KeyValue) Value

func (kv *KeyValue) Value() interface{}

Value returns typed values stored in KeyValue as interface{}.

type KeyValues

type KeyValues []KeyValue

KeyValues is a type alias that exposes convenience functions like Sort, FindByKey.

func (KeyValues) Equal

func (kvs KeyValues) Equal(other KeyValues) bool

Equal compares KeyValues with another list. Both lists must be already sorted.

func (KeyValues) FindByKey

func (kvs KeyValues) FindByKey(key string) (KeyValue, bool)

FindByKey scans the list of key-values searching for the first one with the given key. Returns found tag and a boolean flag indicating if the search was successful.

func (KeyValues) Hash

func (kvs KeyValues) Hash(w io.Writer) error

Hash implements Hash from Hashable.

func (KeyValues) Len

func (kvs KeyValues) Len() int

func (KeyValues) Less

func (kvs KeyValues) Less(i, j int) bool

func (KeyValues) Sort

func (kvs KeyValues) Sort()

Sort does in-place sorting of KeyValues, then by value type, then by value.

func (KeyValues) Swap

func (kvs KeyValues) Swap(i, j int)

type Log

type Log struct {
	Timestamp time.Time  `json:"timestamp"`
	Fields    []KeyValue `json:"fields"`
}

Log describes a micro-log entry that consists of a timestamp and one or more key-value fields

type Process

type Process struct {
	ServiceName string     `json:"serviceName"`
	Tags        []KeyValue `json:"tags,omitempty"`
}

Process describes an instance of an application or service that emits tracing data.

func NewProcess

func NewProcess(serviceName string, tags []KeyValue) *Process

NewProcess creates a new Process for given serviceName and tags. The tags are sorted in place and kept in the the same array/slice, in order to store the Process in a canonical form that is relied upon by the Equal and Hash functions.

func (*Process) Equal

func (p *Process) Equal(other *Process) bool

Equal compares Process object with another Process.

func (*Process) Hash

func (p *Process) Hash(w io.Writer) (err error)

Hash implements Hash from Hashable.

type Span

type Span struct {
	TraceID       TraceID       `json:"traceID"`
	SpanID        SpanID        `json:"spanID"`
	OperationName string        `json:"operationName"`
	References    []SpanRef     `json:"references,omitempty"`
	Flags         Flags         `json:"flags,omitempty"`
	StartTime     time.Time     `json:"startTime"`
	Duration      time.Duration `json:"duration"`
	Tags          []KeyValue    `json:"tags,omitempty"`
	Logs          []Log         `json:"logs,omitempty"`
	Process       *Process      `json:"process"`
	Warnings      []string      `json:"warnings,omitempty"`
}

Span represents a unit of work in an application, such as an RPC, a database call, etc.

func (*Span) HasSpanKind

func (s *Span) HasSpanKind(kind ext.SpanKindEnum) bool

HasSpanKind returns true if the span has a `span.kind` tag set to `kind`.

func (*Span) Hash

func (s *Span) Hash(w io.Writer) (err error)

Hash implements Hash from Hashable.

func (*Span) IsRPCClient

func (s *Span) IsRPCClient() bool

IsRPCClient returns true if the span represents a client side of an RPC, as indicated by the `span.kind` tag set to `client`.

func (*Span) IsRPCServer

func (s *Span) IsRPCServer() bool

IsRPCServer returns true if the span represents a server side of an RPC, as indicated by the `span.kind` tag set to `server`.

func (*Span) NormalizeTimestamps

func (s *Span) NormalizeTimestamps()

NormalizeTimestamps changes all timestamps in this span to UTC.

func (*Span) ParentSpanID

func (s *Span) ParentSpanID() SpanID

ParentSpanID returns ID of a parent span if it exists. It searches for the first child-of reference pointing to the same trace ID.

func (*Span) ReplaceParentID added in v1.5.0

func (s *Span) ReplaceParentID(newParentID SpanID)

ReplaceParentID replaces span ID in the parent span reference. See also ParentSpanID.

type SpanID

type SpanID uint64

SpanID is a random 64bit identifier for a span

func SpanIDFromString

func SpanIDFromString(s string) (SpanID, error)

SpanIDFromString creates a SpanID from a hexadecimal string

func (SpanID) MarshalText

func (s SpanID) MarshalText() ([]byte, error)

MarshalText allows SpanID to serialize itself in JSON as a string.

func (SpanID) String

func (s SpanID) String() string

func (*SpanID) UnmarshalText

func (s *SpanID) UnmarshalText(text []byte) error

UnmarshalText allows SpanID to deserialize itself from a JSON string.

type SpanRef

type SpanRef struct {
	RefType SpanRefType `json:"refType"`
	TraceID TraceID     `json:"traceID"`
	SpanID  SpanID      `json:"spanID"`
}

SpanRef describes a reference from one span to another

func MaybeAddParentSpanID added in v1.5.0

func MaybeAddParentSpanID(traceID TraceID, parentSpanID SpanID, refs []SpanRef) []SpanRef

MaybeAddParentSpanID adds non-zero parentSpanID to refs as a child-of reference. We no longer store ParentSpanID in the domain model, but the data in the database or other formats might still have these IDs without representing them in the References, so this converts parent IDs to canonical reference format.

func NewChildOfRef added in v1.5.0

func NewChildOfRef(traceID TraceID, spanID SpanID) SpanRef

NewChildOfRef creates a new child-of span reference.

func NewFollowsFromRef added in v1.5.0

func NewFollowsFromRef(traceID TraceID, spanID SpanID) SpanRef

NewFollowsFromRef creates a new follows-from span reference.

type SpanRefType

type SpanRefType int

SpanRefType describes the type of a span reference

const (
	// ChildOf span reference type describes a reference to a parent span
	// that depends on the response from the current (child) span
	ChildOf SpanRefType = iota

	// FollowsFrom span reference type describes a reference to a "parent" span
	// that does not depend on the response from the current (child) span
	FollowsFrom
)

func SpanRefTypeFromString

func SpanRefTypeFromString(s string) (SpanRefType, error)

SpanRefTypeFromString converts a string into SpanRefType enum.

func (SpanRefType) MarshalText

func (p SpanRefType) MarshalText() ([]byte, error)

MarshalText allows SpanRefType to serialize itself in JSON as a string.

func (SpanRefType) String

func (p SpanRefType) String() string

func (*SpanRefType) UnmarshalText

func (p *SpanRefType) UnmarshalText(text []byte) error

UnmarshalText allows SpanRefType to deserialize itself from a JSON string.

type Trace

type Trace struct {
	Spans    []*Span  `json:"spans,omitempty"`
	Warnings []string `json:"warnings,omitempty"`
}

Trace is a directed acyclic graph of Spans

func (*Trace) FindSpanByID

func (t *Trace) FindSpanByID(id SpanID) *Span

FindSpanByID looks for a span with given span ID and returns the first one it finds (search order is unspecified), or nil if no spans have that ID.

func (*Trace) NormalizeTimestamps

func (t *Trace) NormalizeTimestamps()

NormalizeTimestamps changes all timestamps in this trace to UTC.

type TraceID

type TraceID struct {
	Low  uint64 `json:"lo"`
	High uint64 `json:"hi"`
}

TraceID is a random 128bit identifier for a trace

func TraceIDFromString

func TraceIDFromString(s string) (TraceID, error)

TraceIDFromString creates a TraceID from a hexadecimal string

func (TraceID) MarshalText

func (t TraceID) MarshalText() ([]byte, error)

MarshalText allows TraceID to serialize itself in JSON as a string.

func (TraceID) String

func (t TraceID) String() string

func (*TraceID) UnmarshalText

func (t *TraceID) UnmarshalText(text []byte) error

UnmarshalText allows TraceID to deserialize itself from a JSON string.

type ValueType

type ValueType int

ValueType describes the type of value contained in a KeyValue struct

const (
	// StringType indicates the value is a unicode string
	StringType ValueType = iota
	// BoolType indicates the value is a Boolean encoded as int64 number 0 or 1
	BoolType
	// Int64Type indicates the value is an int64 number
	Int64Type
	// Float64Type indicates the value is a float64 number stored as int64
	Float64Type
	// BinaryType indicates the value is binary blob stored as a byte array
	BinaryType
)

func ValueTypeFromString

func ValueTypeFromString(s string) (ValueType, error)

ValueTypeFromString converts a string into ValueType enum.

func (ValueType) MarshalText

func (p ValueType) MarshalText() ([]byte, error)

MarshalText allows ValueType to serialize itself in JSON as a string.

func (ValueType) String

func (p ValueType) String() string

func (*ValueType) UnmarshalText

func (p *ValueType) UnmarshalText(text []byte) error

UnmarshalText allows ValueType to deserialize itself from a JSON string.

Directories

Path Synopsis
Package adjuster contains various adjusters for model.Trace.
Package adjuster contains various adjusters for model.Trace.
Package converter contains various utilities for converting model.Trace to/from other data modes, like Thrift, or UI JSON.
Package converter contains various utilities for converting model.Trace to/from other data modes, like Thrift, or UI JSON.
json
Package json allows converting model.Trace to external JSON data model.
Package json allows converting model.Trace to external JSON data model.
thrift
Package thrift allows converting model.Trace to/from various thrift models.
Package thrift allows converting model.Trace to/from various thrift models.
thrift/jaeger
Package jaeger allows converting model.Trace to/from jaeger.thrift model.
Package jaeger allows converting model.Trace to/from jaeger.thrift model.
thrift/zipkin
Package zipkin allows converting model.Trace to/from zipkin.thrift model.
Package zipkin allows converting model.Trace to/from zipkin.thrift model.
Package json defines the external JSON representation for Jaeger traces.
Package json defines the external JSON representation for Jaeger traces.

Jump to

Keyboard shortcuts

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