Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
Add a core attribute to tracing span (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
willscott authored Sep 13, 2023
1 parent 078dddd commit abbbb06
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@ func (p *pool) fetchResource(ctx context.Context, from string, resource string,
fetchRequestContextErrorTotalMetric.WithLabelValues(resourceType, fmt.Sprintf("%t", errors.Is(ce, context.Canceled)), "fetchResource-init").Add(1)
return rm, ce
}
p.lk.RLock()
isCore := p.th.IsCore(from)
p.lk.RUnlock()

ctx, span := spanTrace(ctx, "Pool.FetchResource", trace.WithAttributes(attribute.String("from", from), attribute.String("of", resource), attribute.String("mime", mime)))
ctx, span := spanTrace(ctx, "Pool.FetchResource", trace.WithAttributes(attribute.String("from", from), attribute.String("of", resource), attribute.String("mime", mime), attribute.Bool("core", isCore)))
defer span.End()

requestId := uuid.NewString()
Expand Down
9 changes: 9 additions & 0 deletions tieredhashing/tiered_hashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type NodeInfo struct {
Distance float32 `json:"distance"`
Weight int `json:"weight"`
ComplianceCid string `json:"complianceCid"`
Core bool `json:"core"`
}

type NodePerf struct {
Expand Down Expand Up @@ -530,3 +531,11 @@ func (t *TieredHashing) recordCorrectness(perf *NodePerf, success bool) {
t.LastAverageCalcAt = time.Now()
}
}

func (t *TieredHashing) IsCore(n string) bool {
nd, ok := t.nodes[n]
if !ok {
return false
}
return nd.Core
}

0 comments on commit abbbb06

Please sign in to comment.