Documentation ¶
Index ¶
- Constants
- func ContextField(ctx context.Context) zap.Field
- func ContextWithSpan(parent context.Context, span Span) context.Context
- func ContextWithSpanContext(parent context.Context, sc SpanContext) context.Context
- func Generate(ctx context.Context) context.Context
- func IsEnable() bool
- func IsSpanField(field zapcore.Field) bool
- func SetDefaultTracer(tracer Tracer)
- func SpanField(sc SpanContext) zap.Field
- func WithKind(kind SpanKind) spanOptionFunc
- func WithNewRoot(newRoot bool) spanOptionFunc
- type IDGenerator
- type ITracerHolder
- type MONodeResource
- type NonRecordingSpan
- type NoopSpan
- type NoopTracer
- type Resource
- type Span
- type SpanConfig
- type SpanContext
- func (c SpanContext) GetIDs() (TraceID, SpanID)
- func (c *SpanContext) IsEmpty() bool
- func (c *SpanContext) MarshalLogObject(enc zapcore.ObjectEncoder) error
- func (c *SpanContext) MarshalTo(dAtA []byte) (int, error)
- func (c *SpanContext) Reset()
- func (c *SpanContext) Size() (n int)
- func (c *SpanContext) Unmarshal(dAtA []byte) error
- type SpanEndOption
- type SpanID
- type SpanKind
- type SpanOption
- type SpanProcessor
- type SpanStartOption
- type TraceFlags
- type TraceID
- type Tracer
- type TracerConfig
- type TracerOption
- type TracerProvider
Constants ¶
const ( FlagProfileGoroutine = 1 << iota FlagProfileHeap FlagProfileCpu )
const ( // FlagsSampled is a bitmask with the sampled bit set. A SpanContext // with the sampling bit set means the span is sampled. FlagsSampled = TraceFlags(0x01) )
const NodeTypeStandalone = "Standalone"
const SpanFieldKey = "span"
Variables ¶
This section is empty.
Functions ¶
func ContextWithSpanContext ¶
func ContextWithSpanContext(parent context.Context, sc SpanContext) context.Context
func IsSpanField ¶
func SetDefaultTracer ¶ added in v0.7.0
func SetDefaultTracer(tracer Tracer)
func SpanField ¶
func SpanField(sc SpanContext) zap.Field
func WithNewRoot ¶
func WithNewRoot(newRoot bool) spanOptionFunc
Types ¶
type IDGenerator ¶
type ITracerHolder ¶ added in v0.8.0
type ITracerHolder interface {
GetTracer() Tracer
}
type MONodeResource ¶
type NonRecordingSpan ¶ added in v0.7.0
type NonRecordingSpan struct { NoopSpan // contains filtered or unexported fields }
NonRecordingSpan keep SpanContext{TraceID, SpanID}
func (*NonRecordingSpan) ParentSpanContext ¶ added in v0.7.0
func (s *NonRecordingSpan) ParentSpanContext() SpanContext
func (*NonRecordingSpan) SpanContext ¶ added in v0.7.0
func (s *NonRecordingSpan) SpanContext() SpanContext
type NoopSpan ¶ added in v0.7.0
type NoopSpan struct{}
NoopSpan is an implementation of Span that preforms no operations.
func (NoopSpan) AddExtraFields ¶ added in v0.8.0
func (NoopSpan) ParentSpanContext ¶ added in v0.7.0
func (NoopSpan) ParentSpanContext() SpanContext
func (NoopSpan) SpanContext ¶ added in v0.7.0
func (NoopSpan) SpanContext() SpanContext
SpanContext returns an empty span context.
func (NoopSpan) TracerProvider ¶ added in v0.7.0
func (NoopSpan) TracerProvider() TracerProvider
TracerProvider returns a no-op TracerProvider.
type NoopTracer ¶ added in v0.7.0
type NoopTracer struct{}
NoopTracer is an implementation of Tracer that preforms no operations.
func (NoopTracer) Debug ¶ added in v0.7.0
func (t NoopTracer) Debug(ctx context.Context, name string, opts ...SpanStartOption) (context.Context, Span)
func (NoopTracer) IsEnable ¶ added in v0.7.0
func (t NoopTracer) IsEnable() bool
func (NoopTracer) Start ¶ added in v0.7.0
func (t NoopTracer) Start(ctx context.Context, name string, opts ...SpanStartOption) (context.Context, Span)
Start carries forward a non-recording Span, if one is present in the context, otherwise it creates a no-op Span.
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
func NewResource ¶ added in v0.7.0
func NewResource() *Resource
type Span ¶
type Span interface { // End completes the Span. The Span is considered complete and ready to be // delivered through the rest of the telemetry pipeline after this method // is called. Therefore, updates to the Span are not allowed after this // method has been called. End(options ...SpanEndOption) // AddExtraFields inject more details for span. AddExtraFields(fields ...zap.Field) // SpanContext returns the SpanContext of the Span. The returned SpanContext // is usable even after the End method has been called for the Span. SpanContext() SpanContext ParentSpanContext() SpanContext }
func SpanFromContext ¶
type SpanConfig ¶
type SpanConfig struct { SpanContext // NewRoot identifies a Span as the root Span for a new trace. This is // commonly used when an existing trace crosses trust boundaries and the // remote parent span context should be ignored for security. NewRoot bool `json:"NewRoot"` // WithNewRoot Parent Span `json:"-"` // LongTimeThreshold set by WithLongTimeThreshold LongTimeThreshold time.Duration `json:"-"` // contains filtered or unexported fields }
SpanConfig is a group of options for a Span.
func (*SpanConfig) GetLongTimeThreshold ¶ added in v0.8.0
func (c *SpanConfig) GetLongTimeThreshold() time.Duration
func (*SpanConfig) ProfileCpuSecs ¶ added in v0.8.0
func (c *SpanConfig) ProfileCpuSecs() time.Duration
ProfileCpuSecs return the value set by WithProfileCpuSecs
func (*SpanConfig) ProfileGoroutine ¶ added in v0.8.0
func (c *SpanConfig) ProfileGoroutine() bool
ProfileGoroutine return the value set by WithProfileGoroutine
func (*SpanConfig) ProfileHeap ¶ added in v0.8.0
func (c *SpanConfig) ProfileHeap() bool
ProfileHeap return the value set by WithProfileHeap
func (*SpanConfig) Reset ¶ added in v0.8.0
func (c *SpanConfig) Reset()
type SpanContext ¶
type SpanContext struct { TraceID TraceID `json:"trace_id"` SpanID SpanID `json:"span_id"` // Kind default SpanKindInternal Kind SpanKind `json:"span_kind"` }
SpanContext contains identifying trace information about a Span.
func SpanContextWithID ¶
func SpanContextWithID(id TraceID, kind SpanKind) SpanContext
func SpanContextWithIDs ¶
func SpanContextWithIDs(tid TraceID, sid SpanID) SpanContext
SpanContextWithIDs with default Kind: SpanKindInternal
func (SpanContext) GetIDs ¶
func (c SpanContext) GetIDs() (TraceID, SpanID)
func (*SpanContext) IsEmpty ¶
func (c *SpanContext) IsEmpty() bool
func (*SpanContext) MarshalLogObject ¶
func (c *SpanContext) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject implement zapcore.ObjectMarshaler
func (*SpanContext) Reset ¶
func (c *SpanContext) Reset()
func (*SpanContext) Size ¶
func (c *SpanContext) Size() (n int)
func (*SpanContext) Unmarshal ¶
func (c *SpanContext) Unmarshal(dAtA []byte) error
Unmarshal with default Kind: SpanKindRemote
type SpanEndOption ¶
type SpanEndOption interface {
ApplySpanEnd(*SpanConfig)
}
type SpanID ¶
type SpanID [8]byte
var NilSpanID SpanID
type SpanKind ¶
type SpanKind int
SpanKind is the role a Span plays in a Trace.
const ( // SpanKindInternal is a SpanKind for a Span that represents an internal // operation within MO. SpanKindInternal SpanKind = 0 // SpanKindStatement is a SpanKind for a Span that represents the operation // belong to statement query SpanKindStatement SpanKind = 1 // SpanKindRemote is a SpanKind for a Span that represents the operation // cross rpc SpanKindRemote SpanKind = 2 // SpanKindSession is a SpanKind for a Span that represents the operation // start from session SpanKindSession SpanKind = 3 )
type SpanOption ¶
type SpanOption interface { SpanStartOption SpanEndOption }
SpanOption applies an option to a SpanConfig.
type SpanProcessor ¶
type SpanStartOption ¶
type SpanStartOption interface {
ApplySpanStart(*SpanConfig)
}
SpanStartOption applies an option to a SpanConfig. These options are applicable only when the span is created.
func WithLongTimeThreshold ¶ added in v0.8.0
func WithLongTimeThreshold(d time.Duration) SpanStartOption
func WithProfileCpuSecs ¶ added in v0.8.0
func WithProfileCpuSecs(d time.Duration) SpanStartOption
WithProfileCpuSecs give duration while do pprof more details in MOSpan.doProfile. Please carefully to set this value, it will trigger the sync ProfileCpu op
func WithProfileGoroutine ¶ added in v0.8.0
func WithProfileGoroutine() SpanStartOption
func WithProfileHeap ¶ added in v0.8.0
func WithProfileHeap() SpanStartOption
type TraceFlags ¶
type TraceFlags byte //nolint:revive // revive complains about stutter of `trace.TraceFlags`.
TraceFlags contains flags that can be set on a SpanContext.
func (TraceFlags) IsSampled ¶
func (tf TraceFlags) IsSampled() bool
IsSampled returns if the sampling bit is set in the TraceFlags.
func (TraceFlags) String ¶
func (tf TraceFlags) String() string
String returns the hex string representation form of TraceFlags.
func (TraceFlags) WithSampled ¶
func (tf TraceFlags) WithSampled(sampled bool) TraceFlags
WithSampled sets the sampling bit in a new copy of the TraceFlags.
type TraceID ¶
type TraceID [16]byte
var NilTraceID TraceID
type Tracer ¶
type Tracer interface { // Start creates a span and a context.Context containing the newly-created span. Start(ctx context.Context, spanName string, opts ...SpanStartOption) (context.Context, Span) // Debug creates a span only with DebugMode Debug(ctx context.Context, spanName string, opts ...SpanStartOption) (context.Context, Span) // IsEnable return true, means do record IsEnable() bool }
func DefaultTracer ¶ added in v0.7.0
func DefaultTracer() Tracer
type TracerConfig ¶
type TracerConfig struct {
Name string
}
TracerConfig is a group of options for a Tracer.
type TracerOption ¶
type TracerOption interface {
Apply(*TracerConfig)
}
TracerOption applies an option to a TracerConfig.
type TracerProvider ¶
type TracerProvider interface {
Tracer(instrumentationName string, opts ...TracerOption) Tracer
}