| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package refconsumer // import "go.opentelemetry.io/collector/service/internal/refconsumer" |
| 5 |
|
| 6 |
import ( |
| 7 |
"context" |
| 8 |
|
| 9 |
"go.opentelemetry.io/collector/consumer" |
| 10 |
"go.opentelemetry.io/collector/pdata/plog" |
| 11 |
"go.opentelemetry.io/collector/pdata/xpdata/pref" |
| 12 |
) |
| 13 |
|
| 14 |
func NewLogs(cons consumer.Logs) consumer.Logs { |
| 15 |
return refLogs{ |
| 16 |
consumer: cons, |
| 17 |
} |
| 18 |
} |
| 19 |
|
| 20 |
type refLogs struct { |
| 21 |
consumer consumer.Logs |
| 22 |
} |
| 23 |
|
| 24 |
// ConsumeLogs measures telemetry before calling ConsumeLogs because the data may be mutated downstream |
| 25 |
func (c refLogs) ConsumeLogs(ctx context.Context, ld plog.Logs) error { |
| 26 |
if pref.MarkPipelineOwnedLogs(ld) { |
| 27 |
defer pref.UnrefLogs(ld) |
| 28 |
} |
| 29 |
return c.consumer.ConsumeLogs(ctx, ld) |
| 30 |
} |
| 31 |
|
| 32 |
func (c refLogs) Capabilities() consumer.Capabilities { |
| 33 |
return c.consumer.Capabilities() |
| 34 |
} |