@sentry/opentelemetry 8.5.0 → 8.7.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/cjs/index.js CHANGED
@@ -1440,6 +1440,8 @@ function mapStatus(span) {
1440
1440
  }
1441
1441
  }
1442
1442
 
1443
+ const MAX_SPAN_COUNT = 1000;
1444
+
1443
1445
  /**
1444
1446
  * A Sentry-specific exporter that converts OpenTelemetry Spans to Sentry Spans & Transactions.
1445
1447
  */
@@ -1547,7 +1549,12 @@ function maybeSend(spans) {
1547
1549
  createAndFinishSpanForOtelSpan(child, spans, remaining);
1548
1550
  });
1549
1551
 
1550
- transactionEvent.spans = spans;
1552
+ // spans.sort() mutates the array, but we do not use this anymore after this point
1553
+ // so we can safely mutate it here
1554
+ transactionEvent.spans =
1555
+ spans.length > MAX_SPAN_COUNT
1556
+ ? spans.sort((a, b) => a.start_timestamp - b.start_timestamp).slice(0, MAX_SPAN_COUNT)
1557
+ : spans;
1551
1558
 
1552
1559
  const measurements = core.timedEventsToMeasurements(span.events);
1553
1560
  if (measurements) {