zipkincore

package
v1.20.3 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const CLIENT_ADDR = "ca"
View Source
const CLIENT_RECV = "cr"
View Source
const CLIENT_RECV_FRAGMENT = "crf"
View Source
const CLIENT_SEND = "cs"
View Source
const CLIENT_SEND_FRAGMENT = "csf"
View Source
const ERROR = "error"
View Source
const HTTP_HOST = "http.host"
View Source
const HTTP_METHOD = "http.method"
View Source
const HTTP_PATH = "http.path"
View Source
const HTTP_REQUEST_SIZE = "http.request.size"
View Source
const HTTP_RESPONSE_SIZE = "http.response.size"
View Source
const HTTP_ROUTE = "http.route"
View Source
const HTTP_STATUS_CODE = "http.status_code"
View Source
const HTTP_URL = "http.url"
View Source
const LOCAL_COMPONENT = "lc"
View Source
const MESSAGE_ADDR = "ma"
View Source
const MESSAGE_RECV = "mr"
View Source
const MESSAGE_SEND = "ms"
View Source
const SERVER_ADDR = "sa"
View Source
const SERVER_RECV = "sr"
View Source
const SERVER_RECV_FRAGMENT = "srf"
View Source
const SERVER_SEND = "ss"
View Source
const SERVER_SEND_FRAGMENT = "ssf"
View Source
const WIRE_RECV = "wr"
View Source
const WIRE_SEND = "ws"

Variables

View Source
var Endpoint_Ipv6_DEFAULT []byte
View Source
var GoUnusedProtection__ int
View Source
var Span_Debug_DEFAULT bool = false
View Source
var Span_Duration_DEFAULT int64
View Source
var Span_ParentID_DEFAULT int64
View Source
var Span_Timestamp_DEFAULT int64
View Source
var Span_TraceIDHigh_DEFAULT int64

Functions

This section is empty.

Types

type Annotation

type Annotation struct {
	Timestamp int64     `thrift:"timestamp,1" db:"timestamp" json:"timestamp"`
	Value     string    `thrift:"value,2" db:"value" json:"value"`
	Host      *Endpoint `thrift:"host,3" db:"host" json:"host,omitempty"`
}

Associates an event that explains latency with a timestamp.

Unlike log statements, annotations are often codes: for example "sr".

Attributes:

  • Timestamp: Microseconds from epoch.

This value should use the most precise value possible. For example, gettimeofday or multiplying currentTimeMillis by 1000.

  • Value: Usually a short tag indicating an event, like "sr" or "finagle.retry".
  • Host: The host that recorded the value, primarily for query by service name.

func NewAnnotation

func NewAnnotation() *Annotation

func (*Annotation) Equals

func (p *Annotation) Equals(other *Annotation) bool

func (*Annotation) GetHost

func (p *Annotation) GetHost() *Endpoint

func (*Annotation) GetTimestamp

func (p *Annotation) GetTimestamp() int64

func (*Annotation) GetValue

func (p *Annotation) GetValue() string

func (*Annotation) IsSetHost

func (p *Annotation) IsSetHost() bool

func (*Annotation) Read

func (p *Annotation) Read(ctx context.Context, iprot thrift.TProtocol) error

func (*Annotation) ReadField1

func (p *Annotation) ReadField1(ctx context.Context, iprot thrift.TProtocol) error

func (*Annotation) ReadField2

func (p *Annotation) ReadField2(ctx context.Context, iprot thrift.TProtocol) error

func (*Annotation) ReadField3

func (p *Annotation) ReadField3(ctx context.Context, iprot thrift.TProtocol) error

func (*Annotation) String

func (p *Annotation) String() string

func (*Annotation) Write

func (p *Annotation) Write(ctx context.Context, oprot thrift.TProtocol) error

type AnnotationType

type AnnotationType int64

A subset of thrift base types, except BYTES.

const (
	AnnotationType_BOOL   AnnotationType = 0
	AnnotationType_BYTES  AnnotationType = 1
	AnnotationType_I16    AnnotationType = 2
	AnnotationType_I32    AnnotationType = 3
	AnnotationType_I64    AnnotationType = 4
	AnnotationType_DOUBLE AnnotationType = 5
	AnnotationType_STRING AnnotationType = 6
)

func AnnotationTypeFromString

func AnnotationTypeFromString(s string) (AnnotationType, error)

func AnnotationTypePtr

func AnnotationTypePtr(v AnnotationType) *AnnotationType

func (AnnotationType) MarshalText

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

func (*AnnotationType) Scan

func (p *AnnotationType) Scan(value interface{}) error

func (AnnotationType) String

func (p AnnotationType) String() string

func (*AnnotationType) UnmarshalText

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

func (*AnnotationType) Value

func (p *AnnotationType) Value() (driver.Value, error)

type BinaryAnnotation

type BinaryAnnotation struct {
	Key            string         `thrift:"key,1" db:"key" json:"key"`
	Value          []byte         `thrift:"value,2" db:"value" json:"value"`
	AnnotationType AnnotationType `thrift:"annotation_type,3" db:"annotation_type" json:"annotation_type"`
	Host           *Endpoint      `thrift:"host,4" db:"host" json:"host,omitempty"`
}

Binary annotations are tags applied to a Span to give it context. For example, a binary annotation of HTTP_PATH ("http.path") could the path to a resource in a RPC call.

Binary annotations of type STRING are always queryable, though more a historical implementation detail than a structural concern.

Binary annotations can repeat, and vary on the host. Similar to Annotation, the host indicates who logged the event. This allows you to tell the difference between the client and server side of the same key. For example, the key "http.path" might be different on the client and server side due to rewriting, like "/api/v1/myresource" vs "/myresource. Via the host field, you can see the different points of view, which often help in debugging.

Attributes:

  • Key: Name used to lookup spans, such as "http.path" or "finagle.version".
  • Value: Serialized thrift bytes, in TBinaryProtocol format.

For legacy reasons, byte order is big-endian. See THRIFT-3217.

  • AnnotationType: The thrift type of value, most often STRING.

annotation_type shouldn't vary for the same key.

  • Host: The host that recorded value, allowing query by service name or address.

There are two exceptions: when key is "ca" or "sa", this is the source or destination of an RPC. This exception allows zipkin to display network context of uninstrumented services, such as browsers or databases.

func NewBinaryAnnotation

func NewBinaryAnnotation() *BinaryAnnotation

func (*BinaryAnnotation) Equals

func (p *BinaryAnnotation) Equals(other *BinaryAnnotation) bool

func (*BinaryAnnotation) GetAnnotationType

func (p *BinaryAnnotation) GetAnnotationType() AnnotationType

func (*BinaryAnnotation) GetHost

func (p *BinaryAnnotation) GetHost() *Endpoint

func (*BinaryAnnotation) GetKey

func (p *BinaryAnnotation) GetKey() string

func (*BinaryAnnotation) GetValue

func (p *BinaryAnnotation) GetValue() []byte

func (*BinaryAnnotation) IsSetHost

func (p *BinaryAnnotation) IsSetHost() bool

func (*BinaryAnnotation) Read

func (p *BinaryAnnotation) Read(ctx context.Context, iprot thrift.TProtocol) error

func (*BinaryAnnotation) ReadField1

func (p *BinaryAnnotation) ReadField1(ctx context.Context, iprot thrift.TProtocol) error

func (*BinaryAnnotation) ReadField2

func (p *BinaryAnnotation) ReadField2(ctx context.Context, iprot thrift.TProtocol) error

func (*BinaryAnnotation) ReadField3

func (p *BinaryAnnotation) ReadField3(ctx context.Context, iprot thrift.TProtocol) error

func (*BinaryAnnotation) ReadField4

func (p *BinaryAnnotation) ReadField4(ctx context.Context, iprot thrift.TProtocol) error

func (*BinaryAnnotation) String

func (p *BinaryAnnotation) String() string

func (*BinaryAnnotation) Write

func (p *BinaryAnnotation) Write(ctx context.Context, oprot thrift.TProtocol) error

type Endpoint

type Endpoint struct {
	Ipv4        int32  `thrift:"ipv4,1" db:"ipv4" json:"ipv4"`
	Port        int16  `thrift:"port,2" db:"port" json:"port"`
	ServiceName string `thrift:"service_name,3" db:"service_name" json:"service_name"`
	Ipv6        []byte `thrift:"ipv6,4" db:"ipv6" json:"ipv6,omitempty"`
}

Indicates the network context of a service recording an annotation with two exceptions.

When a BinaryAnnotation, and key is CLIENT_ADDR or SERVER_ADDR, the endpoint indicates the source or destination of an RPC. This exception allows zipkin to display network context of uninstrumented services, or clients such as web browsers.

Attributes:

  • Ipv4: IPv4 host address packed into 4 bytes.

Ex for the ip 1.2.3.4, it would be (1 << 24) | (2 << 16) | (3 << 8) | 4

  • Port: IPv4 port or 0, if unknown.

Note: this is to be treated as an unsigned integer, so watch for negatives.

  • ServiceName: Classifier of a source or destination in lowercase, such as "zipkin-web".

This is the primary parameter for trace lookup, so should be intuitive as possible, for example, matching names in service discovery.

Conventionally, when the service name isn't known, service_name = "unknown". However, it is also permissible to set service_name = "" (empty string). The difference in the latter usage is that the span will not be queryable by service name unless more information is added to the span with non-empty service name, e.g. an additional annotation from the server.

Particularly clients may not have a reliable service name at ingest. One approach is to set service_name to "" at ingest, and later assign a better label based on binary annotations, such as user agent.

  • Ipv6: IPv6 host address packed into 16 bytes. Ex Inet6Address.getBytes()
var Annotation_Host_DEFAULT *Endpoint
var BinaryAnnotation_Host_DEFAULT *Endpoint

func NewEndpoint

func NewEndpoint() *Endpoint

func (*Endpoint) Equals

func (p *Endpoint) Equals(other *Endpoint) bool

func (*Endpoint) GetIpv4

func (p *Endpoint) GetIpv4() int32

func (*Endpoint) GetIpv6

func (p *Endpoint) GetIpv6() []byte

func (*Endpoint) GetPort

func (p *Endpoint) GetPort() int16

func (*Endpoint) GetServiceName

func (p *Endpoint) GetServiceName() string

func (*Endpoint) IsSetIpv6

func (p *Endpoint) IsSetIpv6() bool

func (*Endpoint) Read

func (p *Endpoint) Read(ctx context.Context, iprot thrift.TProtocol) error

func (*Endpoint) ReadField1

func (p *Endpoint) ReadField1(ctx context.Context, iprot thrift.TProtocol) error

func (*Endpoint) ReadField2

func (p *Endpoint) ReadField2(ctx context.Context, iprot thrift.TProtocol) error

func (*Endpoint) ReadField3

func (p *Endpoint) ReadField3(ctx context.Context, iprot thrift.TProtocol) error

func (*Endpoint) ReadField4

func (p *Endpoint) ReadField4(ctx context.Context, iprot thrift.TProtocol) error

func (*Endpoint) String

func (p *Endpoint) String() string

func (*Endpoint) Write

func (p *Endpoint) Write(ctx context.Context, oprot thrift.TProtocol) error

type Span

type Span struct {
	TraceID int64 `thrift:"trace_id,1" db:"trace_id" json:"trace_id"`
	// unused field # 2
	Name        string        `thrift:"name,3" db:"name" json:"name"`
	ID          int64         `thrift:"id,4" db:"id" json:"id"`
	ParentID    *int64        `thrift:"parent_id,5" db:"parent_id" json:"parent_id,omitempty"`
	Annotations []*Annotation `thrift:"annotations,6" db:"annotations" json:"annotations"`
	// unused field # 7
	BinaryAnnotations []*BinaryAnnotation `thrift:"binary_annotations,8" db:"binary_annotations" json:"binary_annotations"`
	Debug             bool                `thrift:"debug,9" db:"debug" json:"debug"`
	Timestamp         *int64              `thrift:"timestamp,10" db:"timestamp" json:"timestamp,omitempty"`
	Duration          *int64              `thrift:"duration,11" db:"duration" json:"duration,omitempty"`
	TraceIDHigh       *int64              `thrift:"trace_id_high,12" db:"trace_id_high" json:"trace_id_high,omitempty"`
}

A trace is a series of spans (often RPC calls) which form a latency tree.

Spans are usually created by instrumentation in RPC clients or servers, but can also represent in-process activity. Annotations in spans are similar to log statements, and are sometimes created directly by application developers to indicate events of interest, such as a cache miss.

The root span is where parent_id = Nil; it usually has the longest duration in the trace.

Span identifiers are packed into i64s, but should be treated opaquely. String encoding is fixed-width lower-hex, to avoid signed interpretation.

Attributes:

  • TraceID: Unique 8-byte identifier for a trace, set on all spans within it.
  • Name: Span name in lowercase, rpc method for example. Conventionally, when the

span name isn't known, name = "unknown".

  • ID: Unique 8-byte identifier of this span within a trace. A span is uniquely

identified in storage by (trace_id, id).

  • ParentID: The parent's Span.id; absent if this the root span in a trace.
  • Annotations: Associates events that explain latency with a timestamp. Unlike log

statements, annotations are often codes: for example SERVER_RECV("sr"). Annotations are sorted ascending by timestamp.

  • BinaryAnnotations: Tags a span with context, usually to support query or aggregation. For

example, a binary annotation key could be "http.path".

  • Debug: True is a request to store this span even if it overrides sampling policy.
  • Timestamp: Epoch microseconds of the start of this span, absent if this an incomplete

span.

This value should be set directly by instrumentation, using the most precise value possible. For example, gettimeofday or syncing nanoTime against a tick of currentTimeMillis.

For compatibility with instrumentation that precede this field, collectors or span stores can derive this via Annotation.timestamp. For example, SERVER_RECV.timestamp or CLIENT_SEND.timestamp.

Timestamp is nullable for input only. Spans without a timestamp cannot be presented in a timeline: Span stores should not output spans missing a timestamp.

There are two known edge-cases where this could be absent: both cases exist when a collector receives a span in parts and a binary annotation precedes a timestamp. This is possible when..

  • The span is in-flight (ex not yet received a timestamp)
  • The span's start event was lost
  • Duration: Measurement in microseconds of the critical path, if known. Durations of

less than one microsecond must be rounded up to 1 microsecond.

This value should be set directly, as opposed to implicitly via annotation timestamps. Doing so encourages precision decoupled from problems of clocks, such as skew or NTP updates causing time to move backwards.

For compatibility with instrumentation that precede this field, collectors or span stores can derive this by subtracting Annotation.timestamp. For example, SERVER_SEND.timestamp - SERVER_RECV.timestamp.

If this field is persisted as unset, zipkin will continue to work, except duration query support will be implementation-specific. Similarly, setting this field non-atomically is implementation-specific.

This field is i64 vs i32 to support spans longer than 35 minutes.

  • TraceIDHigh: Optional unique 8-byte additional identifier for a trace. If non zero, this

means the trace uses 128 bit traceIds instead of 64 bit.

func NewSpan

func NewSpan() *Span

func (*Span) Equals

func (p *Span) Equals(other *Span) bool

func (*Span) GetAnnotations

func (p *Span) GetAnnotations() []*Annotation

func (*Span) GetBinaryAnnotations

func (p *Span) GetBinaryAnnotations() []*BinaryAnnotation

func (*Span) GetDebug

func (p *Span) GetDebug() bool

func (*Span) GetDuration

func (p *Span) GetDuration() int64

func (*Span) GetID

func (p *Span) GetID() int64

func (*Span) GetName

func (p *Span) GetName() string

func (*Span) GetParentID

func (p *Span) GetParentID() int64

func (*Span) GetTimestamp

func (p *Span) GetTimestamp() int64

func (*Span) GetTraceID

func (p *Span) GetTraceID() int64

func (*Span) GetTraceIDHigh

func (p *Span) GetTraceIDHigh() int64

func (*Span) IsSetDebug

func (p *Span) IsSetDebug() bool

func (*Span) IsSetDuration

func (p *Span) IsSetDuration() bool

func (*Span) IsSetParentID

func (p *Span) IsSetParentID() bool

func (*Span) IsSetTimestamp

func (p *Span) IsSetTimestamp() bool

func (*Span) IsSetTraceIDHigh

func (p *Span) IsSetTraceIDHigh() bool

func (*Span) Read

func (p *Span) Read(ctx context.Context, iprot thrift.TProtocol) error

func (*Span) ReadField1

func (p *Span) ReadField1(ctx context.Context, iprot thrift.TProtocol) error

func (*Span) ReadField10

func (p *Span) ReadField10(ctx context.Context, iprot thrift.TProtocol) error

func (*Span) ReadField11

func (p *Span) ReadField11(ctx context.Context, iprot thrift.TProtocol) error

func (*Span) ReadField12

func (p *Span) ReadField12(ctx context.Context, iprot thrift.TProtocol) error

func (*Span) ReadField3

func (p *Span) ReadField3(ctx context.Context, iprot thrift.TProtocol) error

func (*Span) ReadField4

func (p *Span) ReadField4(ctx context.Context, iprot thrift.TProtocol) error

func (*Span) ReadField5

func (p *Span) ReadField5(ctx context.Context, iprot thrift.TProtocol) error

func (*Span) ReadField6

func (p *Span) ReadField6(ctx context.Context, iprot thrift.TProtocol) error

func (*Span) ReadField8

func (p *Span) ReadField8(ctx context.Context, iprot thrift.TProtocol) error

func (*Span) ReadField9

func (p *Span) ReadField9(ctx context.Context, iprot thrift.TProtocol) error

func (*Span) String

func (p *Span) String() string

func (*Span) Write

func (p *Span) Write(ctx context.Context, oprot thrift.TProtocol) error

Jump to

Keyboard shortcuts

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