Documentation
¶
Index ¶
- Constants
- Variables
- type CommonSampler
- type Decoder
- type FormatExternalTraceID
- type Numeric
- func (*Numeric) Descriptor() ([]byte, []int)deprecated
- func (x *Numeric) GetDoublevalue() float64
- func (x *Numeric) GetFloatvalue() float32
- func (x *Numeric) GetInt32Value() int32
- func (x *Numeric) GetInt64Value() int64
- func (m *Numeric) GetNumeric() isNumeric_Numeric
- func (x *Numeric) GetUint32Value() uint32
- func (x *Numeric) GetUint64Value() uint64
- func (*Numeric) ProtoMessage()
- func (x *Numeric) ProtoReflect() protoreflect.Message
- func (x *Numeric) Reset()
- func (x *Numeric) String() string
- type Numeric_Doublevalue
- type Numeric_Floatvalue
- type Numeric_Int32Value
- type Numeric_Int64Value
- type Numeric_Uint32Value
- type Numeric_Uint64Value
- type SamplePriority
- func (SamplePriority) Descriptor() protoreflect.EnumDescriptor
- func (x SamplePriority) Enum() *SamplePriority
- func (SamplePriority) EnumDescriptor() ([]byte, []int)deprecated
- func (x SamplePriority) Number() protoreflect.EnumNumber
- func (x SamplePriority) String() string
- func (SamplePriority) Type() protoreflect.EnumType
- type Sampler
- type Span
- func (sp *Span) BaggageItem(restrictedKey string) string
- func (sp *Span) Context() opentracing.SpanContext
- func (*Span) Descriptor() ([]byte, []int)deprecated
- func (sp *Span) Finish()
- func (sp *Span) FinishWithOptions(opts opentracing.FinishOptions)
- func (x *Span) GetEndTime() int64
- func (x *Span) GetMeta() map[string]string
- func (x *Span) GetMetrics() map[string]*Numeric
- func (x *Span) GetOperation() string
- func (x *Span) GetParentID() int64
- func (x *Span) GetService() string
- func (x *Span) GetSpanID() int64
- func (x *Span) GetStartTime() int64
- func (x *Span) GetStatus() SpanStatus
- func (x *Span) GetTraceID() int64
- func (sp *Span) Log(data opentracing.LogData)deprecated
- func (sp *Span) LogEvent(event string)deprecated
- func (sp *Span) LogEventWithPayload(event string, payload interface{})deprecated
- func (sp *Span) LogFields(fields ...log.Field)
- func (sp *Span) LogKV(alternatingKeyValues ...interface{})
- func (*Span) ProtoMessage()
- func (x *Span) ProtoReflect() protoreflect.Message
- func (x *Span) Reset()
- func (sp *Span) SetBaggageItem(restrictedKey, value string) opentracing.Span
- func (sp *Span) SetMeta(key, value string) opentracing.Span
- func (sp *Span) SetMetric(key string, number *Numeric) opentracing.Span
- func (sp *Span) SetOperationName(operationName string) opentracing.Span
- func (sp *Span) SetTag(key string, value interface{}) opentracing.Span
- func (sp *Span) SetTags(tags map[string]interface{}) opentracing.Span
- func (x *Span) String() string
- func (sp *Span) Tracer() opentracing.Tracer
- type SpanContext
- func (*SpanContext) Descriptor() ([]byte, []int)deprecated
- func (spctx *SpanContext) ForeachBaggageItem(handler func(k, v string) bool)
- func (x *SpanContext) GetMeta() map[string]string
- func (x *SpanContext) GetParentID() int64
- func (x *SpanContext) GetSamplePriority() SamplePriority
- func (x *SpanContext) GetSampleRatio() float64
- func (x *SpanContext) GetTraceID() int64
- func (*SpanContext) ProtoMessage()
- func (x *SpanContext) ProtoReflect() protoreflect.Message
- func (x *SpanContext) Reset()
- func (x *SpanContext) String() string
- type SpanNative
- type SpanStatus
- type SpanTransform
- type SpanTransformServer
- type SpanTransformServerConfig
- type StartTracerOption
- type Trace
- type TraceNative
- type Tracer
- func (tcr *Tracer) Close()
- func (tcr *Tracer) Extract(format interface{}, carrier interface{}) (opentracing.SpanContext, error)
- func (tcr *Tracer) Flush()
- func (tcr *Tracer) Inject(sm opentracing.SpanContext, format interface{}, carrier interface{}) error
- func (tcr *Tracer) Start()
- func (tcr *Tracer) StartSpan(operationName string, opts ...opentracing.StartSpanOption) opentracing.Span
- type Traces
Constants ¶
const ( ServiceNameKey = "uni-ot-service" DataSourceKey = "uni-ot-data-source" SamplePriorityKey = "uni-ot-smaple-priority" SampleRatioKey = "uni-ot-sample-ratio" ExternalTraceID = "uni-ot-external-trace-id" )
Service key
const ( TraceIDKey = "uni-ot-trace-id" ParentIDKey = "uni-ot-parent-id" )
Trace key
const ( DefService = "UniversalOpenTracingTransform" DefFlushBuffer = 1024 DefFlushInterval = 3 * time.Second )
const Prefix = "uni-ot-"
Prefix for universal-opentracing-transformer key in k-v paris
Variables ¶
var ( SpanStatus_name = map[int32]string{ 0: "OK", 1: "Error", 2: "Recovery", 3: "Crisis", } SpanStatus_value = map[string]int32{ "OK": 0, "Error": 1, "Recovery": 2, "Crisis": 3, } )
Enum value maps for SpanStatus.
var ( SamplePriority_name = map[int32]string{ 0: "AutoKeep", 1: "AutoBlock", 2: "SamplerKeep", 3: "SamplerBlock", 4: "UserKeep", 5: "UserBlock", } SamplePriority_value = map[string]int32{ "AutoKeep": 0, "AutoBlock": 1, "SamplerKeep": 2, "SamplerBlock": 3, "UserKeep": 4, "UserBlock": 5, } )
Enum value maps for SamplePriority.
var File_span_proto protoreflect.FileDescriptor
var File_spancontext_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type CommonSampler ¶
type CommonSampler float64
func (CommonSampler) Ratio ¶
func (cs CommonSampler) Ratio() float64
type Decoder ¶
type Decoder func(body io.Reader) SpanNative
type FormatExternalTraceID ¶
type FormatExternalTraceID func(tid interface{}) int64
type Numeric ¶
type Numeric struct {
// Types that are assignable to Numeric:
// *Numeric_Int32Value
// *Numeric_Int64Value
// *Numeric_Uint32Value
// *Numeric_Uint64Value
// *Numeric_Floatvalue
// *Numeric_Doublevalue
Numeric isNumeric_Numeric `protobuf_oneof:"Numeric"`
// contains filtered or unexported fields
}
func (*Numeric) Descriptor
deprecated
func (*Numeric) GetDoublevalue ¶
func (*Numeric) GetFloatvalue ¶
func (*Numeric) GetInt32Value ¶
func (*Numeric) GetInt64Value ¶
func (*Numeric) GetNumeric ¶
func (m *Numeric) GetNumeric() isNumeric_Numeric
func (*Numeric) GetUint32Value ¶
func (*Numeric) GetUint64Value ¶
func (*Numeric) ProtoMessage ¶
func (*Numeric) ProtoMessage()
func (*Numeric) ProtoReflect ¶
func (x *Numeric) ProtoReflect() protoreflect.Message
type Numeric_Doublevalue ¶
type Numeric_Doublevalue struct {
Doublevalue float64 `protobuf:"fixed64,6,opt,name=doublevalue,proto3,oneof"`
}
type Numeric_Floatvalue ¶
type Numeric_Floatvalue struct {
Floatvalue float32 `protobuf:"fixed32,5,opt,name=floatvalue,proto3,oneof"`
}
type Numeric_Int32Value ¶
type Numeric_Int32Value struct {
Int32Value int32 `protobuf:"varint,1,opt,name=int32value,proto3,oneof"`
}
type Numeric_Int64Value ¶
type Numeric_Int64Value struct {
Int64Value int64 `protobuf:"varint,2,opt,name=int64value,proto3,oneof"`
}
type Numeric_Uint32Value ¶
type Numeric_Uint32Value struct {
Uint32Value uint32 `protobuf:"varint,3,opt,name=uint32value,proto3,oneof"`
}
type Numeric_Uint64Value ¶
type Numeric_Uint64Value struct {
Uint64Value uint64 `protobuf:"varint,4,opt,name=uint64value,proto3,oneof"`
}
type SamplePriority ¶
type SamplePriority int32
const ( SamplePriority_AutoKeep SamplePriority = 0 SamplePriority_AutoBlock SamplePriority = 1 SamplePriority_SamplerKeep SamplePriority = 2 SamplePriority_SamplerBlock SamplePriority = 3 SamplePriority_UserKeep SamplePriority = 4 SamplePriority_UserBlock SamplePriority = 5 )
func (SamplePriority) Descriptor ¶
func (SamplePriority) Descriptor() protoreflect.EnumDescriptor
func (SamplePriority) Enum ¶
func (x SamplePriority) Enum() *SamplePriority
func (SamplePriority) EnumDescriptor
deprecated
func (SamplePriority) EnumDescriptor() ([]byte, []int)
Deprecated: Use SamplePriority.Descriptor instead.
func (SamplePriority) Number ¶
func (x SamplePriority) Number() protoreflect.EnumNumber
func (SamplePriority) String ¶
func (x SamplePriority) String() string
func (SamplePriority) Type ¶
func (SamplePriority) Type() protoreflect.EnumType
type Span ¶
type Span struct {
TraceID int64 `protobuf:"varint,1,opt,name=TraceID,proto3" json:"TraceID,omitempty"`
ParentID int64 `protobuf:"varint,2,opt,name=ParentID,proto3" json:"ParentID,omitempty"`
SpanID int64 `protobuf:"varint,3,opt,name=SpanID,proto3" json:"SpanID,omitempty"`
Service string `protobuf:"bytes,4,opt,name=Service,proto3" json:"Service,omitempty"`
Operation string `protobuf:"bytes,5,opt,name=Operation,proto3" json:"Operation,omitempty"`
Meta map[string]string `` /* 149-byte string literal not displayed */
Metrics map[string]*Numeric `` /* 155-byte string literal not displayed */
Status SpanStatus `protobuf:"varint,9,opt,name=Status,proto3,enum=opentracing.go.SpanStatus" json:"Status,omitempty"`
StartTime int64 `protobuf:"varint,10,opt,name=StartTime,proto3" json:"StartTime,omitempty"`
EndTime int64 `protobuf:"varint,11,opt,name=EndTime,proto3" json:"EndTime,omitempty"`
// contains filtered or unexported fields
}
func (*Span) BaggageItem ¶
Gets the value for a baggage item given its key. Returns the empty string if the value isn't found in this Span.
func (*Span) Context ¶
func (sp *Span) Context() opentracing.SpanContext
Context() yields the SpanContext for this Span. Note that the return value of Context() is still valid after a call to Span.Finish(), as is a call to Span.Context() after a call to Span.Finish().
func (*Span) Descriptor
deprecated
func (*Span) Finish ¶
func (sp *Span) Finish()
Sets the end timestamp and finalizes Span state.
With the exception of calls to Context() (which are always allowed), Finish() must be the last call made to any span instance, and to do otherwise leads to undefined behavior.
func (*Span) FinishWithOptions ¶
func (sp *Span) FinishWithOptions(opts opentracing.FinishOptions)
FinishWithOptions is like Finish() but with explicit control over timestamps and log data.
func (*Span) GetEndTime ¶
func (*Span) GetMetrics ¶
func (*Span) GetOperation ¶
func (*Span) GetParentID ¶
func (*Span) GetService ¶
func (*Span) GetStartTime ¶
func (*Span) GetStatus ¶
func (x *Span) GetStatus() SpanStatus
func (*Span) GetTraceID ¶
func (*Span) Log
deprecated
func (sp *Span) Log(data opentracing.LogData)
Deprecated: use LogFields or LogKV
func (*Span) LogEventWithPayload
deprecated
func (*Span) LogFields ¶
LogFields is an efficient and type-checked way to record key:value logging data about a Span, though the programming interface is a little more verbose than LogKV(). Here's an example:
span.LogFields(
log.String("event", "soft error"),
log.String("type", "cache timeout"),
log.Int("waited.millis", 1500))
Also see Span.FinishWithOptions() and FinishOptions.BulkLogData.
func (*Span) LogKV ¶
func (sp *Span) LogKV(alternatingKeyValues ...interface{})
LogKV is a concise, readable way to record key:value logging data about a Span, though unfortunately this also makes it less efficient and less type-safe than LogFields(). Here's an example:
span.LogKV(
"event", "soft error",
"type", "cache timeout",
"waited.millis", 1500)
For LogKV (as opposed to LogFields()), the parameters must appear as key-value pairs, like
span.LogKV(key1, val1, key2, val2, key3, val3, ...)
The keys must all be strings. The values may be strings, numeric types, bools, Go error instances, or arbitrary structs.
(Note to implementors: consider the log.InterleavedKVToFields() helper)
func (*Span) ProtoMessage ¶
func (*Span) ProtoMessage()
func (*Span) ProtoReflect ¶
func (x *Span) ProtoReflect() protoreflect.Message
func (*Span) SetBaggageItem ¶
func (sp *Span) SetBaggageItem(restrictedKey, value string) opentracing.Span
SetBaggageItem sets a key:value pair on this Span and its SpanContext that also propagates to descendants of this Span.
SetBaggageItem() enables powerful functionality given a full-stack opentracing integration (e.g., arbitrary application data from a mobile app can make it, transparently, all the way into the depths of a storage system), and with it some powerful costs: use this feature with care.
IMPORTANT NOTE #1: SetBaggageItem() will only propagate baggage items to *future* causal descendants of the associated Span.
IMPORTANT NOTE #2: Use this thoughtfully and with care. Every key and value is copied into every local *and remote* child of the associated Span, and that can add up to a lot of network and cpu overhead.
Returns a reference to this Span for chaining.
func (*Span) SetOperationName ¶
func (sp *Span) SetOperationName(operationName string) opentracing.Span
Sets or changes the operation name.
Returns a reference to this Span for chaining.
func (*Span) SetTag ¶
func (sp *Span) SetTag(key string, value interface{}) opentracing.Span
Adds a tag to the span.
If there is a pre-existing tag set for `key`, it is overwritten.
Tag values can be numeric types, strings, or bools. The behavior of other tag value types is undefined at the OpenTracing level. If a tracing system does not know how to handle a particular value type, it may ignore the tag, but shall not panic.
Returns a reference to this Span for chaining.
func (*Span) Tracer ¶
func (sp *Span) Tracer() opentracing.Tracer
Provides access to the Tracer that created this Span.
type SpanContext ¶
type SpanContext struct {
TraceID int64 `protobuf:"varint,1,opt,name=TraceID,proto3" json:"TraceID,omitempty"`
ParentID int64 `protobuf:"varint,2,opt,name=ParentID,proto3" json:"ParentID,omitempty"`
SamplePriority SamplePriority `protobuf:"varint,3,opt,name=SamplePriority,proto3,enum=opentracing.go.SamplePriority" json:"SamplePriority,omitempty"`
SampleRatio float64 `protobuf:"fixed64,4,opt,name=SampleRatio,proto3" json:"SampleRatio,omitempty"`
Meta map[string]string `` /* 149-byte string literal not displayed */
// contains filtered or unexported fields
}
func SpanContextFromContext ¶
func SpanContextFromContext(ctx context.Context) *SpanContext
func (*SpanContext) Descriptor
deprecated
func (*SpanContext) Descriptor() ([]byte, []int)
Deprecated: Use SpanContext.ProtoReflect.Descriptor instead.
func (*SpanContext) ForeachBaggageItem ¶
func (spctx *SpanContext) ForeachBaggageItem(handler func(k, v string) bool)
func (*SpanContext) GetMeta ¶
func (x *SpanContext) GetMeta() map[string]string
func (*SpanContext) GetParentID ¶
func (x *SpanContext) GetParentID() int64
func (*SpanContext) GetSamplePriority ¶
func (x *SpanContext) GetSamplePriority() SamplePriority
func (*SpanContext) GetSampleRatio ¶
func (x *SpanContext) GetSampleRatio() float64
func (*SpanContext) GetTraceID ¶
func (x *SpanContext) GetTraceID() int64
func (*SpanContext) ProtoMessage ¶
func (*SpanContext) ProtoMessage()
func (*SpanContext) ProtoReflect ¶
func (x *SpanContext) ProtoReflect() protoreflect.Message
func (*SpanContext) Reset ¶
func (x *SpanContext) Reset()
func (*SpanContext) String ¶
func (x *SpanContext) String() string
type SpanNative ¶
type SpanStatus ¶
type SpanStatus int32
const ( SpanStatus_OK SpanStatus = 0 SpanStatus_Error SpanStatus = 1 SpanStatus_Recovery SpanStatus = 2 SpanStatus_Crisis SpanStatus = 3 )
func (SpanStatus) Descriptor ¶
func (SpanStatus) Descriptor() protoreflect.EnumDescriptor
func (SpanStatus) Enum ¶
func (x SpanStatus) Enum() *SpanStatus
func (SpanStatus) EnumDescriptor
deprecated
func (SpanStatus) EnumDescriptor() ([]byte, []int)
Deprecated: Use SpanStatus.Descriptor instead.
func (SpanStatus) Number ¶
func (x SpanStatus) Number() protoreflect.EnumNumber
func (SpanStatus) String ¶
func (x SpanStatus) String() string
func (SpanStatus) Type ¶
func (SpanStatus) Type() protoreflect.EnumType
type SpanTransform ¶
type SpanTransform interface {
RegisterDecoder(contentType string, decoder Decoder)
BuildSpanFrom(native SpanNative) Span
}
type SpanTransformServer ¶
type SpanTransformServer struct {
// contains filtered or unexported fields
}
func (*SpanTransformServer) BuildSpanFrom ¶
func (sts *SpanTransformServer) BuildSpanFrom(native SpanNative) Span
type StartTracerOption ¶
type StartTracerOption func(tracer *Tracer)
func WithFlushBuffer ¶
func WithFlushBuffer(size int) StartTracerOption
func WithFlushInterval ¶
func WithFlushInterval(d time.Duration) StartTracerOption
func WithGlobalTags ¶
func WithGlobalTags(tags map[string]interface{}) StartTracerOption
func WithSampleRatio ¶
func WithSampleRatio(ratio float64) StartTracerOption
type Trace ¶
type Trace struct {
Trace []*Span `protobuf:"bytes,1,rep,name=Trace,proto3" json:"Trace,omitempty"`
// contains filtered or unexported fields
}
func (*Trace) Descriptor
deprecated
func (*Trace) ProtoMessage ¶
func (*Trace) ProtoMessage()
func (*Trace) ProtoReflect ¶
func (x *Trace) ProtoReflect() protoreflect.Message
type TraceNative ¶
type TraceNative interface {
Foreach(handler func(native SpanNative))
}
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
func NewTracer ¶
func NewTracer(service string, opts ...StartTracerOption) *Tracer
func (*Tracer) Extract ¶
func (tcr *Tracer) Extract(format interface{}, carrier interface{}) (opentracing.SpanContext, error)
Extract() returns a SpanContext instance given `format` and `carrier`.
OpenTracing defines a common set of `format` values (see BuiltinFormat), and each has an expected carrier type.
Other packages may declare their own `format` values, much like the keys used by `context.Context` (see https://godoc.org/golang.org/x/net/context#WithValue).
Example usage (with StartSpan):
carrier := opentracing.HTTPHeadersCarrier(httpReq.Header)
clientContext, err := tracer.Extract(opentracing.HTTPHeaders, carrier)
// ... assuming the ultimate goal here is to resume the trace with a
// server-side Span:
var serverSpan opentracing.Span
if err == nil {
span = tracer.StartSpan(
rpcMethodName, ext.RPCServerOption(clientContext))
} else {
span = tracer.StartSpan(rpcMethodName)
}
NOTE: All opentracing.Tracer implementations MUST support all BuiltinFormats.
Return values:
- A successful Extract returns a SpanContext instance and a nil error
- If there was simply no SpanContext to extract in `carrier`, Extract() returns (nil, opentracing.ErrSpanContextNotFound)
- If `format` is unsupported or unrecognized, Extract() returns (nil, opentracing.ErrUnsupportedFormat)
- If there are more fundamental problems with the `carrier` object, Extract() may return opentracing.ErrInvalidCarrier, opentracing.ErrSpanContextCorrupted, or implementation-specific errors.
See Tracer.Inject().
func (*Tracer) Inject ¶
func (tcr *Tracer) Inject(sm opentracing.SpanContext, format interface{}, carrier interface{}) error
Inject() takes the `sm` SpanContext instance and injects it for propagation within `carrier`. The actual type of `carrier` depends on the value of `format`.
OpenTracing defines a common set of `format` values (see BuiltinFormat), and each has an expected carrier type.
Other packages may declare their own `format` values, much like the keys used by `context.Context` (see https://godoc.org/context#WithValue).
Example usage (sans error handling):
carrier := opentracing.HTTPHeadersCarrier(httpReq.Header)
err := tracer.Inject(
span.Context(),
opentracing.HTTPHeaders,
carrier)
NOTE: All opentracing.Tracer implementations MUST support all BuiltinFormats.
Implementations may return opentracing.ErrUnsupportedFormat if `format` is not supported by (or not known by) the implementation.
Implementations may return opentracing.ErrInvalidCarrier or any other implementation-specific error if the format is supported but injection fails anyway.
See Tracer.Extract().
func (*Tracer) StartSpan ¶
func (tcr *Tracer) StartSpan(operationName string, opts ...opentracing.StartSpanOption) opentracing.Span
Create, start, and return a new Span with the given `operationName` and incorporate the given StartSpanOption `opts`. (Note that `opts` borrows from the "functional options" pattern, per http://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis)
A Span with no SpanReference options (e.g., opentracing.ChildOf() or opentracing.FollowsFrom()) becomes the root of its own trace.
Examples:
var tracer opentracing.Tracer = ...
// The root-span case:
sp := tracer.StartSpan("GetFeed")
// The vanilla child span case:
sp := tracer.StartSpan(
"GetFeed",
opentracing.ChildOf(parentSpan.Context()))
// All the bells and whistles:
sp := tracer.StartSpan(
"GetFeed",
opentracing.ChildOf(parentSpan.Context()),
opentracing.Tag{"user_agent", loggedReq.UserAgent},
opentracing.StartTime(loggedReq.Timestamp),
)
type Traces ¶
type Traces struct {
Traces []*Trace `protobuf:"bytes,1,rep,name=Traces,proto3" json:"Traces,omitempty"`
// contains filtered or unexported fields
}
func (*Traces) Descriptor
deprecated
func (*Traces) ProtoMessage ¶
func (*Traces) ProtoMessage()
func (*Traces) ProtoReflect ¶
func (x *Traces) ProtoReflect() protoreflect.Message