Skip to content

Commit

Permalink
[receiver/signalfx] Replace usages of Insert to Upsert on empty maps (#…
Browse files Browse the repository at this point in the history
…13918)

signalfx receiver doesn't create resource attributes from sfx datapoint or event conversion. So it's save to use Map.Upsert instead of Map.Insert
  • Loading branch information
dmitryax authored Sep 7, 2022
1 parent 10a525b commit 2db61c0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions receiver/signalfxreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (r *sfxReceiver) handleDatapointReq(resp http.ResponseWriter, req *http.Req
for i := 0; i < md.ResourceMetrics().Len(); i++ {
rm := md.ResourceMetrics().At(i)
res := rm.Resource()
res.Attributes().InsertString(splunk.SFxAccessTokenLabel, accessToken)
res.Attributes().UpsertString(splunk.SFxAccessTokenLabel, accessToken)
}
}
}
Expand Down Expand Up @@ -297,7 +297,7 @@ func (r *sfxReceiver) handleEventReq(resp http.ResponseWriter, req *http.Request

if r.config.AccessTokenPassthrough {
if accessToken := req.Header.Get(splunk.SFxAccessTokenHeader); accessToken != "" {
rl.Resource().Attributes().InsertString(splunk.SFxAccessTokenLabel, accessToken)
rl.Resource().Attributes().UpsertString(splunk.SFxAccessTokenLabel, accessToken)
}
}

Expand Down

0 comments on commit 2db61c0

Please sign in to comment.