Files
Damien MathieuandGitHub 6883920b73 Introduce switchDictionary methods for profiles (#14075)
This is the next step towards
https://github.com/open-telemetry/opentelemetry-collector/issues/13106

It introduces private `switchDictionary` methods for all profile
structs, so their base dictionary can be switched, which is a
requirement (and maybe the biggest bit) of merging profiles.

Right now, the private method isn't called yet, because this PR is
already very big, and I believe introducing `MergeTo` should be in
another PR.
But the gist is that to merge profiles together, we need to change the
base dictionary for the profiles that are being moved before we can
merge the two slices of resource profiles into one.
2025-11-19 10:58:00 +00:00

20 lines
564 B
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package pprofile // import "go.opentelemetry.io/collector/pdata/pprofile"
import "fmt"
// switchDictionary updates the ResourceProfiles, switching its indices from one
// dictionary to another.
func (ms ResourceProfiles) switchDictionary(src, dst ProfilesDictionary) error {
for i, v := range ms.ScopeProfiles().All() {
err := v.switchDictionary(src, dst)
if err != nil {
return fmt.Errorf("error switching dictionary for scope profile %d: %w", i, err)
}
}
return nil
}