Skip to content

Commit 9d30ab8

Browse files
authored
pkg/*: eliminate use of .Append() (#3862)
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
1 parent a1c3cdc commit 9d30ab8

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

pkg/batchperresourceattr/batchperresourceattr.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ func (bt *batchTraces) ConsumeTraces(ctx context.Context, td pdata.Traces) error
6262
}
6363

6464
// Append ResourceSpan to pdata.Traces for this attribute value.
65-
tracesForAttr.ResourceSpans().Append(rs)
65+
tgt := tracesForAttr.ResourceSpans().AppendEmpty()
66+
rs.CopyTo(tgt)
6667
}
6768

6869
var errs []error
@@ -114,7 +115,8 @@ func (bt *batchMetrics) ConsumeMetrics(ctx context.Context, td pdata.Metrics) er
114115
}
115116

116117
// Append ResourceSpan to pdata.Metrics for this attribute value.
117-
metricsForAttr.ResourceMetrics().Append(rm)
118+
tgt := metricsForAttr.ResourceMetrics().AppendEmpty()
119+
rm.CopyTo(tgt)
118120
}
119121

120122
var errs []error
@@ -166,7 +168,8 @@ func (bt *batchLogs) ConsumeLogs(ctx context.Context, td pdata.Logs) error {
166168
}
167169

168170
// Append ResourceSpan to pdata.Logs for this attribute value.
169-
logsForAttr.ResourceLogs().Append(rl)
171+
tgt := logsForAttr.ResourceLogs().AppendEmpty()
172+
rl.CopyTo(tgt)
170173
}
171174

172175
var errs []error

pkg/batchpersignal/batchpersignal.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ func SplitTraces(batch pdata.Traces) []pdata.Traces {
5353
}
5454

5555
// there is only one instrumentation library per batch
56-
batches[key].InstrumentationLibrarySpans().At(0).Spans().Append(span)
56+
tgt := batches[key].InstrumentationLibrarySpans().At(0).Spans().AppendEmpty()
57+
span.CopyTo(tgt)
5758
}
5859
}
5960
}
@@ -98,7 +99,8 @@ func SplitLogs(batch pdata.Logs) []pdata.Logs {
9899
}
99100

100101
// there is only one instrumentation library per batch
101-
batches[key].InstrumentationLibraryLogs().At(0).Logs().Append(log)
102+
tgt := batches[key].InstrumentationLibraryLogs().At(0).Logs().AppendEmpty()
103+
log.CopyTo(tgt)
102104
}
103105
}
104106
}

0 commit comments

Comments
 (0)