| 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/plog" |
| 11 |
) |
| 12 |
|
| 13 |
// MarkPipelineOwnedLogs marks the plog.Logs data as owned by the pipeline, returns true if the data were |
| 14 |
// previously not owned by the pipeline, otherwise false. |
| 15 |
func MarkPipelineOwnedLogs(ld plog.Logs) bool { |
| 16 |
return internal.GetLogsState(internal.LogsWrapper(ld)).MarkPipelineOwned() |
| 17 |
} |
| 18 |
|
| 19 |
func RefLogs(ld plog.Logs) { |
| 20 |
if EnableRefCounting.IsEnabled() { |
| 21 |
internal.GetLogsState(internal.LogsWrapper(ld)).Ref() |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
func UnrefLogs(ld plog.Logs) { |
| 26 |
if EnableRefCounting.IsEnabled() { |
| 27 |
if !internal.GetLogsState(internal.LogsWrapper(ld)).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.DeleteExportLogsServiceRequest(internal.GetLogsOrig(internal.LogsWrapper(ld)), true) |
| 33 |
} |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
// TODO: Generate this in pdata. |
| 38 |
|
| 39 |
func EqualLogs(ld1, ld2 plog.Logs) bool { |
| 40 |
return reflect.DeepEqual(internal.GetLogsOrig(internal.LogsWrapper(ld1)), internal.GetLogsOrig(internal.LogsWrapper(ld2))) |
| 41 |
} |