func (t *Tracer) RegisterResourceMapping(mapping ResMapping) {
	t.resourceMapping = mapping
}
RegisterResourceMapping registers handler to the tracer
package tracing
import (
	"errors"
	"fmt"
	"sync"
	"github.com/AliyunContainerService/terway/types"
)
const (
	ResourceTypeNetworkService = "network_service"
	ResourceTypeResourcePool = "resource_pool"
	ResourceTypeFactory = "factory"
	DisposeResourceFailed = "DisposeResourceFailed"
	AllocResourceFailed = "AllocResourceFailed"
)
type PodMapping struct {
	Name      string
	Namespace string
	Valid     bool
	PodBindResID string
	LocalResID   string
	RemoteResID  string
}
var (
	defaultTracer Tracer
)
type MapKeyValueEntry struct {
	Key   string
	Value string
}
type TraceHandler interface {
	Config() []MapKeyValueEntry
	Trace() []MapKeyValueEntry
	Execute(cmd string, args []string, message chan<- string)
}
type ResourcePoolStats interface {
	GetLocal() map[string]types.Res
	GetRemote() map[string]types.Res
}
type FakeResourcePoolStats struct {
	Local  map[string]types.Res
	Remote map[string]types.Res
}
func (f *FakeResourcePoolStats) GetLocal() map[string]types.Res {
	return f.Local
}
func (f *FakeResourcePoolStats) GetRemote() map[string]types.Res {
	return f.Remote
}
type ResourceMappingHandler interface {
	GetResourceMapping() (ResourcePoolStats, error)
}
type ResMapping interface {
	GetResourceMapping() ([]*PodMapping, error)
}
type PodEventRecorder func(podName, podNamespace, eventType, reason, message string) error
type NodeEventRecorder func(eventType, reason, message string)
type resourceMap map[string]TraceHandler
type Tracer struct {
	mtx sync.Mutex
	traceMap        map[string]resourceMap
	resourceMapping ResMapping
	podEvent        PodEventRecorder
	nodeEvent       NodeEventRecorder
}
func init() {
	defaultTracer.traceMap = make(map[string]resourceMap)
}
func (t *Tracer) Register(typ, resourceName string, handler TraceHandler) error {
	t.mtx.Lock()
	defer t.mtx.Unlock()
	_, ok := t.traceMap[typ]
	if !ok {  
		t.traceMap[typ] = make(resourceMap)
	}
	_, ok = t.traceMap[typ][resourceName]
	if ok {
		return fmt.Errorf("resource name %s with type %s has been registered", resourceName, typ)
	}
	t.traceMap[typ][resourceName] = handler
	return nil
}
func (t *Tracer) Unregister(typ, resourceName string) {
	t.mtx.Lock()
	defer t.mtx.Unlock()
	resourceMap, ok := t.traceMap[typ]
	if !ok {
		return
	}
	delete(resourceMap, resourceName)
}