@sentry/opentelemetry 8.5.0 → 8.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/index.js CHANGED
@@ -1437,6 +1437,8 @@ function mapStatus(span) {
1437
1437
  }
1438
1438
  }
1439
1439
 
1440
+ const MAX_SPAN_COUNT = 1000;
1441
+
1440
1442
  /**
1441
1443
  * A Sentry-specific exporter that converts OpenTelemetry Spans to Sentry Spans & Transactions.
1442
1444
  */
@@ -1544,7 +1546,12 @@ function maybeSend(spans) {
1544
1546
  createAndFinishSpanForOtelSpan(child, spans, remaining);
1545
1547
  });
1546
1548
 
1547
- transactionEvent.spans = spans;
1549
+ // spans.sort() mutates the array, but we do not use this anymore after this point
1550
+ // so we can safely mutate it here
1551
+ transactionEvent.spans =
1552
+ spans.length > MAX_SPAN_COUNT
1553
+ ? spans.sort((a, b) => a.start_timestamp - b.start_timestamp).slice(0, MAX_SPAN_COUNT)
1554
+ : spans;
1548
1555
 
1549
1556
  const measurements = timedEventsToMeasurements(span.events);
1550
1557
  if (measurements) {