diff --git a/pkg/trace/agent/agent.go b/pkg/trace/agent/agent.go index ff2307a3aeb49..2eb5aa861edb0 100644 --- a/pkg/trace/agent/agent.go +++ b/pkg/trace/agent/agent.go @@ -535,7 +535,8 @@ func (a *Agent) processStats(in *pb.ClientStatsPayload, lang, tracerVersion, con if !a.Blacklister.AllowsStat(b) { continue } - a.obfuscateStatsGroup(b) + obfuscator := a.lazyInitObfuscator() + obfuscateStatsGroup(obfuscator, b) a.Replacer.ReplaceStatsGroup(b) group.Stats[n] = b n++ diff --git a/pkg/trace/agent/obfuscate.go b/pkg/trace/agent/obfuscate.go index 25042e3fd6edc..b7d4bf2f2d7e7 100644 --- a/pkg/trace/agent/obfuscate.go +++ b/pkg/trace/agent/obfuscate.go @@ -110,9 +110,7 @@ func (a *Agent) obfuscateSpan(span *pb.Span) { } } -func (a *Agent) obfuscateStatsGroup(b *pb.ClientGroupedStats) { - o := a.lazyInitObfuscator() - +func obfuscateStatsGroup(o *obfuscate.Obfuscator, b *pb.ClientGroupedStats) { switch b.Type { case "sql", "cassandra": oq, err := o.ObfuscateSQLString(b.Resource) diff --git a/pkg/trace/agent/obfuscate_test.go b/pkg/trace/agent/obfuscate_test.go index 268f55630f4d9..6add9410583fc 100644 --- a/pkg/trace/agent/obfuscate_test.go +++ b/pkg/trace/agent/obfuscate_test.go @@ -48,7 +48,8 @@ func TestObfuscateStatsGroup(t *testing.T) { } { agnt, stop := agentWithDefaults() defer stop() - agnt.obfuscateStatsGroup(tt.in) + obfuscator := agnt.lazyInitObfuscator() + obfuscateStatsGroup(obfuscator, tt.in) assert.Equal(t, tt.in.Resource, tt.out) } }