Skip to content

Commit

Permalink
[processor/batch] Removed casts to Sizer interface in batch processor (
Browse files Browse the repository at this point in the history
…#5937)

* Removed casts to Sizer interface in batch processor

Signed-off-by: Corbin Phelps <[email protected]>

* Added changelog entry

Signed-off-by: Corbin Phelps <[email protected]>

* removed changelog

Signed-off-by: Corbin Phelps <[email protected]>

Signed-off-by: Corbin Phelps <[email protected]>
  • Loading branch information
Corbin Phelps authored Aug 19, 2022
1 parent ec04503 commit f0d69d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions processor/batchprocessor/batch_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ type batchTraces struct {
}

func newBatchTraces(nextConsumer consumer.Traces) *batchTraces {
return &batchTraces{nextConsumer: nextConsumer, traceData: ptrace.NewTraces(), sizer: ptrace.NewProtoMarshaler().(ptrace.Sizer)}
return &batchTraces{nextConsumer: nextConsumer, traceData: ptrace.NewTraces(), sizer: ptrace.NewProtoMarshaler()}
}

// add updates current batchTraces by adding new TraceData object
Expand Down Expand Up @@ -274,7 +274,7 @@ type batchMetrics struct {
}

func newBatchMetrics(nextConsumer consumer.Metrics) *batchMetrics {
return &batchMetrics{nextConsumer: nextConsumer, metricData: pmetric.NewMetrics(), sizer: pmetric.NewProtoMarshaler().(pmetric.Sizer)}
return &batchMetrics{nextConsumer: nextConsumer, metricData: pmetric.NewMetrics(), sizer: pmetric.NewProtoMarshaler()}
}

func (bm *batchMetrics) export(ctx context.Context, sendBatchMaxSize int, returnBytes bool) (int, int, error) {
Expand Down Expand Up @@ -320,7 +320,7 @@ type batchLogs struct {
}

func newBatchLogs(nextConsumer consumer.Logs) *batchLogs {
return &batchLogs{nextConsumer: nextConsumer, logData: plog.NewLogs(), sizer: plog.NewProtoMarshaler().(plog.Sizer)}
return &batchLogs{nextConsumer: nextConsumer, logData: plog.NewLogs(), sizer: plog.NewProtoMarshaler()}
}

func (bl *batchLogs) export(ctx context.Context, sendBatchMaxSize int, returnBytes bool) (int, int, error) {
Expand Down
8 changes: 4 additions & 4 deletions processor/batchprocessor/batch_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func TestBatchProcessorSpansDeliveredEnforceBatchSize(t *testing.T) {
}

func TestBatchProcessorSentBySize(t *testing.T) {
sizer := ptrace.NewProtoMarshaler().(ptrace.Sizer)
sizer := ptrace.NewProtoMarshaler()
views := MetricViews()
require.NoError(t, view.Register(views...))
defer view.Unregister(views...)
Expand Down Expand Up @@ -359,7 +359,7 @@ func TestBatchMetricProcessor_ReceivingData(t *testing.T) {
}

func TestBatchMetricProcessor_BatchSize(t *testing.T) {
sizer := pmetric.NewProtoMarshaler().(pmetric.Sizer)
sizer := pmetric.NewProtoMarshaler()
views := MetricViews()
require.NoError(t, view.Register(views...))
defer view.Unregister(views...)
Expand Down Expand Up @@ -564,7 +564,7 @@ func getTestMetricName(requestNum, index int) string {
}

func BenchmarkTraceSizeBytes(b *testing.B) {
sizer := ptrace.NewProtoMarshaler().(ptrace.Sizer)
sizer := ptrace.NewProtoMarshaler()
td := testdata.GenerateTraces(8192)
for n := 0; n < b.N; n++ {
fmt.Println(sizer.TracesSize(td))
Expand Down Expand Up @@ -677,7 +677,7 @@ func TestBatchLogProcessor_ReceivingData(t *testing.T) {
}

func TestBatchLogProcessor_BatchSize(t *testing.T) {
sizer := plog.NewProtoMarshaler().(plog.Sizer)
sizer := plog.NewProtoMarshaler()
views := MetricViews()
require.NoError(t, view.Register(views...))
defer view.Unregister(views...)
Expand Down

0 comments on commit f0d69d6

Please sign in to comment.