zipkin-go: github.com/openzipkin/zipkin-go/model Index | Files

package model

import "github.com/openzipkin/zipkin-go/model"

Package model contains the Zipkin V2 model which is used by the Zipkin Go tracer implementation.

Third party instrumentation libraries can use the model and transport packages found in this Zipkin Go library to directly interface with the Zipkin Server or Zipkin Collectors without the need to use the tracer implementation itself.

Index

Package Files

annotation.go doc.go endpoint.go kind.go span.go span_id.go traceid.go

Variables

var (
    ErrValidTraceIDRequired  = errors.New("valid traceId required")
    ErrValidIDRequired       = errors.New("valid span id required")
    ErrValidDurationRequired = errors.New("valid duration required")
)

unmarshal errors

var ErrValidTimestampRequired = errors.New("valid annotation timestamp required")

ErrValidTimestampRequired error

type Annotation Uses

type Annotation struct {
    Timestamp time.Time
    Value     string
}

Annotation associates an event that explains latency with a timestamp.

func (*Annotation) MarshalJSON Uses

func (a *Annotation) MarshalJSON() ([]byte, error)

MarshalJSON implements custom JSON encoding

func (*Annotation) UnmarshalJSON Uses

func (a *Annotation) UnmarshalJSON(b []byte) error

UnmarshalJSON implements custom JSON decoding

type Endpoint Uses

type Endpoint struct {
    ServiceName string `json:"serviceName,omitempty"`
    IPv4        net.IP `json:"ipv4,omitempty"`
    IPv6        net.IP `json:"ipv6,omitempty"`
    Port        uint16 `json:"port,omitempty"`
}

Endpoint holds the network context of a node in the service graph.

func (*Endpoint) Empty Uses

func (e *Endpoint) Empty() bool

Empty returns if all Endpoint properties are empty / unspecified.

type ID Uses

type ID uint64

ID type

func (ID) MarshalJSON Uses

func (i ID) MarshalJSON() ([]byte, error)

MarshalJSON serializes an ID type (SpanID, ParentSpanID) to HEX.

func (ID) String Uses

func (i ID) String() string

String outputs the 64-bit ID as hex string.

func (*ID) UnmarshalJSON Uses

func (i *ID) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON deserializes an ID type (SpanID, ParentSpanID) from HEX.

type Kind Uses

type Kind string

Kind clarifies context of timestamp, duration and remoteEndpoint in a span.

const (
    Undetermined Kind = ""
    Client       Kind = "CLIENT"
    Server       Kind = "SERVER"
    Producer     Kind = "PRODUCER"
    Consumer     Kind = "CONSUMER"
)

Available Kind values

type SpanContext Uses

type SpanContext struct {
    TraceID  TraceID `json:"traceId"`
    ID       ID      `json:"id"`
    ParentID *ID     `json:"parentId,omitempty"`
    Debug    bool    `json:"debug,omitempty"`
    Sampled  *bool   `json:"-"`
    Err      error   `json:"-"`
}

SpanContext holds the context of a Span.

type SpanModel Uses

type SpanModel struct {
    SpanContext
    Name           string            `json:"name,omitempty"`
    Kind           Kind              `json:"kind,omitempty"`
    Timestamp      time.Time         `json:"-"`
    Duration       time.Duration     `json:"-"`
    Shared         bool              `json:"shared,omitempty"`
    LocalEndpoint  *Endpoint         `json:"localEndpoint,omitempty"`
    RemoteEndpoint *Endpoint         `json:"remoteEndpoint,omitempty"`
    Annotations    []Annotation      `json:"annotations,omitempty"`
    Tags           map[string]string `json:"tags,omitempty"`
}

SpanModel structure.

If using this library to instrument your application you will not need to directly access or modify this representation. The SpanModel is exported for use cases involving 3rd party Go instrumentation libraries desiring to export data to a Zipkin server using the Zipkin V2 Span model.

func (SpanModel) MarshalJSON Uses

func (s SpanModel) MarshalJSON() ([]byte, error)

MarshalJSON exports our Model into the correct format for the Zipkin V2 API.

func (*SpanModel) UnmarshalJSON Uses

func (s *SpanModel) UnmarshalJSON(b []byte) error

UnmarshalJSON imports our Model from a Zipkin V2 API compatible span representation.

type TraceID Uses

type TraceID struct {
    High uint64
    Low  uint64
}

TraceID is a 128 bit number internally stored as 2x uint64 (high & low). In case of 64 bit traceIDs, the value can be found in Low.

func TraceIDFromHex Uses

func TraceIDFromHex(h string) (t TraceID, err error)

TraceIDFromHex returns the TraceID from a hex string.

func (TraceID) Empty Uses

func (t TraceID) Empty() bool

Empty returns if TraceID has zero value.

func (TraceID) MarshalJSON Uses

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

MarshalJSON custom JSON serializer to export the TraceID in the required zero padded hex representation.

func (TraceID) String Uses

func (t TraceID) String() string

String outputs the 128-bit traceID as hex string.

func (*TraceID) UnmarshalJSON Uses

func (t *TraceID) UnmarshalJSON(traceID []byte) error

UnmarshalJSON custom JSON deserializer to retrieve the traceID from the hex encoded representation.

Package model imports 6 packages (graph) and is imported by 53 packages. Updated 2019-02-04. Refresh now. Tools for package owners.