Debian Codegraph @

pdata/xpdata/pref/profiles.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package pref // import "go.opentelemetry.io/collector/pdata/xpdata/pref"
5
6 import (
7 "reflect"
8
9 "go.opentelemetry.io/collector/pdata/internal"
10 "go.opentelemetry.io/collector/pdata/pprofile"
11 )
12
13 // MarkPipelineOwnedProfiles marks the pprofile.Profiles data as owned by the pipeline, returns true if the data were
14 // previously not owned by the pipeline, otherwise false.
15 func MarkPipelineOwnedProfiles(pd pprofile.Profiles) bool {
16 return internal.GetProfilesState(internal.ProfilesWrapper(pd)).MarkPipelineOwned()
17 }
18
19 func RefProfiles(pd pprofile.Profiles) {
20 if EnableRefCounting.IsEnabled() {
21 internal.GetProfilesState(internal.ProfilesWrapper(pd)).Ref()
22 }
23 }
24
25 func UnrefProfiles(pd pprofile.Profiles) {
26 if EnableRefCounting.IsEnabled() {
27 if !internal.GetProfilesState(internal.ProfilesWrapper(pd)).Unref() {
28 return
29 }
30 // Don't call DeleteExportLogsServiceRequest without the gate because we reset the data and that may still cause issues.
31 if internal.UseProtoPooling.IsEnabled() {
32 internal.DeleteExportProfilesServiceRequest(internal.GetProfilesOrig(internal.ProfilesWrapper(pd)), true)
33 }
34 }
35 }
36
37 // TODO: Generate this in pdata.
38
39 func EqualProfiles(pd1, pd2 pprofile.Profiles) bool {
40 return reflect.DeepEqual(internal.GetProfilesOrig(internal.ProfilesWrapper(pd1)), internal.GetProfilesOrig(internal.ProfilesWrapper(pd2)))
41 }