@sentry/opentelemetry 8.11.0 → 8.12.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
@@ -1471,14 +1471,16 @@ function inferStatusFromAttributes(attributes) {
1471
1471
  function _optionalChain$2(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1472
1472
 
1473
1473
  const MAX_SPAN_COUNT = 1000;
1474
+ const DEFAULT_TIMEOUT = 300; // 5 min
1474
1475
 
1475
1476
  /**
1476
1477
  * A Sentry-specific exporter that converts OpenTelemetry Spans to Sentry Spans & Transactions.
1477
1478
  */
1478
1479
  class SentrySpanExporter {
1479
1480
 
1480
- constructor() {
1481
+ constructor(options) {
1481
1482
  this._finishedSpans = [];
1483
+ this._timeout = _optionalChain$2([options, 'optionalAccess', _ => _.timeout]) || DEFAULT_TIMEOUT;
1482
1484
  }
1483
1485
 
1484
1486
  /** Export a single span. */
@@ -1539,7 +1541,7 @@ class SentrySpanExporter {
1539
1541
  */
1540
1542
  _cleanupOldSpans(spans = this._finishedSpans) {
1541
1543
  this._finishedSpans = spans.filter(span => {
1542
- const shouldDrop = shouldCleanupSpan(span, 5 * 60);
1544
+ const shouldDrop = shouldCleanupSpan(span, this._timeout);
1543
1545
  DEBUG_BUILD &&
1544
1546
  shouldDrop &&
1545
1547
  utils.logger.log(
@@ -1639,7 +1641,7 @@ function createTransactionForOtelSpan(span) {
1639
1641
 
1640
1642
  const { traceId: trace_id, spanId: span_id } = span.spanContext();
1641
1643
 
1642
- const parentSpanIdFromTraceState = _optionalChain$2([span, 'access', _ => _.spanContext, 'call', _2 => _2(), 'access', _3 => _3.traceState, 'optionalAccess', _4 => _4.get, 'call', _5 => _5(SENTRY_TRACE_STATE_PARENT_SPAN_ID)]);
1644
+ const parentSpanIdFromTraceState = _optionalChain$2([span, 'access', _2 => _2.spanContext, 'call', _3 => _3(), 'access', _4 => _4.traceState, 'optionalAccess', _5 => _5.get, 'call', _6 => _6(SENTRY_TRACE_STATE_PARENT_SPAN_ID)]);
1643
1645
 
1644
1646
  // If parentSpanIdFromTraceState is defined at all, we want it to take presedence
1645
1647
  // In that case, an empty string should be interpreted as "no parent span id",
@@ -1857,9 +1859,9 @@ function onSpanEnd(span) {
1857
1859
  */
1858
1860
  class SentrySpanProcessor {
1859
1861
 
1860
- constructor() {
1862
+ constructor(options) {
1861
1863
  setIsSetup('SentrySpanProcessor');
1862
- this._exporter = new SentrySpanExporter();
1864
+ this._exporter = new SentrySpanExporter(options);
1863
1865
  }
1864
1866
 
1865
1867
  /**