mirror of
https://github.com/hanzoai/telemetry.git
synced 2026-10-30 20:01:49 +00:00
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.
20 lines
564 B
Go
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
|
|
}
|