| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package pprofile // import "go.opentelemetry.io/collector/pdata/pprofile" |
| 5 |
|
| 6 |
// MergeTo merges the current Profiles into dest, updating the destination |
| 7 |
// dictionary as needed and appending the resource profiles. |
| 8 |
// The source Profiles is consumed and marked read-only after this operation. |
| 9 |
func (ms Profiles) MergeTo(dest Profiles) error { |
| 10 |
ms.getState().AssertMutable() |
| 11 |
dest.getState().AssertMutable() |
| 12 |
if ms.getOrig() == dest.getOrig() { |
| 13 |
return nil |
| 14 |
} |
| 15 |
|
| 16 |
if err := ms.switchDictionary(ms.Dictionary(), dest.Dictionary()); err != nil { |
| 17 |
return err |
| 18 |
} |
| 19 |
|
| 20 |
ms.ResourceProfiles().MoveAndAppendTo(dest.ResourceProfiles()) |
| 21 |
ms.MarkReadOnly() |
| 22 |
|
| 23 |
return nil |
| 24 |
} |