trace

package
v0.1.2-test Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TraceFeature           = "TraceFeature"
	TraceContextAnnotation = "meta.lunettes.com/trace-context"
)
View Source
const (
	OpenTraceStatus   TraceStatus = "open"
	ClosedTraceStatus TraceStatus = "closed"

	CreateDelivery string = "create"
	StartDelivery  string = "start"
	StopDelivery   string = "stop"
)

Variables

View Source
var (
	WatcherQueue *queue.BoundedQueue
)

Functions

func EqualsField

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

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

func HandleCrash

func HandleCrash()

func InitKubeTraceWatcher

func InitKubeTraceWatcher(cluster string, otlpAddr string) error

func ParseJsonAndProtoTag

func ParseJsonAndProtoTag(tag reflect.StructTag) []string

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

func StringToSpanID

func StringToSpanID(name string) trace.SpanID

func StringToTraceID

func StringToTraceID(name 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"`
	MatchRex    string           `json:"MatchRex,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) IsMatchRex

func (h *HyperEvent) IsMatchRex(event *shares.AuditEvent) 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, globalSpans utils.ConcurrentMap, properties utils.ConcurrentMap) (map[string]string, map[string]*Span, []*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
	Children   []*Span
	// contains filtered or unexported fields
}

func (*Span) Empty

func (s *Span) Empty() bool

func (*Span) Finish

func (s *Span) Finish(endTime time.Time)

func (*Span) InjectAttributesToSpan

func (s *Span) InjectAttributesToSpan()

func (*Span) SetElapsed

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

func (*Span) Update

func (s *Span) Update(event *shares.AuditEvent)

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
	Component string   `json:"Component,omitempty"` // span owner
	Mode      SpanMode `json:"Mode,omitempty"`

	DirectEvent []*HyperEvent `json:"DirectEvent,omitempty"`
	StartEvent  []*HyperEvent `json:"StartEvent,omitempty"`
	EndEvent    []*HyperEvent `json:"EndEvent,omitempty"`
	Children    []*SpanConfig `json:"Children,omitempty"`
	ErrorEvent  []*HyperEvent `json:"ErrorEvent,omitempty"`

	Omitempty bool `json:"Omitempty,omitempty"`
	NeedClose bool `json:"NeedClose,omitempty"` //need to close the span which does not have end time
}

func (*SpanConfig) Initial

func (s *SpanConfig) Initial(object runtime.Object, globalSpans utils.ConcurrentMap) (map[string]*Span, []*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

	trace.SpanContextConfig
	ParentSpanID trace.SpanID

	Begin time.Time
	End   time.Time
	// contains filtered or unexported fields
}

func NewSpanMeta

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

func (*SpanMeta) Finish

func (s *SpanMeta) Finish(ev *shares.AuditEvent)

func (*SpanMeta) TackSpan

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

type SpanMode

type SpanMode string
const (
	StartFinish SpanMode = "start-finish"
	DirectInfo  SpanMode = "direct-info"
)

type SpanProcessor

type SpanProcessor struct {
	Cluster string

	SpanMetas *sync.Map
	// contains filtered or unexported fields
}

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 TraceInfo

type TraceInfo struct {
	TraceID      string          `json:"trace_id"`
	ParentSpanID string          `json:"parent_id"`
	RootSpanID   string          `json:"root_span_id"`
	DeliveryType string          `json:"delivery_type"`
	Status       TraceStatus     `json:"status"`
	Services     []*TraceService `json:"services"`
	StartAt      string          `json:"start_at"`
	FinishAt     string          `json:"finish_at"`
}

type TraceService

type TraceService struct {
	Component string `json:"component"`
	SpanID    string `json:"span_id"`
}

type TraceStatus

type TraceStatus string

Jump to

Keyboard shortcuts

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