spans

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StartFinish SpanMode = "start-finish"
	DirectInfo  SpanMode = "direct-info"

	CustomOwner SpanOwner = "custom"
	K8sOwner    SpanOwner = "k8s"
	OthersOwner SpanOwner = "others"
)
View Source
const (
	SpanAnalysisFeature = "SpanAnalysisFeature"
	SpanIndex           = "spans_consuming"
	SpanDocType         = "_doc"

	JaegerFeature = "JaegerFeature"
)

Variables

This section is empty.

Functions

func EqualsField

func EqualsField(rField reflect.StructField, fieldName string) bool

对比字段的tag与给定的field是否想等

func HandleCrash

func HandleCrash()

func InitKubeSpanWatcher

func InitKubeSpanWatcher(cluster string, otlpAddr string) error

actually cluster is not necessary

func InjectHelperFuncToLua

func InjectHelperFuncToLua(L *lua.LState)

func Loader

func Loader(L *lua.LState) int

func ParseJsonAndProtoTag

func ParseJsonAndProtoTag(tag reflect.StructTag) []string

获取字段的tag,支持json和protobuf两种tag设置

func RegisterLuaHelperFunc

func RegisterLuaHelperFunc(name string, helper func(L *lua.LState) int)

func SpanToSpanID

func SpanToSpanID(name string) trace.SpanID

func UIDToTraceID

func UIDToTraceID(uid string) trace.TraceID

Types

type ExtraProperty

type ExtraProperty struct {
	Name       string `json:"Name,omitempty"`
	Value      string `json:"Value,omitempty"`      //json path to Value
	NeedMetric bool   `json:"NeedMetric,omitempty"` //is need metric
}

type ExtraPropertyConfig

type ExtraPropertyConfig struct {
	Name         string      `json:"Name,omitempty"`
	ValueRex     string      `json:"ValueRex,omitempty"`     //json path to Value
	ValueFetcher *LuaFetcher `json:"ValueFetcher,omitempty"` //json path to Value
	NeedMetric   bool        `json:"NeedMetric,omitempty"`   //is need metric
}

type Field

type Field struct {
	Name      string
	MatchKeys []string // 用户数组元素匹配; match key对应的value必须为string

}

func (*Field) GetFieldKey

func (f *Field) GetFieldKey(value reflect.Value) string

type FieldRef

type FieldRef struct {
	FieldSelector string   `json:"fieldSelector,omitempty"`
	FieldPaths    []*Field `json:"-"`
	PathDelimiter string   `json:"pathDelimiter,omitempty"`
}

func NewFieldRef

func NewFieldRef(fieldSelector string, pathDelimiter string) *FieldRef

func (*FieldRef) GetFieldValue

func (f *FieldRef) GetFieldValue(obj interface{}) map[string]reflect.Value

type HyperEvent

type HyperEvent struct {
	Type        shares.AuditType `json:"Type,omitempty"`
	NameRex     string           `json:"NameRex,omitempty"`
	DurationRex string           `json:"DurationRex,omitempty"`
	Operation   string           `json:"Operation,omitempty"`
	Reason      string           `json:"Reason,omitempty"`
	LuaMatcher  *LuaMatcher      `json:"LuaMatcher,omitempty"`
}

func (*HyperEvent) GetDuration

func (h *HyperEvent) GetDuration(event *shares.AuditEvent) time.Duration

func (*HyperEvent) GetName

func (h *HyperEvent) GetName(event *shares.AuditEvent) map[string]bool

func (*HyperEvent) Match

func (h *HyperEvent) Match(event *shares.AuditEvent, spanName *string) (bool, time.Duration)

type LifeFlag

type LifeFlag struct {
	StartName   *string       `json:"StartName,omitempty"`
	FinishName  *string       `json:"FinishName,omitempty"`
	StartEvent  []*HyperEvent `json:"StartEvent,omitempty"`
	FinishEvent []*HyperEvent `json:"FinishEvent,omitempty"`
}

type LuaFetcher

type LuaFetcher struct {
	Scripts string `json:"Scripts,omitempty"`
}

type LuaMatcher

type LuaMatcher struct {
	Scripts string `json:"Scripts,omitempty"`
}

type ResourceSpanConfig

type ResourceSpanConfig struct {
	ObjectRef       *audit.ObjectReference          `json:"ObjectRef,omitempty"`
	ActionType      string                          `json:"ActionType,omitempty"` //span计算类型
	LifeFlag        *LifeFlag                       `json:"LifeFlag,omitempty"`   //标记Span的开始和结束
	Spans           []*SpanConfig                   `json:"Spans,omitempty"`
	ExtraProperties map[string]*ExtraPropertyConfig `json:"ExtraProperties,omitempty"` //需要提取的属性 map[name] = [json.path.to.value]
}

func (*ResourceSpanConfig) GetExtraPropertyNames

func (r *ResourceSpanConfig) GetExtraPropertyNames() []string

func (*ResourceSpanConfig) Initial

func (r *ResourceSpanConfig) Initial(object runtime.Object, uid string, properties utils.ConcurrentMap) (map[string]string, map[string]*Span)

func (*ResourceSpanConfig) IsFinishToTrack

func (r *ResourceSpanConfig) IsFinishToTrack(ev *shares.AuditEvent) bool

func (*ResourceSpanConfig) IsStartToTrack

func (r *ResourceSpanConfig) IsStartToTrack(ev *shares.AuditEvent) bool

type ResourceSpanConfigList

type ResourceSpanConfigList []*ResourceSpanConfig

func NewResourceSpanConfigList

func NewResourceSpanConfigList() ResourceSpanConfigList

func (*ResourceSpanConfigList) GetConfigByRef

func (*ResourceSpanConfigList) GetExtraPropertyNames

func (r *ResourceSpanConfigList) GetExtraPropertyNames() []string

type Span

type Span struct {
	Name  string
	Type  string
	Begin time.Time
	End   time.Time

	Elapsed    int64
	Cluster    string
	ActionType string
	TimeStamp  time.Time
	Omitempty  bool
	// contains filtered or unexported fields
}

func (*Span) Emptry

func (s *Span) Emptry() bool

func (*Span) GetConfig

func (s *Span) GetConfig() *SpanConfig

func (*Span) Reset

func (s *Span) Reset()

func (*Span) SetConfig

func (s *Span) SetConfig(sc *SpanConfig)

func (*Span) SetElapsed

func (s *Span) SetElapsed(d time.Duration)

type SpanConfig

type SpanConfig struct {
	Name        string        `json:"Name,omitempty"`    // span name
	Type        string        `json:"Type,omitempty"`    // span type
	NameRef     *string       `json:"NameRef,omitempty"` // json path
	Mode        SpanMode      `json:"Mode,omitempty"`
	DirectEvent []*HyperEvent `json:"DirectEvent,omitempty"`
	StartEvent  []*HyperEvent `json:"StartEvent,omitempty"`
	EndEvent    []*HyperEvent `json:"EndEvent,omitempty"`
	Omitempty   bool          `json:"Omitempty,omitempty"`
	SpanOwner   SpanOwner     `json:"SpanOwner,omitempty"`
	NeedClose   bool          `json:"NeedClose,omitempty"` // if need to close the span which does not have end time
}

func (*SpanConfig) Initial

func (s *SpanConfig) Initial(object runtime.Object) map[string]*Span

func (*SpanConfig) Update

func (s *SpanConfig) Update(event *shares.AuditEvent, span *Span)

type SpanMeta

type SpanMeta struct {
	ObjectRef *audit.ObjectReference
	Spans     []*Span

	//properties
	Cluster           string
	CreationTimestamp time.Time
	ExtraProperties   utils.ConcurrentMap
	// contains filtered or unexported fields
}

func NewSpanMeta

func NewSpanMeta(config *ResourceSpanConfig, cluster string, createTime time.Time, event *shares.AuditEvent) *SpanMeta

func (*SpanMeta) SpanConfig

func (s *SpanMeta) SpanConfig() *ResourceSpanConfig

func (*SpanMeta) TrackSpan

func (s *SpanMeta) TrackSpan(event *shares.AuditEvent)

type SpanMode

type SpanMode string

type SpanOwner

type SpanOwner string

type SpanProcessor

type SpanProcessor struct {
	Cluster string

	SpanMetas *sync.Map
	// contains filtered or unexported fields
}
var (
	WatcherQueue          *queue.BoundedQueue
	DeliverySpanProcessor *SpanProcessor
)

func NewSpanProcessor

func NewSpanProcessor(cluster string) *SpanProcessor

func (*SpanProcessor) Compact

func (p *SpanProcessor) Compact()

func (*SpanProcessor) ProcessEvent

func (p *SpanProcessor) ProcessEvent(ev *shares.AuditEvent)

this function should be thread safe

func (*SpanProcessor) RefreshConfig

func (p *SpanProcessor) RefreshConfig()

type TraceErrorHandler

type TraceErrorHandler struct{}

func (*TraceErrorHandler) Handle

func (*TraceErrorHandler) Handle(err error)

type Writer

type Writer interface {
	Write(p *SpanMeta) error
}

type XSearchWriter

type XSearchWriter struct {
	// contains filtered or unexported fields
}

func NewXSearchWriter

func NewXSearchWriter() (*XSearchWriter, error)

func (*XSearchWriter) Write

func (x *XSearchWriter) Write(p *SpanMeta) error

Jump to

Keyboard shortcuts

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