Documentation ¶
Overview ¶
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 ¶
Constants ¶
This section is empty.
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
Functions ¶
This section is empty.
Types ¶
type Annotation ¶
Annotation associates an event that explains latency with a timestamp.
func (*Annotation) MarshalJSON ¶
func (a *Annotation) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON encoding
func (*Annotation) UnmarshalJSON ¶
func (a *Annotation) UnmarshalJSON(b []byte) error
UnmarshalJSON implements custom JSON decoding
type BaggageFields ¶
type BaggageFields interface { // Get returns the values for a field identified by its key. Get(key string) []string // Add adds the provided values to a header designated by key. If not // accepted by the baggage implementation, it will return false. Add(key string, value ...string) bool // Set sets the provided values to a header designated by key. If not // accepted by the baggage implementation, it will return false. Set(key string, value ...string) bool // Delete removes the field data designated by key. If not accepted by the // baggage implementation, it will return false. Delete(key string) bool // Iterate will iterate over the available fields and for each one it will // trigger the callback function. Iterate(f func(key string, values []string)) }
BaggageFields holds the interface for consumers needing to interact with the fields in application logic.
type Endpoint ¶
Endpoint holds the network context of a node in the service graph.
func (Endpoint) MarshalJSON ¶
MarshalJSON exports our Endpoint into the correct format for the Zipkin V2 API.
type ID ¶
type ID uint64
ID type
func (ID) MarshalJSON ¶
MarshalJSON serializes an ID type (SpanID, ParentSpanID) to HEX.
func (*ID) UnmarshalJSON ¶
UnmarshalJSON deserializes an ID type (SpanID, ParentSpanID) from HEX.
type Kind ¶
type Kind string
Kind clarifies context of timestamp, duration and remoteEndpoint in a span.
type SpanContext ¶
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:"-"` Baggage BaggageFields `json:"-"` }
SpanContext holds the context of a Span.
type SpanModel ¶
type SpanModel struct { SpanContext Name string `json:"name,omitempty"` Kind Kind `json:"kind,omitempty"` Timestamp time.Time `json:"-"` Duration time.Duration `json:"-"` 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 ¶
MarshalJSON exports our Model into the correct format for the Zipkin V2 API.
func (*SpanModel) UnmarshalJSON ¶
UnmarshalJSON imports our Model from a Zipkin V2 API compatible span representation.
type TraceID ¶
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 ¶
TraceIDFromHex returns the TraceID from a hex string.
func (TraceID) MarshalJSON ¶
MarshalJSON custom JSON serializer to export the TraceID in the required zero padded hex representation.
func (*TraceID) UnmarshalJSON ¶
UnmarshalJSON custom JSON deserializer to retrieve the traceID from the hex encoded representation.