tracer

package
v0.0.0-...-719f2d6 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateEndpointTable

func CreateEndpointTable(db sqlx.SqlConn) error

func CreateL34Table

func CreateL34Table(db sqlx.SqlConn) error

func CreateL7Table

func CreateL7Table(db sqlx.SqlConn) error

func CreateSockTable

func CreateSockTable(db sqlx.SqlConn) error

func NewL34Inserter

func NewL34Inserter(db sqlx.SqlConn) (*sqlx.BulkInserter, error)

func NewL7Inserter

func NewL7Inserter(db sqlx.SqlConn) (*sqlx.BulkInserter, error)

func NewSockInserter

func NewSockInserter(db sqlx.SqlConn) (*sqlx.BulkInserter, error)

Types

type ExFlow

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

ExFlow stands for Exceptional Flow

type Flow

type Flow interface {
	// Check 预检查流量
	Check(flow *flowpb.Flow) error

	// Build 基于 manager 上下文构建字段
	Build(flow *observerpb.Flow) error

	// Insert 插入数据库
	Insert() error

	// MarkExFlow 标记异常流量
	MarkExFlow(exFlow ExFlow)

	// Consume 消费流量,not error but log
	Consume(flow *flowpb.Flow)
}

Flow operate 为三种 flow 抽象出父类:l34_flow、sock_flow、l7_flow(PreSpan)。

type L34Flow

type L34Flow struct {
	L34FlowEntity
	// contains filtered or unexported fields
}

func (*L34Flow) Build

func (l *L34Flow) Build(flow *observerpb.Flow) error

func (*L34Flow) Check

func (l *L34Flow) Check(flow *flowpb.Flow) error

func (*L34Flow) Consume

func (l *L34Flow) Consume(flow *flowpb.Flow)

func (*L34Flow) Insert

func (l *L34Flow) Insert() error

func (*L34Flow) MarkExFlow

func (l *L34Flow) MarkExFlow(exFlow ExFlow)

type L34FlowEntity

type L34FlowEntity struct {
	Time      time.Time `db:"time"`      // 捕获时间。
	Namespace string    `db:"namespace"` // 流量相关名字空间,存在“或”逻辑。

	SrcIdentity  uint32 `db:"src_identity"`  // NumericIdentity 的数值类型为 uint32,且用 0 作为空值。
	DestIdentity uint32 `db:"dest_identity"` //

	IsReply            bool   `db:"is_reply"`            // 区分流量方向1。
	TrafficDirection   string `db:"traffic_direction"`   // 区分流量方向2,一般是这两种 "INGRESS" 或 "EGRESS"。
	TrafficObservation string `db:"traffic_observation"` // 捕获位置,@pkg/monitor/api/types.go:150
	Verdict            string `db:"verdict"`             // 一般是这两种 "FORWARDED" 或 "DROPPED"。

	EventType int8 `db:"event_type"` // 事件类型,@pkg/monitor/api/types.go:18
	SubType   int8 `db:"sub_type"`   // 事件子类型,@pkg/monitor/api/types.go:217

}

type L7Flow

type L7Flow struct {
	L7FlowEntity
	// contains filtered or unexported fields
}

L7Flow 别名 Span、PreSpan。

func (*L7Flow) Build

func (l *L7Flow) Build(flow *observerpb.Flow) error

func (*L7Flow) Check

func (l *L7Flow) Check(flow *flowpb.Flow) error

func (*L7Flow) Consume

func (l *L7Flow) Consume(flow *flowpb.Flow)

Consume 异步处理,且需要 WG 同步

func (*L7Flow) Insert

func (l *L7Flow) Insert() error

func (*L7Flow) MarkExFlow

func (l *L7Flow) MarkExFlow(exFlow ExFlow)

type L7FlowEntity

type L7FlowEntity struct {
	ID      string `db:"id"`       // UUID32 格式的 SpanID
	TraceID string `db:"trace_id"` // UUID16、X-B3-Traceid 格式的 TraceID

	SrcIdentity uint32 `db:"src_identity"` // identity 是对服务组的编址
	SrcPod      string `db:"src_pod"`      // pod_name 是对 pod 的编址,类似的有 endpoint

	DestIdentity uint32 `db:"dest_identity"`
	DestPod      string `db:"dest_pod"`

	StartTime time.Time `db:"start_time"` // 请求发出时间
	EndTime   time.Time `db:"end_time"`   // 响应发出时间(不是响应被接收的时间)

}

type Olap

type Olap struct {

	// 活跃 namespace 列表,通过 Hubble 更新
	ActiveNamespaces []string
	// contains filtered or unexported fields
}

func NewOlap

func NewOlap(vp *viper.Viper) *Olap

func (*Olap) CheckSpansCount

func (o *Olap) CheckSpansCount(namespace string) bool

CheckSpansCount 检查某一 namespace 下的 span 是否增加了 true 代表增加了

func (*Olap) Conn

func (o *Olap) Conn() sqlx.SqlConn

func (*Olap) GetSpanCount

func (o *Olap) GetSpanCount(namespace string) int

func (*Olap) RemoveSpanCount

func (o *Olap) RemoveSpanCount(namespace string)

func (*Olap) SelectL7Spans

func (o *Olap) SelectL7Spans(spans *[]*L7FlowEntity, trace_id string)

SelectL7Spans 选择某一 trace_id 下的全体 span

func (*Olap) SummaryExFlows

func (o *Olap) SummaryExFlows()

type PostSpan

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

type PreSpan

type PreSpan = L7FlowEntity

type SockFlow

type SockFlow struct {
	SockFlowEntity
	// contains filtered or unexported fields
}

func (*SockFlow) Build

func (s *SockFlow) Build(flow *observerpb.Flow) error

func (*SockFlow) Check

func (s *SockFlow) Check(flow *flowpb.Flow) error

func (*SockFlow) Consume

func (s *SockFlow) Consume(flow *flowpb.Flow)

func (*SockFlow) Insert

func (s *SockFlow) Insert() error

func (*SockFlow) MarkExFlow

func (s *SockFlow) MarkExFlow(exFlow ExFlow)

type SockFlowEntity

type SockFlowEntity struct {
	Time      time.Time `db:"time"`      // 捕获时间。
	Namespace string    `db:"namespace"` // 流量相关名字空间,存在“或”逻辑。

	SrcIdentity  uint32 `db:"src_identity"`  // NumericIdentity 的数值类型为 uint32,且用 0 作为空值。
	DestIdentity uint32 `db:"dest_identity"` //

	EventType int8 `db:"event_type"` // 事件类型,@pkg/monitor/api/types.go:18
	SubType   int8 `db:"sub_type"`   // 事件子类型,@pkg/monitor/api/types.go:217
	CgroupId  int  `db:"cgroup_id"`  // todo 可能与 identity 作用重复,后面可能删掉

}

type Tracer

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

func (*Tracer) Assemble

func (t *Tracer) Assemble(kind int, amCtx context.Context) error

func (*Tracer) BasicAssemble

func (t *Tracer) BasicAssemble(amCtx context.Context) error

BasicAssemble 离线算法,输入完备的 Span 数据。 返回 trace,返回的是该 Trace 的根 Span,提供给测试。

type TracerManager

type TracerManager struct {
	ShutdownCtx context.Context
	// contains filtered or unexported fields
}

func NewTracerManager

func NewTracerManager(vp *viper.Viper) *TracerManager

func (*TracerManager) Assemble

func (tm *TracerManager) Assemble(traceID string)

状态机控制在更加上层

func (*TracerManager) AssembleAll

func (tm *TracerManager) AssembleAll()

func (*TracerManager) CheckSpansCount

func (tm *TracerManager) CheckSpansCount(trace_id string) bool

func (*TracerManager) ConsumeFlow

func (tm *TracerManager) ConsumeFlow(flow *observerpb.Flow)

ConsumeFlow 消耗一条 Flow 数据,针对不同的 flow 类型进行分发

func (*TracerManager) Flush

func (tm *TracerManager) Flush()

func (*TracerManager) InitDummyExporter

func (tm *TracerManager) InitDummyExporter() (func(context.Context) error, error)

InitDummyExporter only for testing purposes

func (*TracerManager) InitGRPCExporter

func (tm *TracerManager) InitGRPCExporter(shutdownCtx context.Context) (func(context.Context) error, error)

func (*TracerManager) InitStdoutExporter

func (tm *TracerManager) InitStdoutExporter() (func(context.Context) error, error)

func (*TracerManager) Olap

func (tm *TracerManager) Olap() *Olap

func (*TracerManager) Summary

func (tm *TracerManager) Summary()

Jump to

Keyboard shortcuts

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