tracing

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DataChecksum

func DataChecksum(data []interface{}) (uint32, error)

DataChecksum calculates the checksum of a given interface{} slice. each interface{} is first converted to []byte via gob encoder, then combines all of them in sequence, at last calculate the crc32 using IEEE polynomial.

func GetTraceCode

func GetTraceCode(skip int) (string, int, error)

GetTraceCode returns file and line number information about function invocations on the calling goroutine's stack. The argument skip is the number of stack frames to ascend, with 0 identifying the caller of runtime.Caller.

Types

type Config

type Config struct {
	Enable     bool   `toml:"enable" json:"enable"`           // whether to enable tracing
	Source     string `toml:"source" json:"source"`           // trace event source id
	TracerAddr string `toml:"tracer-addr" json:"tracer-addr"` // tracing service rpc address
	BatchSize  int    `toml:"batch-size" json:"batch-size"`   // upload trace event batch size
	Checksum   bool   `toml:"checksum" json:"checksum"`       // whether to caclculate checksum of data
}

Config is the configuration for tracer

type EventType

type EventType byte

EventType represents trace event type

const (
	EventNull EventType = iota
	EventSyncerBinlog
	EventSyncerJob
	EventFlush // used to force upload tracing event
)

EventType list

func (EventType) String

func (e EventType) String() string

type IDGenerator

type IDGenerator struct {
	sync.Mutex
	// contains filtered or unexported fields
}

IDGenerator is a simple ID generator

func NewIDGen

func NewIDGen() *IDGenerator

NewIDGen returns a new IDGenerator

func (*IDGenerator) NextID

func (g *IDGenerator) NextID(source string, offset int64) string

NextID returns a new ID under namespace of `source`, in the name of `source`.index

type Job

type Job struct {
	Tp    EventType
	Event interface{}
}

Job is used for tracing evnets collecting and batch uploading

type Tracer

type Tracer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Tracer is a tracing service provider

func GetTracer

func GetTracer() *Tracer

GetTracer returns the tracer instance. If InitTracerHub is not called, returns a default disabled tracer.

func InitTracerHub

func InitTracerHub(cfg Config) *Tracer

InitTracerHub inits the singleton instance of TracerHub

func NewTracer

func NewTracer(cfg Config) *Tracer

NewTracer creates a new Tracer

func (*Tracer) AddJob

func (t *Tracer) AddJob(job *Job)

AddJob add a job to tracer

func (*Tracer) CollectSyncerBinlogEvent

func (t *Tracer) CollectSyncerBinlogEvent(source string, safeMode, tryReSync bool, globalPos, currentPos mysql.Position, eventType, opType int32) (*pb.SyncerBinlogEvent, error)

CollectSyncerBinlogEvent collects syncer binlog event and returns the trace event traceID

func (*Tracer) CollectSyncerJobEvent

func (t *Tracer) CollectSyncerJobEvent(traceID string, traceGID string, opType int32, pos, currentPos mysql.Position, queueBucket, sql string, ddls []string, args []interface{}, req *pb.ExecDDLRequest, state pb.SyncerJobState) (*pb.SyncerJobEvent, error)

CollectSyncerJobEvent collects syncer job event and returns traceID

func (*Tracer) Enable

func (t *Tracer) Enable() bool

Enable returns whether tracing is enabled

func (*Tracer) FinishedSyncerJobState

func (t *Tracer) FinishedSyncerJobState(err error) pb.SyncerJobState

FinishedSyncerJobState returns pb.SyncerJobState according to given error

func (*Tracer) GetTSO

func (t *Tracer) GetTSO() int64

GetTSO returns current tso

func (*Tracer) GetTraceID

func (t *Tracer) GetTraceID(source string) string

GetTraceID returns a new traceID for tracing

func (*Tracer) ProcessTraceEvents

func (t *Tracer) ProcessTraceEvents(jobs []*Job) error

ProcessTraceEvents upload trace events to tracing service. ensure all jobs have same EventType

func (*Tracer) Start

func (t *Tracer) Start()

Start starts tracing service

func (*Tracer) Stop

func (t *Tracer) Stop()

Stop stops tracer

type TracerHub

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

TracerHub holds a tracer

Jump to

Keyboard shortcuts

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