Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: qtree ZapiPerf duplicate instance key #3369

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions cmd/collectors/zapiperf/zapiperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,6 @@ func parseHistogramLabels(elem *node.Node) ([]string, string) {

// PollInstance updates instance cache
func (z *ZapiPerf) PollInstance() (map[string]*matrix.Matrix, error) {

var (
err error
request, results *node.Node
Expand Down Expand Up @@ -1669,7 +1668,6 @@ func (z *ZapiPerf) PollInstance() (map[string]*matrix.Matrix, error) {
}

responseData, err := z.Client.InvokeBatchRequest(request, batchTag, z.testFilePath, headers)

if err != nil {
if errors.Is(err, errs.ErrAPIRequestRejected) {
z.Logger.Info(
Expand Down Expand Up @@ -1705,9 +1703,9 @@ func (z *ZapiPerf) PollInstance() (map[string]*matrix.Matrix, error) {
}

for _, i := range instances.GetChildren() {

key := z.buildKeyValue(i, keyAttrs)
if key == "" {
switch {
case key == "":
// instance key missing
name := i.GetChildContentS(nameAttr)
uuid := i.GetChildContentS(uuidAttr)
Expand All @@ -1719,16 +1717,22 @@ func (z *ZapiPerf) PollInstance() (map[string]*matrix.Matrix, error) {
slog.String("uuid", uuid),
)
}
} else if oldInstances.Has(key) {
case oldInstances.Has(key):
// instance already in cache
oldInstances.Remove(key)
instance := mat.GetInstance(key)
z.updateQosLabels(i, instance, key)
continue
} else if instance, err := mat.NewInstance(key); err != nil {
z.Logger.Error("add instance", slogx.Err(err))
} else {
z.updateQosLabels(i, instance, key)
default:
instance := mat.GetInstance(key)
if instance == nil {
instance, err = mat.NewInstance(key)
if err != nil {
z.Logger.Error("add instance", slogx.Err(err))
}
}
if instance != nil {
z.updateQosLabels(i, instance, key)
}
}
}
parseD += time.Since(parseT)
Expand Down
Loading