Skip to content

Commit 9383e82

Browse files
Update docs and code comments to not refer to old consumerdata (#2511)
* Update docs and code comments to not refer to old consumerdata Updates #2482 Signed-off-by: Bogdan Drutu <[email protected]> * Update processor/README.md Co-authored-by: Tigran Najaryan <[email protected]> Co-authored-by: Tigran Najaryan <[email protected]>
1 parent 92f1cac commit 9383e82

File tree

11 files changed

+28
-39
lines changed

11 files changed

+28
-39
lines changed

component/componenttest/example_factories.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ func (f *ExampleExporterFactory) CustomUnmarshaler() component.CustomUnmarshaler
287287
}
288288
}
289289

290-
// CreateTraceExporter creates a trace exporter based on this config.
290+
// CreateTracesExporter creates a trace exporter based on this config.
291291
func (f *ExampleExporterFactory) CreateTracesExporter(
292292
_ context.Context,
293293
_ component.ExporterCreateParams,
@@ -330,13 +330,13 @@ func (exp *ExampleExporterConsumer) Start(_ context.Context, _ component.Host) e
330330
return nil
331331
}
332332

333-
// ConsumeTraceData receives consumerdata.TraceData for processing by the TracesConsumer.
333+
// ConsumeTraces receives pdata.Traces for processing by the TracesConsumer.
334334
func (exp *ExampleExporterConsumer) ConsumeTraces(_ context.Context, td pdata.Traces) error {
335335
exp.Traces = append(exp.Traces, td)
336336
return nil
337337
}
338338

339-
// ConsumeMetricsData receives consumerdata.MetricsData for processing by the MetricsConsumer.
339+
// ConsumeMetrics receives pdata.Metrics for processing by the MetricsConsumer.
340340
func (exp *ExampleExporterConsumer) ConsumeMetrics(_ context.Context, md pdata.Metrics) error {
341341
exp.Metrics = append(exp.Metrics, md)
342342
return nil

component/receiver.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ type Receiver interface {
3232
// Its purpose is to translate data from the wild into internal trace format.
3333
// TracesReceiver feeds a consumer.TracesConsumer with data.
3434
//
35-
// For example it could be Zipkin data source which translates
36-
// Zipkin spans into consumerdata.TraceData.
35+
// For example it could be Zipkin data source which translates Zipkin spans into pdata.Traces.
3736
type TracesReceiver interface {
3837
Receiver
3938
}
@@ -42,8 +41,7 @@ type TracesReceiver interface {
4241
// Its purpose is to translate data from the wild into internal metrics format.
4342
// MetricsReceiver feeds a consumer.MetricsConsumer with data.
4443
//
45-
// For example it could be Prometheus data source which translates
46-
// Prometheus metrics into consumerdata.MetricsData.
44+
// For example it could be Prometheus data source which translates Prometheus metrics into pdata.Metrics.
4745
type MetricsReceiver interface {
4846
Receiver
4947
}

consumer/pdata/trace.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import (
2222
// This file defines in-memory data structures to represent traces (spans).
2323

2424
// Traces is the top-level struct that is propagated through the traces pipeline.
25-
// This is the newer version of consumerdata.Traces, but uses more efficient
26-
// in-memory representation.
2725
type Traces struct {
2826
orig *[]*otlptrace.ResourceSpans
2927
}

exporter/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,12 @@ service:
8787

8888
When multiple exporters are configured to send the same data (e.g. by configuring multiple
8989
exporters for the same pipeline) the exporters will have a shared access to the data.
90-
Exporters get access to this shared data when `ConsumeTraceData`/`ConsumeMetricsData`
91-
function is called. Exporters MUST NOT modify the `TraceData`/`MetricsData` argument of
90+
Exporters get access to this shared data when `ConsumeTraces`/`ConsumeMetrics`/`ConsumeLogs`
91+
function is called. Exporters MUST NOT modify the `pdata.Traces`/`pdata.Metrics`/`pdata.Logs` argument of
9292
these functions. If the exporter needs to modify the data while performing the exporting
9393
the exporter can clone the data and perform the modification on the clone or use a
94-
copy-on-write approach for individual sub-parts of `TraceData`/`MetricsData` argument.
95-
Any approach that does not mutate the original `TraceData`/`MetricsData` argument
96-
(including referenced data, such as `Node`, `Resource`, `Spans`, etc) is allowed.
94+
copy-on-write approach for individual sub-parts of `pdata.Traces`/`pdata.Metrics`/`pdata.Logs`.
95+
Any approach that does not mutate the original `pdata.Traces`/`pdata.Metrics`/`pdata.Logs` is allowed.
9796

9897
## Proxy Support
9998

exporter/exporterhelper/tracehelper_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func TestTraceExporter_Default_ReturnError(t *testing.T) {
101101
require.NotNil(t, te)
102102

103103
err = te.ConsumeTraces(context.Background(), td)
104-
require.Equalf(t, want, err, "ConsumeTraceData returns: Want %v Got %v", want, err)
104+
require.Equal(t, want, err)
105105
}
106106

107107
func TestTraceExporter_WithRecordMetrics(t *testing.T) {

obsreport/obsreport_receiver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ type StartReceiveOption func(*StartReceiveOptions)
110110
//
111111
// Example:
112112
//
113-
// func (r *receiver) ClientConnect(ctx context.Context, rcvChan <-chan consumerdata.TraceData) {
113+
// func (r *receiver) ClientConnect(ctx context.Context, rcvChan <-chan pdata.Traces) {
114114
// longLivedCtx := obsreport.ReceiverContext(ctx, r.config.Name(), r.transport, "")
115115
// for {
116116
// // Since the context outlives the individual receive operations call obsreport using
@@ -124,7 +124,7 @@ type StartReceiveOption func(*StartReceiveOptions)
124124
// td, ok := <-rcvChan
125125
// var err error
126126
// if ok {
127-
// err = r.nextConsumer.ConsumeTraceData(ctx, td)
127+
// err = r.nextConsumer.ConsumeTraces(ctx, td)
128128
// }
129129
// obsreport.EndTraceDataReceiveOp(
130130
// ctx,

processor/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ processor documentation for more information.
4747

4848
## <a name="data-ownership"></a>Data Ownership
4949

50-
The ownership of the `TraceData` and `MetricsData` in a pipeline is passed as the data travels
51-
through the pipeline. The data is created by the receiver and then the ownership is passed
52-
to the first processor when `ConsumeTraceData`/`ConsumeMetricsData` function is called.
50+
The ownership of the `pdata.Traces`, `pdata.Metrics` and `pdata.Logs` data in a pipeline
51+
is passed as the data travels through the pipeline. The data is created by the receiver
52+
and then the ownership is passed to the first processor when `ConsumeTraces`/`ConsumeMetrics`/`ConsumeLogs`
53+
function is called.
5354

5455
Note: the receiver may be attached to multiple pipelines, in which case the same data
5556
will be passed to all attached pipelines via a data fan-out connector.
@@ -79,8 +80,8 @@ data and the data can be safely modified in the pipeline.
7980

8081
The exclusive ownership of data allows processors to freely modify the data while
8182
they own it (e.g. see `attributesprocessor`). The duration of ownership of the data
82-
by processor is from the beginning of `ConsumeTraceData`/`ConsumeMetricsData` call
83-
until the processor calls the next processor's `ConsumeTraceData`/`ConsumeMetricsData`
83+
by processor is from the beginning of `ConsumeTraces`/`ConsumeMetrics`/`ConsumeLogs`
84+
call until the processor calls the next processor's `ConsumeTraces`/`ConsumeMetrics`/`ConsumeLogs`
8485
function, which passes the ownership to the next processor. After that the processor
8586
must no longer read or write the data since it may be concurrently modified by the
8687
new owner.
@@ -97,17 +98,16 @@ In this mode no cloning is performed at the fan-out connector of receivers that
9798
are attached to multiple pipelines. In this case all such pipelines will see
9899
the same single shared copy of the data. Processors in pipelines operating in shared
99100
ownership mode are prohibited from modifying the original data that they receive
100-
via `ConsumeTraceData`/`ConsumeMetricsData` call. Processors may only read the data but
101-
must not modify the data.
101+
via `ConsumeTraces`/`ConsumeMetrics`/`ConsumeLogs` call. Processors may only read
102+
the data but must not modify the data.
102103

103104
If the processor needs to modify the data while performing the processing but
104105
does not want to incur the cost of data cloning that Exclusive mode brings then
105106
the processor can declare that it does not modify the data and use any
106107
different technique that ensures original data is not modified. For example,
107108
the processor can implement copy-on-write approach for individual sub-parts of
108-
`TraceData`/`MetricsData` argument. Any approach that does not mutate the
109-
original `TraceData`/`MetricsData` argument (including referenced data, such as
110-
`Node`, `Resource`, `Spans`, etc) is allowed.
109+
`pdata.Traces`/`pdata.Metrics`/`pdata.Logs` argument. Any approach that does not
110+
mutate the original `pdata.Traces`/`pdata.Metrics`/`pdata.Logs` is allowed.
111111

112112
If the processor uses such technique it should declare that it does not intend
113113
to modify the original data by setting `MutatesConsumedData=false` in its capabilities

processor/cloningfanoutconnector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ type tracesCloningFanOutConnector []consumer.TracesConsumer
7878

7979
var _ consumer.TracesConsumer = (*tracesCloningFanOutConnector)(nil)
8080

81-
// ConsumeTraceData exports the span data to all trace consumers wrapped by the current one.
81+
// ConsumeTraces exports the span data to all trace consumers wrapped by the current one.
8282
func (tfc tracesCloningFanOutConnector) ConsumeTraces(ctx context.Context, td pdata.Traces) error {
8383
var errs []error
8484

processor/fanoutconnector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type metricsFanOutConnector []consumer.MetricsConsumer
3838

3939
var _ consumer.MetricsConsumer = (*metricsFanOutConnector)(nil)
4040

41-
// ConsumeMetricsData exports the MetricsData to all consumers wrapped by the current one.
41+
// ConsumeMetrics exports the pdata.Metrics to all consumers wrapped by the current one.
4242
func (mfc metricsFanOutConnector) ConsumeMetrics(ctx context.Context, md pdata.Metrics) error {
4343
var errs []error
4444
for _, mc := range mfc {

processor/probabilisticsamplerprocessor/probabilisticsampler_test.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,7 @@ func Test_tracesamplerprocessor_SamplingPercentageRange(t *testing.T) {
150150
return
151151
}
152152
for _, td := range genRandomTestData(tt.numBatches, tt.numTracesPerBatch, testSvcName, 1) {
153-
if err := tsp.ConsumeTraces(context.Background(), td); err != nil {
154-
t.Errorf("tracesamplerprocessor.ConsumeTraceData() error = %v", err)
155-
return
156-
}
153+
assert.NoError(t, tsp.ConsumeTraces(context.Background(), td))
157154
}
158155
_, sampled := assertSampledData(t, sink.AllTraces(), testSvcName)
159156
actualPercentageSamplingPercentage := float32(sampled) / float32(tt.numBatches*tt.numTracesPerBatch) * 100.0
@@ -213,10 +210,7 @@ func Test_tracesamplerprocessor_SamplingPercentageRange_MultipleResourceSpans(t
213210
}
214211

215212
for _, td := range genRandomTestData(tt.numBatches, tt.numTracesPerBatch, testSvcName, tt.resourceSpanPerTrace) {
216-
if err := tsp.ConsumeTraces(context.Background(), td); err != nil {
217-
t.Errorf("tracesamplerprocessor.ConsumeTraceData() error = %v", err)
218-
return
219-
}
213+
assert.NoError(t, tsp.ConsumeTraces(context.Background(), td))
220214
assert.Equal(t, tt.resourceSpanPerTrace*tt.numTracesPerBatch, sink.SpansCount())
221215
sink.Reset()
222216
}
@@ -440,7 +434,7 @@ func Test_hash(t *testing.T) {
440434
}
441435
}
442436

443-
// genRandomTestData generates a slice of consumerdata.TraceData with the numBatches elements which one with
437+
// genRandomTestData generates a slice of pdata.Traces with the numBatches elements which one with
444438
// numTracesPerBatch spans (ie.: each span has a different trace ID). All spans belong to the specified
445439
// serviceName.
446440
func genRandomTestData(numBatches, numTracesPerBatch int, serviceName string, resourceSpanCount int) (tdd []pdata.Traces) {

0 commit comments

Comments
 (0)