mirror of
https://github.com/hanzoai/traces.git
synced 2026-11-03 04:05:45 +00:00
* Update Prometheus to v0.307.2 * Update otel collector * Update OTel collector
35 lines
883 B
Go
35 lines
883 B
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package refconsumer // import "go.opentelemetry.io/collector/service/internal/refconsumer"
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go.opentelemetry.io/collector/consumer"
|
|
"go.opentelemetry.io/collector/pdata/ptrace"
|
|
"go.opentelemetry.io/collector/pdata/xpdata/pref"
|
|
)
|
|
|
|
func NewTraces(cons consumer.Traces) consumer.Traces {
|
|
return refTraces{
|
|
consumer: cons,
|
|
}
|
|
}
|
|
|
|
type refTraces struct {
|
|
consumer consumer.Traces
|
|
}
|
|
|
|
// ConsumeTraces measures telemetry before calling ConsumeTraces because the data may be mutated downstream
|
|
func (c refTraces) ConsumeTraces(ctx context.Context, ld ptrace.Traces) error {
|
|
if pref.MarkPipelineOwnedTraces(ld) {
|
|
defer pref.UnrefTraces(ld)
|
|
}
|
|
return c.consumer.ConsumeTraces(ctx, ld)
|
|
}
|
|
|
|
func (c refTraces) Capabilities() consumer.Capabilities {
|
|
return c.consumer.Capabilities()
|
|
}
|