Repository: dragonflyoss/Dragonfly2
Pull request #1462 (2022-07-14 03:12:11)

feat: proxy add defaultTag field
Signed-off-by: Gaius <gaius.qi@gmail.com>

<!--- Provide a general summary of your changes in the Title above -->

## Description
- Proxy add defaultTag field.
<!--- Describe your changes in detail -->

## Related Issue

<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
<!--- Please link to the issue here: -->

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->

## Screenshots (if appropriate)

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Documentation Update (if none of the other choices apply)

## Checklist

<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [x] I have read the **CONTRIBUTING** document.
- [ ] I have added tests to cover my changes.



Patch:
diff --git a/client/config/headers.go b/client/config/headers.go
index f76c35dc..6b8ace04 100644
--- a/client/config/headers.go
+++ b/client/config/headers.go
@@ -21,7 +21,7 @@ const (
 	HeaderDragonflyPeer   = "X-Dragonfly-Peer"
 	HeaderDragonflyTask   = "X-Dragonfly-Task"
 	HeaderDragonflyRange  = "X-Dragonfly-Range"
-	HeaderDragonflyBiz    = "X-Dragonfly-Biz"
+	HeaderDragonflyTag    = "X-Dragonfly-Tag"
 	// HeaderDragonflyRegistry is used for dynamic registry mirrors.
 	HeaderDragonflyRegistry = "X-Dragonfly-Registry"
 	// HeaderDragonflyObjectMetaDigest is used for digest of object storage.
diff --git a/client/config/peerhost.go b/client/config/peerhost.go
index 32f58d81..760b0c5e 100644
--- a/client/config/peerhost.go
+++ b/client/config/peerhost.go
@@ -269,6 +269,7 @@ type ProxyOption struct {
 	ListenOption    `mapstructure:",squash" yaml:",inline"`
 	BasicAuth       *BasicAuth      `mapstructure:"basicAuth" yaml:"basicAuth"`
 	DefaultFilter   string          `mapstructure:"defaultFilter" yaml:"defaultFilter"`
+	DefaultTag      string          `mapstructure:"defaultTag" yaml:"defaultTag"`
 	MaxConcurrency  int64           `mapstructure:"maxConcurrency" yaml:"maxConcurrency"`
 	RegistryMirror  *RegistryMirror `mapstructure:"registryMirror" yaml:"registryMirror"`
 	WhiteList       []*WhiteList    `mapstructure:"whiteList" yaml:"whiteList"`
@@ -356,6 +357,7 @@ func (p *ProxyOption) unmarshal(unmarshal func(in []byte, out any) (err error),
 		ListenOption         `mapstructure:",squash" yaml:",inline"`
 		BasicAuth            *BasicAuth        `mapstructure:"basicAuth" yaml:"basicAuth"`
 		DefaultFilter        string            `mapstructure:"defaultFilter" yaml:"defaultFilter"`
+		DefaultTag           string            `mapstructure:"defaultTag" yaml:"defaultTag"`
 		MaxConcurrency       int64             `mapstructure:"maxConcurrency" yaml:"maxConcurrency"`
 		RegistryMirror       *RegistryMirror   `mapstructure:"registryMirror" yaml:"registryMirror"`
 		WhiteList            []*WhiteList      `mapstructure:"whiteList" yaml:"whiteList"`
@@ -376,6 +378,7 @@ func (p *ProxyOption) unmarshal(unmarshal func(in []byte, out any) (err error),
 	p.WhiteList = pt.WhiteList
 	p.MaxConcurrency = pt.MaxConcurrency
 	p.DefaultFilter = pt.DefaultFilter
+	p.DefaultTag = pt.DefaultTag
 	p.BasicAuth = pt.BasicAuth
 	p.DumpHTTPContent = pt.DumpHTTPContent
 
diff --git a/client/daemon/proxy/proxy.go b/client/daemon/proxy/proxy.go
index 3ee88cad..d008faae 100644
--- a/client/daemon/proxy/proxy.go
+++ b/client/daemon/proxy/proxy.go
@@ -52,9 +52,6 @@ import (
 var (
 	okHeader = []byte("HTTP/1.1 200 OK\r\n\r\n")
 
-	// Default biz value is empty.
-	bizTag = ""
-
 	schemaHTTPS = "https"
 
 	portHTTPS = 443
@@ -99,6 +96,9 @@ type Proxy struct {
 	// defaultFilter is used when http request without X-Dragonfly-Filter Header
 	defaultFilter string
 
+	// defaultTag is used when http request without X-Dragonfly-Tag Header
+	defaultTag string
+
 	// defaultFilter is used for registering steam task
 	defaultPattern base.Pattern
 
@@ -217,6 +217,14 @@ func WithDefaultFilter(f string) Option {
 	}
 }
 
+// WithDefaultTag sets default tag for http requests without X-Dragonfly-Tag Header
+func WithDefaultTag(t string) Option {
+	return func(p *Proxy) *Proxy {
+		p.defaultTag = t
+		return p
+	}
+}
+
 // WithDefaultPattern sets default pattern for downloading
 func WithDefaultPattern(pattern base.Pattern) Option {
 	return func(p *Proxy) *Proxy {
@@ -494,7 +502,7 @@ func (proxy *Proxy) newTransport(tlsConfig *tls.Config) http.RoundTripper {
 		transport.WithCondition(proxy.shouldUseDragonfly),
 		transport.WithDefaultFilter(proxy.defaultFilter),
 		transport.WithDefaultPattern(proxy.defaultPattern),
-		transport.WithDefaultBiz(bizTag),
+		transport.WithDefaultTag(proxy.defaultTag),
 		transport.WithDumpHTTPContent(proxy.dumpHTTPContent),
 	)
 	return rt
@@ -508,7 +516,7 @@ func (proxy *Proxy) mirrorRegistry(w http.ResponseWriter, r *http.Request) {
 		transport.WithTLS(proxy.registry.TLSConfig()),
 		transport.WithCondition(proxy.shouldUseDragonflyForMirror),
 		transport.WithDefaultFilter(proxy.defaultFilter),
-		transport.WithDefaultBiz(bizTag),
+		transport.WithDefaultTag(proxy.defaultTag),
 		transport.WithDumpHTTPContent(proxy.dumpHTTPContent),
 	)
 	if err != nil {
diff --git a/client/daemon/proxy/proxy_manager.go b/client/daemon/proxy/proxy_manager.go
index c21235bc..ea4f030f 100644
--- a/client/daemon/proxy/proxy_manager.go
+++ b/client/daemon/proxy/proxy_manager.go
@@ -78,6 +78,7 @@ func NewProxyManager(peerHost *scheduler.PeerHost, peerTaskManager peer.TaskMana
 		WithWhiteList(whiteList),
 		WithMaxConcurrency(proxyOption.MaxConcurrency),
 		WithDefaultFilter(proxyOption.DefaultFilter),
+		WithDefaultTag(proxyOption.DefaultTag),
 		WithDefaultPattern(defaultPattern),
 		WithBasicAuth(proxyOption.BasicAuth),
 		WithDumpHTTPContent(proxyOption.DumpHTTPContent),
diff --git a/client/daemon/transport/transport.go b/client/daemon/transport/transport.go
index a08e7940..5288a82d 100644
--- a/client/daemon/transport/transport.go
+++ b/client/daemon/transport/transport.go
@@ -72,8 +72,8 @@ type transport struct {
 	// defaultFilter is used for registering steam task
 	defaultPattern base.Pattern
 
-	// defaultBiz is used when http request without X-Dragonfly-Biz Header
-	defaultBiz string
+	// defaultTag is used when http request without X-Dragonfly-Tag Header
+	defaultTag string
 
 	// dumpHTTPContent indicates to dump http request header and response header
 	dumpHTTPContent bool
@@ -132,10 +132,10 @@ func WithDefaultPattern(pattern base.Pattern) Option {
 	}
 }
 
-// WithDefaultBiz sets default biz for http requests with X-Dragonfly-Biz Header
-func WithDefaultBiz(b string) Option {
+// WithDefaultTag sets default tag for http requests with X-Dragonfly-Tag Header
+func WithDefaultTag(b string) Option {
 	return func(rt *transport) *transport {
-		rt.defaultBiz = b
+		rt.defaultTag = b
 		return rt
 	}
 }
@@ -237,7 +237,7 @@ func (rt *transport) download(ctx context.Context, req *http.Request) (*http.Res
 
 	// Pick header's parameters
 	filter := nethttp.PickHeader(req.Header, config.HeaderDragonflyFilter, rt.defaultFilter)
-	tag := nethttp.PickHeader(req.Header, config.HeaderDragonflyBiz, rt.defaultBiz)
+	tag := nethttp.PickHeader(req.Header, config.HeaderDragonflyTag, rt.defaultTag)
 
 	// Delete hop-by-hop headers
 	delHopHeaders(req.Header)
diff --git a/scheduler/metrics/metrics.go b/scheduler/metrics/metrics.go
index 972815e8..ba372252 100644
--- a/scheduler/metrics/metrics.go
+++ b/scheduler/metrics/metrics.go
@@ -56,28 +56,28 @@ var (
 		Subsystem: constants.SchedulerMetricsName,
 		Name:      "register_peer_task_total",
 		Help:      "Counter of the number of the register peer task.",
-	}, []string{"biz_tag"})
+	}, []string{"tag"})
 
 	RegisterPeerTaskFailureCount = promauto.NewCounterVec(prometheus.CounterOpts{
 		Namespace: constants.MetricsNamespace,
 		Subsystem: constants.SchedulerMetricsName,
 		Name:      "register_peer_task_failure_total",
 		Help:      "Counter of the number of failed of the register peer task.",
-	}, []string{"biz_tag"})
+	}, []string{"tag"})
 
 	DownloadCount = promauto.NewCounterVec(prometheus.CounterOpts{
 		Namespace: constants.MetricsNamespace,
 		Subsystem: constants.SchedulerMetricsName,
 		Name:      "download_total",
 		Help:      "Counter of the number of the downloading.",
-	}, []string{"biz_tag"})
+	}, []string{"tag"})
 
 	DownloadFailureCount = promauto.NewCounterVec(prometheus.CounterOpts{
 		Namespace: constants.MetricsNamespace,
 		Subsystem: constants.SchedulerMetricsName,
 		Name:      "download_failure_total",
 		Help:      "Counter of the number of failed of the downloading.",
-	}, []string{"biz_tag", "type"})
+	}, []string{"tag", "type"})
 
 	StatTaskCount = promauto.NewCounter(prometheus.CounterOpts{
 		Namespace: constants.MetricsNamespace,
@@ -112,35 +112,35 @@ var (
 		Subsystem: constants.SchedulerMetricsName,
 		Name:      "leave_task_total",
 		Help:      "Counter of the number of the leaving task.",
-	}, []string{"biz_tag"})
+	}, []string{"tag"})
 
 	LeaveTaskFailureCount = promauto.NewCounterVec(prometheus.CounterOpts{
 		Namespace: constants.MetricsNamespace,
 		Subsystem: constants.SchedulerMetricsName,
 		Name:      "leave_task_failure_total",
 		Help:      "Counter of the number of failed of the leaving task.",
-	}, []string{"biz_tag"})
+	}, []string{"tag"})
 
 	Traffic = promauto.NewCounterVec(prometheus.CounterOpts{
 		Namespace: constants.MetricsNamespace,
 		Subsystem: constants.SchedulerMetricsName,
 		Name:      "traffic",
 		Help:      "Counter of the number of traffic.",
-	}, []string{"biz_tag", "type"})
+	}, []string{"tag", "type"})
 
 	PeerHostTraffic = promauto.NewCounterVec(prometheus.CounterOpts{
 		Namespace: constants.MetricsNamespace,
 		Subsystem: constants.SchedulerMetricsName,
 		Name:      "peer_host_traffic",
 		Help:      "Counter of the number of per peer host traffic.",
-	}, []string{"biz_tag", "traffic_type", "peer_host_id", "peer_host_ip"})
+	}, []string{"tag", "traffic_type", "peer_host_id", "peer_host_ip"})
 
 	PeerTaskCounter = promauto.NewCounterVec(prometheus.CounterOpts{
 		Namespace: constants.MetricsNamespace,
 		Subsystem: constants.SchedulerMetricsName,
 		Name:      "peer_task_total",
 		Help:      "Counter of the number of peer task.",
-	}, []string{"biz_tag", "type"})
+	}, []string{"tag", "type"})
 
 	PeerTaskDownloadDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{
 		Namespace: constants.MetricsNamespace,
@@ -148,7 +148,7 @@ var (
 		Name:      "peer_task_download_duration_milliseconds",
 		Help:      "Histogram of the time each peer task downloading.",
 		Buckets:   []float64{100, 200, 500, 1000, 1500, 2 * 1000, 3 * 1000, 5 * 1000, 10 * 1000, 20 * 1000, 60 * 1000, 120 * 1000, 300 * 1000},
-	}, []string{"biz_tag"})
+	}, []string{"tag"})
 
 	ConcurrentScheduleGauge = promauto.NewGauge(prometheus.GaugeOpts{
 		Namespace: constants.MetricsNamespace,
diff --git a/scheduler/resource/peer.go b/scheduler/resource/peer.go
index a845cf58..dfa04716 100644
--- a/scheduler/resource/peer.go
+++ b/scheduler/resource/peer.go
@@ -36,8 +36,8 @@ import (
 )
 
 const (
-	// Default value of biz tag.
-	DefaultBizTag = "unknow"
+	// Default value of tag.
+	DefaultTag = "unknow"
 
 	// Download tiny file timeout.
 	downloadTinyFileContextTimeout = 30 * time.Second
@@ -101,10 +101,10 @@ const (
 // PeerOption is a functional option for configuring the peer.
 type PeerOption func(p *Peer) *Peer
 
-// WithBizTag sets peer's BizTag.
-func WithBizTag(bizTag string) PeerOption {
+// WithTag sets peer's Tag.
+func WithTag(tag string) PeerOption {
 	return func(p *Peer) *Peer {
-		p.BizTag = bizTag
+		p.Tag = tag
 		return p
 	}
 }
@@ -113,8 +113,8 @@ type Peer struct {
 	// ID is peer id.
 	ID string
 
-	// BizTag is peer biz tag.
-	BizTag string
+	// Tag is peer tag.
+	Tag string
 
 	// Pieces is piece bitset.
 	Pieces *bitset.BitSet
@@ -180,7 +180,7 @@ type Peer struct {
 func NewPeer(id string, task *Task, host *Host, options ...PeerOption) *Peer {
 	p := &Peer{
 		ID:               id,
-		BizTag:           DefaultBizTag,
+		Tag:              DefaultTag,
 		Pieces:           &bitset.BitSet{},
 		pieceCosts:       []int64{},
 		Stream:           &atomic.Value{},
diff --git a/scheduler/resource/seed_peer.go b/scheduler/resource/seed_peer.go
index bbaedcdc..5809c56e 100644
--- a/scheduler/resource/seed_peer.go
+++ b/scheduler/resource/seed_peer.go
@@ -31,7 +31,7 @@ import (
 
 const (
 	// Default value of biz tag for seed peer.
-	SeedBizTag = "d7y/seed"
+	SeedTag = "d7y/seed"
 )
 
 const (
@@ -152,7 +152,7 @@ func (s *seedPeer) initSeedPeer(task *Task, ps *cdnsystem.PieceSeed) (*Peer, err
 	}
 
 	// New seed peer.
-	peer = NewPeer(ps.PeerId, task, host, WithBizTag(SeedBizTag))
+	peer = NewPeer(ps.PeerId, task, host, WithTag(SeedTag))
 	peer.Log.Info("new seed peer successfully")
 
 	// Store seed peer.
diff --git a/scheduler/rpcserver/rpcserver.go b/scheduler/rpcserver/rpcserver.go
index 8a870f3a..7b756ba7 100644
--- a/scheduler/rpcserver/rpcserver.go
+++ b/scheduler/rpcserver/rpcserver.go
@@ -59,17 +59,17 @@ func (s *Server) RegisterPeerTask(ctx context.Context, req *scheduler.PeerTaskRe
 		req.TaskId = idgen.TaskID(req.Url, req.UrlMeta)
 	}
 
-	bizTag := resource.DefaultBizTag
+	tag := resource.DefaultTag
 	if req.UrlMeta.Tag != "" {
-		bizTag = req.UrlMeta.Tag
+		tag = req.UrlMeta.Tag
 	}
-	metrics.RegisterPeerTaskCount.WithLabelValues(bizTag).Inc()
+	metrics.RegisterPeerTaskCount.WithLabelValues(tag).Inc()
 
 	resp, err := s.service.RegisterPeerTask(ctx, req)
 	if err != nil {
-		metrics.RegisterPeerTaskFailureCount.WithLabelValues(bizTag).Inc()
+		metrics.RegisterPeerTaskFailureCount.WithLabelValues(tag).Inc()
 	} else {
-		metrics.PeerTaskCounter.WithLabelValues(bizTag, resp.SizeScope.String()).Inc()
+		metrics.PeerTaskCounter.WithLabelValues(tag, resp.SizeScope.String()).Inc()
 	}
 
 	return resp, err
diff --git a/scheduler/service/service.go b/scheduler/service/service.go
index 6c039f5c..1e4deb32 100644
--- a/scheduler/service/service.go
+++ b/scheduler/service/service.go
@@ -300,9 +300,9 @@ func (s *Service) ReportPieceResult(stream rpcscheduler.Scheduler_ReportPieceRes
 
 			// Collect peer host traffic metrics.
 			if s.config.Metrics != nil && s.config.Metrics.EnablePeerHost {
-				metrics.PeerHostTraffic.WithLabelValues(peer.BizTag, metrics.PeerHostTrafficDownloadType, peer.Host.ID, peer.Host.IP).Add(float64(piece.PieceInfo.RangeSize))
+				metrics.PeerHostTraffic.WithLabelValues(peer.Tag, metrics.PeerHostTrafficDownloadType, peer.Host.ID, peer.Host.IP).Add(float64(piece.PieceInfo.RangeSize))
 				if parent, ok := s.resource.PeerManager().Load(piece.DstPid); ok {
-					metrics.PeerHostTraffic.WithLabelValues(peer.BizTag, metrics.PeerHostTrafficUploadType, parent.Host.ID, parent.Host.IP).Add(float64(piece.PieceInfo.RangeSize))
+					metrics.PeerHostTraffic.WithLabelValues(peer.Tag, metrics.PeerHostTrafficUploadType, parent.Host.ID, parent.Host.IP).Add(float64(piece.PieceInfo.RangeSize))
 				} else {
 					peer.Log.Warnf("dst peer %s not found for piece %#v %#v", piece.DstPid, piece, piece.PieceInfo)
 				}
@@ -310,9 +310,9 @@ func (s *Service) ReportPieceResult(stream rpcscheduler.Scheduler_ReportPieceRes
 
 			// Collect traffic metrics.
 			if piece.DstPid != "" {
-				metrics.Traffic.WithLabelValues(peer.BizTag, metrics.TrafficP2PType).Add(float64(piece.PieceInfo.RangeSize))
+				metrics.Traffic.WithLabelValues(peer.Tag, metrics.TrafficP2PType).Add(float64(piece.PieceInfo.RangeSize))
 			} else {
-				metrics.Traffic.WithLabelValues(peer.BizTag, metrics.TrafficBackToSourceType).Add(float64(piece.PieceInfo.RangeSize))
+				metrics.Traffic.WithLabelValues(peer.Tag, metrics.TrafficBackToSourceType).Add(float64(piece.PieceInfo.RangeSize))
 			}
 			continue
 		}
@@ -342,13 +342,13 @@ func (s *Service) ReportPeerResult(ctx context.Context, req *rpcscheduler.PeerRe
 		logger.Error(msg)
 		return dferrors.New(base.Code_SchedPeerNotFound, msg)
 	}
-	metrics.DownloadCount.WithLabelValues(peer.BizTag).Inc()
+	metrics.DownloadCount.WithLabelValues(peer.Tag).Inc()
 
 	if !req.Success {
 		peer.Log.Errorf("report peer failed result: %s %#v", req.Code, req)
 		if peer.FSM.Is(resource.PeerStateBackToSource) {
 			s.createRecord(peer, storage.PeerStateBackToSourceFailed, req)
-			metrics.DownloadFailureCount.WithLabelValues(peer.BizTag, metrics.DownloadFailureBackToSourceType).Inc()
+			metrics.DownloadFailureCount.WithLabelValues(peer.Tag, metrics.DownloadFailureBackToSourceType).Inc()
 
 			s.handleTaskFail(ctx, peer.Task, req.GetSourceError(), nil)
 			s.handlePeerFail(ctx, peer)
@@ -356,12 +356,12 @@ func (s *Service) ReportPeerResult(ctx context.Context, req *rpcscheduler.PeerRe
 		}
 
 		s.createRecord(peer, storage.PeerStateFailed, req)
-		metrics.DownloadFailureCount.WithLabelValues(peer.BizTag, metrics.DownloadFailureP2PType).Inc()
+		metrics.DownloadFailureCount.WithLabelValues(peer.Tag, metrics.DownloadFailureP2PType).Inc()
 
 		s.handlePeerFail(ctx, peer)
 		return nil
 	}
-	metrics.PeerTaskDownloadDuration.WithLabelValues(peer.BizTag).Observe(float64(req.Cost))
+	metrics.PeerTaskDownloadDuration.WithLabelValues(peer.Tag).Observe(float64(req.Cost))
 
 	peer.Log.Infof("report peer result: %#v", req)
 	if peer.FSM.Is(resource.PeerStateBackToSource) {
@@ -467,11 +467,11 @@ func (s *Service) LeaveTask(ctx context.Context, req *rpcscheduler.PeerTarget) e
 		logger.Error(msg)
 		return dferrors.New(base.Code_SchedPeerNotFound, msg)
 	}
-	metrics.LeaveTaskCount.WithLabelValues(peer.BizTag).Inc()
+	metrics.LeaveTaskCount.WithLabelValues(peer.Tag).Inc()
 
 	peer.Log.Infof("leave task: %#v", req)
 	if err := peer.FSM.Event(resource.PeerEventLeave); err != nil {
-		metrics.LeaveTaskFailureCount.WithLabelValues(peer.BizTag).Inc()
+		metrics.LeaveTaskFailureCount.WithLabelValues(peer.Tag).Inc()
 
 		msg := fmt.Sprintf("peer fsm event failed: %s", err.Error())
 		peer.Log.Error(msg)
@@ -552,7 +552,7 @@ func (s *Service) registerHost(ctx context.Context, rawHost *rpcscheduler.PeerHo
 func (s *Service) registerPeer(ctx context.Context, peerID string, task *resource.Task, host *resource.Host, tag string) *resource.Peer {
 	var options []resource.PeerOption
 	if tag != "" {
-		options = append(options, resource.WithBizTag(tag))
+		options = append(options, resource.WithTag(tag))
 	}
 
 	peer, loaded := s.resource.PeerManager().LoadOrStore(resource.NewPeer(peerID, task, host, options...))
@@ -847,7 +847,7 @@ func (s *Service) createRecord(peer *resource.Peer, peerState int, req *rpcsched
 		ID:              peer.ID,
 		IP:              peer.Host.IP,
 		Hostname:        peer.Host.Hostname,
-		BizTag:          peer.BizTag,
+		Tag:             peer.Tag,
 		Cost:            req.Cost,
 		PieceCount:      int32(peer.Pieces.Count()),
 		TotalPieceCount: peer.Task.TotalPieceCount.Load(),
@@ -867,7 +867,7 @@ func (s *Service) createRecord(peer *resource.Peer, peerState int, req *rpcsched
 		record.ParentID = parent.ID
 		record.ParentIP = parent.Host.IP
 		record.ParentHostname = parent.Host.Hostname
-		record.ParentBizTag = parent.BizTag
+		record.ParentTag = parent.Tag
 		record.ParentPieceCount = int32(parent.Pieces.Count())
 		record.ParentSecurityDomain = parent.Host.SecurityDomain
 		record.ParentIDC = parent.Host.IDC
diff --git a/scheduler/storage/storage.go b/scheduler/storage/storage.go
index 29928210..21162b75 100644
--- a/scheduler/storage/storage.go
+++ b/scheduler/storage/storage.go
@@ -88,8 +88,8 @@ type Record struct {
 	// Hostname is host name.
 	Hostname string `csv:"hostname"`
 
-	// BizTag is peer biz tag.
-	BizTag string `csv:"bizTag"`
+	// Tag is peer tag.
+	Tag string `csv:"tag"`
 
 	// Cost is the task download time(millisecond).
 	Cost uint32 `csv:"cost"`
@@ -141,8 +141,8 @@ type Record struct {
 	// ParentHostname is parent hostname.
 	ParentHostname string `csv:"parentHostname"`
 
-	// ParentBizTag is parent peer biz tag.
-	ParentBizTag string `csv:"parentBizTag"`
+	// ParentTag is parent peer tag.
+	ParentTag string `csv:"parentTag"`
 
 	// ParentPieceCount is parent total piece count.
 	ParentPieceCount int32 `csv:"parentPieceCount"`


Test patch:
diff --git a/client/config/peerhost_test.go b/client/config/peerhost_test.go
index d6a0b2f5..ef5774f4 100644
--- a/client/config/peerhost_test.go
+++ b/client/config/peerhost_test.go
@@ -420,6 +420,7 @@ func TestPeerHostOption_Load(t *testing.T) {
 				Password: "bar",
 			},
 			DefaultFilter:  "baz",
+			DefaultTag:     "tag",
 			MaxConcurrency: 1,
 			RegistryMirror: &RegistryMirror{
 				Remote: &URL{
diff --git a/client/config/testdata/config/daemon.yaml b/client/config/testdata/config/daemon.yaml
index 00dc7f12..4066af53 100644
--- a/client/config/testdata/config/daemon.yaml
+++ b/client/config/testdata/config/daemon.yaml
@@ -124,6 +124,7 @@ proxy:
     username: "foo"
     password: "bar"
   defaultFilter: "baz"
+  defaultTag: "tag"
   maxConcurrency: 1
   security:
     insecure: true
diff --git a/scheduler/resource/peer_test.go b/scheduler/resource/peer_test.go
index 801cc390..964eb145 100644
--- a/scheduler/resource/peer_test.go
+++ b/scheduler/resource/peer_test.go
@@ -68,13 +68,13 @@ func TestPeer_NewPeer(t *testing.T) {
 			},
 		},
 		{
-			name:    "new peer with bizTag",
+			name:    "new peer with tag",
 			id:      mockPeerID,
-			options: []PeerOption{WithBizTag("foo")},
+			options: []PeerOption{WithTag("foo")},
 			expect: func(t *testing.T, peer *Peer, mockTask *Task, mockHost *Host) {
 				assert := assert.New(t)
 				assert.Equal(peer.ID, mockPeerID)
-				assert.Equal(peer.BizTag, "foo")
+				assert.Equal(peer.Tag, "foo")
 				assert.Empty(peer.Pieces)
 				assert.Equal(len(peer.PieceCosts()), 0)
 				assert.Empty(peer.Stream)
diff --git a/scheduler/service/service_test.go b/scheduler/service/service_test.go
index 425bf736..8a6e635d 100644
--- a/scheduler/service/service_test.go
+++ b/scheduler/service/service_test.go
@@ -2297,7 +2297,7 @@ func TestService_registerPeer(t *testing.T) {
 			expect: func(t *testing.T, peer *resource.Peer) {
 				assert := assert.New(t)
 				assert.Equal(peer.ID, mockPeerID)
-				assert.Equal(peer.BizTag, resource.DefaultBizTag)
+				assert.Equal(peer.Tag, resource.DefaultTag)
 			},
 		},
 		{
@@ -2315,7 +2315,7 @@ func TestService_registerPeer(t *testing.T) {
 			expect: func(t *testing.T, peer *resource.Peer) {
 				assert := assert.New(t)
 				assert.Equal(peer.ID, mockPeerID)
-				assert.Equal(peer.BizTag, resource.DefaultBizTag)
+				assert.Equal(peer.Tag, resource.DefaultTag)
 			},
 		},
 	}
diff --git a/scheduler/storage/storage_test.go b/scheduler/storage/storage_test.go
index 6e2c1ba0..b9aeb96a 100644
--- a/scheduler/storage/storage_test.go
+++ b/scheduler/storage/storage_test.go
@@ -243,7 +243,7 @@ func TestStorage_List(t *testing.T) {
 				ID:                   "1",
 				IP:                   "127.0.0.1",
 				Hostname:             "hostname",
-				BizTag:               "biz_tag",
+				Tag:                  "tag",
 				Cost:                 1,
 				PieceCount:           1,
 				TotalPieceCount:      1,
@@ -259,7 +259,7 @@ func TestStorage_List(t *testing.T) {
 				ParentID:             "2",
 				ParentIP:             "127.0.0.1",
 				ParentHostname:       "parent_hostname",
-				ParentBizTag:         "parent_biz_tag",
+				ParentTag:            "parent_tag",
 				ParentPieceCount:     1,
 				ParentSecurityDomain: "parent_security_domain",
 				ParentIDC:            "parent_idc",