tracing

package
v1.3.0-policy Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ResourceTypeNetworkService represents resource of a network service
	ResourceTypeNetworkService = "network_service"
	// ResourceTypeResourcePool represents resource of a resource pool(object pool)
	ResourceTypeResourcePool = "resource_pool"
	// ResourceTypeFactory represents resource of a factory(eniip/eni)
	ResourceTypeFactory = "factory"

	// DisposeResourceFailed DisposeResourceFailed
	DisposeResourceFailed = "DisposeResourceFailed"
	// AllocResourceFailed AllocResourceFailed
	AllocResourceFailed = "AllocResourceFailed"
)

Variables

This section is empty.

Functions

func DefaultRPCServer

func DefaultRPCServer() rpc.TerwayTracingServer

DefaultRPCServer returns the RPC server for default tracer

func RPCServer

func RPCServer(tracer *Tracer) rpc.TerwayTracingServer

RPCServer returns RPC server for the given tracer

func RecordNodeEvent

func RecordNodeEvent(eventType, reason, message string) error

RecordNodeEvent records node event via PodEventRecorder

func RecordPodEvent

func RecordPodEvent(podName, podNamespace, eventType, reason, message string) error

RecordPodEvent records pod event via PodEventRecorder

func Register

func Register(typ, resourceName string, handler TraceHandler) error

Register registers a TraceHandler to the default tracer

func RegisterEventRecorder

func RegisterEventRecorder(node NodeEventRecorder, pod PodEventRecorder)

RegisterEventRecorder registers pod & node event recorder to a tracer

func RegisterResourceMapping

func RegisterResourceMapping(handler ResMapping)

RegisterResourceMapping register resource mapping handler to the default tracer

func Unregister

func Unregister(typ, resourceName string)

Unregister removes TraceHandler from tracer. do nothing if not found

Types

type FakeResourcePoolStats

type FakeResourcePoolStats struct {
	Local  map[string]types.Res
	Remote map[string]types.Res
}

FakeResourcePoolStats for test

func (*FakeResourcePoolStats) GetLocal

func (f *FakeResourcePoolStats) GetLocal() map[string]types.Res

GetLocal GetLocal

func (*FakeResourcePoolStats) GetRemote

func (f *FakeResourcePoolStats) GetRemote() map[string]types.Res

GetRemote GetRemote

type MapKeyValueEntry

type MapKeyValueEntry struct {
	Key   string
	Value string
}

MapKeyValueEntry uses for a in-order key-value store

type NodeEventRecorder

type NodeEventRecorder func(eventType, reason, message string)

NodeEventRecorder records event on node

type PodEventRecorder

type PodEventRecorder func(podName, podNamespace, eventType, reason, message string) error

PodEventRecorder records event on pod

type PodMapping

type PodMapping struct {
	Name      string
	Namespace string
	Valid     bool

	PodBindResID string
	LocalResID   string
	RemoteResID  string
}

PodMapping PodMapping

type ResMapping

type ResMapping interface {
	GetResourceMapping() ([]*PodMapping, error)
}

ResMapping ResMapping

type ResourceMappingHandler

type ResourceMappingHandler interface {
	GetResourceMapping() (ResourcePoolStats, error)
}

ResourceMappingHandler get resource mapping

type ResourcePoolStats

type ResourcePoolStats interface {
	GetLocal() map[string]types.Res
	GetRemote() map[string]types.Res
}

ResourcePoolStats define two pool lo and remote

type TraceHandler

type TraceHandler interface {
	// Config() returns the static resource config (like min_idle, max_idle, etc) as []MapKeyValueEntry
	Config() []MapKeyValueEntry
	// Trace() returns the trace info (like ENIs count, MAC address) as []MapKeyValueEntry
	Trace() []MapKeyValueEntry
	// Execute(string, []string) execute command in the registered resource, and returns a string channel as stream
	// if the execution has done, the channel should be closed
	Execute(cmd string, args []string, message chan<- string)
}

TraceHandler declares functions should be implemented in a tracing component

type Tracer

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

Tracer manages tracing handlers registered from the system

func NewTracer

func NewTracer() *Tracer

NewTracer creates a new tracer

func (*Tracer) Execute

func (t *Tracer) Execute(typ, resourceName, cmd string, args []string) (<-chan string, error)

Execute invokes Execute() function of the given type & resource name with command and arguments

func (*Tracer) GetConfig

func (t *Tracer) GetConfig(typ, resourceName string) ([]MapKeyValueEntry, error)

GetConfig invokes Config() function of the given type & resource name

func (*Tracer) GetResourceMapping

func (t *Tracer) GetResourceMapping() ([]*PodMapping, error)

GetResourceMapping gives the resource mapping from the handler if the handler has not been registered, there will be error

func (*Tracer) GetResourceNames

func (t *Tracer) GetResourceNames(typ string) []string

GetResourceNames lists resource names of a certain type

func (*Tracer) GetTrace

func (t *Tracer) GetTrace(typ, resourceName string) ([]MapKeyValueEntry, error)

GetTrace invokes Trace() function of the given type & resource name

func (*Tracer) GetTypes

func (t *Tracer) GetTypes() []string

GetTypes gets all types registered to the tracer

func (*Tracer) RecordNodeEvent

func (t *Tracer) RecordNodeEvent(eventType, reason, message string) error

RecordNodeEvent records node event via PodEventRecorder

func (*Tracer) RecordPodEvent

func (t *Tracer) RecordPodEvent(podName, podNamespace, eventType, reason, message string) error

RecordPodEvent records pod event via PodEventRecorder

func (*Tracer) Register

func (t *Tracer) Register(typ, resourceName string, handler TraceHandler) error

Register registers a TraceHandler to the tracer

func (*Tracer) RegisterEventRecorder

func (t *Tracer) RegisterEventRecorder(node NodeEventRecorder, pod PodEventRecorder)

RegisterEventRecorder registers pod & node event recorder to a tracer

func (*Tracer) RegisterResourceMapping

func (t *Tracer) RegisterResourceMapping(mapping ResMapping)

RegisterResourceMapping registers handler to the tracer

func (*Tracer) Unregister

func (t *Tracer) Unregister(typ, resourceName string)

Unregister remove TraceHandler from tracer. do nothing if not found

Jump to

Keyboard shortcuts

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