-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
traces.go
43 lines (35 loc) · 1.23 KB
/
traces.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package consumer // import "go.opentelemetry.io/collector/consumer"
import (
"context"
"go.opentelemetry.io/collector/consumer/internal"
"go.opentelemetry.io/collector/pdata/ptrace"
)
// Traces is an interface that receives ptrace.Traces, processes it
// as needed, and sends it to the next processing node if any or to the destination.
type Traces interface {
internal.BaseConsumer
// ConsumeTraces receives ptrace.Traces for consumption.
ConsumeTraces(ctx context.Context, td ptrace.Traces) error
}
// ConsumeTracesFunc is a helper function that is similar to ConsumeTraces.
type ConsumeTracesFunc func(ctx context.Context, td ptrace.Traces) error
// ConsumeTraces calls f(ctx, td).
func (f ConsumeTracesFunc) ConsumeTraces(ctx context.Context, td ptrace.Traces) error {
return f(ctx, td)
}
type baseTraces struct {
*internal.BaseImpl
ConsumeTracesFunc
}
// NewTraces returns a Traces configured with the provided options.
func NewTraces(consume ConsumeTracesFunc, options ...Option) (Traces, error) {
if consume == nil {
return nil, errNilFunc
}
return &baseTraces{
BaseImpl: internal.NewBaseImpl(options...),
ConsumeTracesFunc: consume,
}, nil
}