Skip to content

Commit

Permalink
use slice for NPM connection tags (#28112)
Browse files Browse the repository at this point in the history
  • Loading branch information
brycekahle authored Aug 1, 2024
1 parent 8efec6f commit 946ce87
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/network/encoding/marshal/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func formatTags(c network.ConnectionStats, tagsSet *network.TagsSet, connDynamic
}

// other tags, e.g., from process env vars like DD_ENV, etc.
for tag := range c.Tags {
for _, tag := range c.Tags {
t := tag.Get().(string)
checksum ^= murmur3.StringSum32(t)
tagsIdx = append(tagsIdx, tagsSet.Add(t))
Expand Down
8 changes: 4 additions & 4 deletions pkg/network/encoding/marshal/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ func BenchmarkConnectionReset(b *testing.B) {
func BenchmarkFormatTags(b *testing.B) {
tagSet := network.NewTagsSet()
var c network.ConnectionStats
c.Tags = map[*intern.Value]struct{}{
intern.GetByString("env:env"): {},
intern.GetByString("version:version"): {},
intern.GetByString("service:service"): {},
c.Tags = []*intern.Value{
intern.GetByString("env:env"),
intern.GetByString("version:version"),
intern.GetByString("service:service"),
}
b.ReportAllocs()
b.ResetTimer()
Expand Down
2 changes: 1 addition & 1 deletion pkg/network/event_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ type ConnectionStats struct {
Direction ConnectionDirection
SPortIsEphemeral EphemeralPortType
StaticTags uint64
Tags map[*intern.Value]struct{}
Tags []*intern.Value

IntraHost bool
IsAssured bool
Expand Down
6 changes: 2 additions & 4 deletions pkg/network/tracer/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,8 @@ func (t *Tracer) addProcessInfo(c *network.ConnectionStats) {
}

if len(p.Tags) > 0 {
c.Tags = make(map[*intern.Value]struct{}, len(p.Tags))
for _, t := range p.Tags {
c.Tags[t] = struct{}{}
}
c.Tags = make([]*intern.Value, len(p.Tags))
copy(c.Tags, p.Tags)
}

if p.ContainerID != nil {
Expand Down

0 comments on commit 946ce87

Please sign in to comment.