Skip to content

Commit

Permalink
feat: scheduler metrics add default value of biz tag (#1151)
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi authored Mar 10, 2022
1 parent 435e539 commit 843b800
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scheduler/resource/cdn.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ import (
"d7y.io/dragonfly/v2/scheduler/config"
)

const (
// Default value of biz tag for cdn peer
cdnBizTag = "d7y/cdn"
)

type CDN interface {
// TriggerTask start to trigger cdn task
TriggerTask(context.Context, *Task) (*Peer, *rpcscheduler.PeerResult, error)
Expand Down Expand Up @@ -146,7 +151,7 @@ func (c *cdn) initPeer(task *Task, ps *cdnsystem.PieceSeed) (*Peer, error) {
}

// New cdn peer
peer = NewPeer(ps.PeerId, task, host)
peer = NewPeer(ps.PeerId, task, host, WithBizTag(cdnBizTag))
peer.Log.Info("new cdn peer successfully")

// Store cdn peer
Expand Down
4 changes: 4 additions & 0 deletions scheduler/resource/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ import (
const (
// Download tiny file timeout
downloadTinyFileContextTimeout = 2 * time.Minute

// Default value of biz tag
defaultBizTag = "unknow"
)

const (
Expand Down Expand Up @@ -156,6 +159,7 @@ type Peer struct {
func NewPeer(id string, task *Task, host *Host, options ...PeerOption) *Peer {
p := &Peer{
ID: id,
BizTag: defaultBizTag,
Pieces: &bitset.BitSet{},
pieceCosts: []int64{},
Stream: &atomic.Value{},
Expand Down

0 comments on commit 843b800

Please sign in to comment.