Skip to content

Commit

Permalink
[ENG-2342] refactor census
Browse files Browse the repository at this point in the history
  • Loading branch information
pwilczynskiclearcode committed Jan 8, 2025
1 parent 48540cf commit eeaf6f8
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions monitor/census.go
Original file line number Diff line number Diff line change
Expand Up @@ -1043,20 +1043,21 @@ func manifestIDTag(ctx context.Context, others ...tag.Mutator) []tag.Mutator {
return others
}

func manifestIDTagAndOrchInfo(orchInfo *lpnet.OrchestratorInfo, ctx context.Context, others ...tag.Mutator) []tag.Mutator {
others = manifestIDTag(ctx, others...)

others = append(
others,
tag.Insert(census.kOrchestratorURI, orchInfo.GetTranscoder()),
tag.Insert(census.kOrchestratorAddress, common.BytesToAddress(orchInfo.GetAddress()).String()),
)
func orchInfoTags(orchInfo *lpnet.OrchestratorInfo) []tag.Mutator {
orchAddr := ""
if addr := orchInfo.GetAddress(); addr != nil {
orchAddr = common.BytesToAddress(addr).String()
}
tags := []tag.Mutator{tag.Insert(census.kOrchestratorURI, orchInfo.GetTranscoder()), tag.Insert(census.kOrchestratorAddress, orchAddr)}
capabilities := orchInfo.GetCapabilities()
if capabilities != nil {
others = append(others, tag.Insert(census.kOrchestratorVersion, capabilities.Version))
tags = append(tags, tag.Insert(census.kOrchestratorVersion, orchInfo.GetCapabilities().GetVersion()))
}
return tags
}

return others
func manifestIDTagAndOrchInfo(orchInfo *lpnet.OrchestratorInfo, ctx context.Context, others ...tag.Mutator) []tag.Mutator {
return append(manifestIDTag(ctx, others...), orchInfoTags(orchInfo)...)
}

func manifestIDTagStr(manifestID string, others ...tag.Mutator) []tag.Mutator {
Expand Down Expand Up @@ -1997,16 +1998,7 @@ func AIResultDownloaded(ctx context.Context, pipeline string, model string, down
}

func AIFirstSegmentDelay(delay int64, orchInfo *lpnet.OrchestratorInfo) {
orchAddr := ""
if addr := orchInfo.GetAddress(); addr != nil {
orchAddr = common.BytesToAddress(addr).String()
}
tags := []tag.Mutator{tag.Insert(census.kOrchestratorURI, orchInfo.GetTranscoder()), tag.Insert(census.kOrchestratorAddress, orchAddr)}
capabilities := orchInfo.GetCapabilities()
if capabilities != nil {
tags = append(tags, tag.Insert(census.kOrchestratorVersion, orchInfo.GetCapabilities().GetVersion()))
}
if err := stats.RecordWithTags(census.ctx, tags, census.mAIFirstSegmentDelay.M(delay)); err != nil {
if err := stats.RecordWithTags(census.ctx, orchInfoTags(orchInfo), census.mAIFirstSegmentDelay.M(delay)); err != nil {
glog.Errorf("Error recording metrics err=%q", err)
}
}
Expand Down

0 comments on commit eeaf6f8

Please sign in to comment.