Skip to content

Commit 4bac9ef

Browse files
committed
Resolve feedback from #637
Signed-off-by: Bogdan Drutu <[email protected]>
1 parent 8bed97a commit 4bac9ef

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

translator/metrics/otlp_to_oc.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ func ResourceMetricsToMetricsData(resourceMetrics *otlpmetrics.ResourceMetrics)
4949
Resource: resource,
5050
}
5151

52-
// TODO: Do not ignore InstrumentationLibrary properties
53-
5452
if len(resourceMetrics.InstrumentationLibraryMetrics) == 0 {
5553
return md
5654
}
5755

58-
// This is a size approximation.
56+
// Allocate slice with a capacity approximated for the case when there is only one
57+
// InstrumentationLibrary or the first InstrumentationLibrary contains most of the data.
58+
// This is a best guess only that reduced slice re-allocations.
5959
metrics := make([]*ocmetrics.Metric, 0, len(resourceMetrics.InstrumentationLibraryMetrics[0].Metrics))
6060
for _, il := range resourceMetrics.InstrumentationLibraryMetrics {
6161
for _, metric := range il.Metrics {

translator/trace/otlp_to_oc.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ func ResourceSpansToTraceData(resourceSpans *otlptrace.ResourceSpans) consumerda
5252
SourceFormat: sourceFormat,
5353
}
5454

55-
// TODO: Do not ignore InstrumentationLibrary properties
56-
5755
if len(resourceSpans.InstrumentationLibrarySpans) == 0 {
5856
return td
5957
}
6058

61-
// This is a size approximation.
59+
// Allocate slice with a capacity approximated for the case when there is only one
60+
// InstrumentationLibrary or the first InstrumentationLibrary contains most of the data.
61+
// This is a best guess only that reduced slice re-allocations.
6262
spans := make([]*octrace.Span, 0, len(resourceSpans.InstrumentationLibrarySpans[0].Spans))
6363
for _, ils := range resourceSpans.InstrumentationLibrarySpans {
6464
for _, span := range ils.Spans {

0 commit comments

Comments
 (0)