github-vet / github-vet/rangeloop-pointer-findings
DataDog/datadog-agent: pkg/trace/agent/agent.go; 62 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [DataDog/datadog-agent](https://www.github.com/DataDog/datadog-agent) at [pkg/trace/agent/agent.go](https://github.com/DataDog/datadog-agent/blob/48c550dd038a656bc97b7ad893cc55172830cb1b/pkg/trace/agent/agent.go#L281-L342)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first
issue it finds, so please do not limit your consideration to the contents of the below message.
> function call which takes a reference to b at line 282 may start a goroutine
[Click here to see the code in its original context.](https://github.com/DataDog/datadog-agent/blob/48c550dd038a656bc97b7ad893cc55172830cb1b/pkg/trace/agent/agent.go#L281-L342)
Click here to show the 62 line(s) of Go which triggered the analyzer.
```go
for _, b := range group.Stats {
normalizeStatsGroup(&b, lang)
a.obfuscator.ObfuscateStatsGroup(&b)
a.Replacer.ReplaceStatsGroup(&b)
statusCode := ""
if b.HTTPStatusCode != 0 {
statusCode = strconv.Itoa(int(b.HTTPStatusCode))
}
newb := stats.Bucket{
Start: int64(group.Start),
Duration: int64(group.Duration),
Counts: make(map[string]stats.Count),
Distributions: make(map[string]stats.Distribution),
ErrDistributions: make(map[string]stats.Distribution),
}
aggr := stats.NewAggregation(out.Env, b.Resource, b.Service, "", statusCode, in.Version)
tagset := aggr.ToTagSet()
key := stats.GrainKey(b.Name, stats.HITS, aggr)
newb.Counts[key] = stats.Count{
Key: key,
Name: b.Name,
Measure: stats.HITS,
TagSet: tagset,
Value: float64(b.Hits),
}
key = stats.GrainKey(b.Name, stats.ERRORS, aggr)
newb.Counts[key] = stats.Count{
Key: key,
Name: b.Name,
Measure: stats.ERRORS,
TagSet: tagset,
Value: float64(b.Errors),
}
key = stats.GrainKey(b.Name, stats.DURATION, aggr)
newb.Counts[key] = stats.Count{
Key: key,
Name: b.Name,
Measure: stats.DURATION,
TagSet: tagset,
Value: float64(b.Duration),
}
if hits, errors, err := quantile.DDToGKSketches(b.OkSummary, b.ErrorSummary); err != nil {
log.Errorf("Error handling distributions: %v", err)
} else {
newb.Distributions[key] = stats.Distribution{
Key: key,
Name: b.Name,
Measure: stats.DURATION,
TagSet: tagset,
Summary: hits,
}
newb.ErrDistributions[key] = stats.Distribution{
Key: key,
Name: b.Name,
Measure: stats.DURATION,
TagSet: tagset,
Summary: errors,
}
}
out.Stats = append(out.Stats, newb)
}
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: 48c550dd038a656bc97b7ad893cc55172830cb1b
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.