@sentry/opentelemetry 9.38.0 → 9.40.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.
@@ -689,7 +689,7 @@ class SentryPropagator extends core$1.W3CBaggagePropagator {
689
689
  */
690
690
  inject(context, carrier, setter) {
691
691
  if (core$1.isTracingSuppressed(context)) {
692
- DEBUG_BUILD && core.logger.log('[Tracing] Not injecting trace data for url because tracing is suppressed.');
692
+ DEBUG_BUILD && core.debug.log('[Tracing] Not injecting trace data for url because tracing is suppressed.');
693
693
  return;
694
694
  }
695
695
 
@@ -699,10 +699,7 @@ class SentryPropagator extends core$1.W3CBaggagePropagator {
699
699
  const tracePropagationTargets = core.getClient()?.getOptions()?.tracePropagationTargets;
700
700
  if (!shouldPropagateTraceForUrl(url, tracePropagationTargets, this._urlMatchesTargetsMap)) {
701
701
  DEBUG_BUILD &&
702
- core.logger.log(
703
- '[Tracing] Not injecting trace data for url because it does not match tracePropagationTargets:',
704
- url,
705
- );
702
+ core.debug.log('[Tracing] Not injecting trace data for url because it does not match tracePropagationTargets:', url);
706
703
  return;
707
704
  }
708
705
 
@@ -783,14 +780,14 @@ function shouldPropagateTraceForUrl(
783
780
 
784
781
  const cachedDecision = decisionMap?.get(url);
785
782
  if (cachedDecision !== undefined) {
786
- DEBUG_BUILD && !cachedDecision && core.logger.log(NOT_PROPAGATED_MESSAGE, url);
783
+ DEBUG_BUILD && !cachedDecision && core.debug.log(NOT_PROPAGATED_MESSAGE, url);
787
784
  return cachedDecision;
788
785
  }
789
786
 
790
787
  const decision = core.stringMatchesSomePattern(url, tracePropagationTargets);
791
788
  decisionMap?.set(url, decision);
792
789
 
793
- DEBUG_BUILD && !decision && core.logger.log(NOT_PROPAGATED_MESSAGE, url);
790
+ DEBUG_BUILD && !decision && core.debug.log(NOT_PROPAGATED_MESSAGE, url);
794
791
  return decision;
795
792
  }
796
793
 
@@ -1659,7 +1656,7 @@ class SentrySpanExporter {
1659
1656
  });
1660
1657
  if (droppedSpanCount > 0) {
1661
1658
  DEBUG_BUILD &&
1662
- core.logger.log(
1659
+ core.debug.log(
1663
1660
  `SpanExporter dropped ${droppedSpanCount} spans because they were pending for more than ${this._finishedSpanBucketSize} seconds.`,
1664
1661
  );
1665
1662
  }
@@ -1696,7 +1693,7 @@ class SentrySpanExporter {
1696
1693
  const sentSpanCount = sentSpans.size;
1697
1694
  const remainingOpenSpanCount = finishedSpans.length - sentSpanCount;
1698
1695
  DEBUG_BUILD &&
1699
- core.logger.log(
1696
+ core.debug.log(
1700
1697
  `SpanExporter exported ${sentSpanCount} spans, ${remainingOpenSpanCount} spans are waiting for their parent spans to finish`,
1701
1698
  );
1702
1699
 
@@ -1745,6 +1742,14 @@ class SentrySpanExporter {
1745
1742
  sentSpans.add(span);
1746
1743
  const transactionEvent = createTransactionForOtelSpan(span);
1747
1744
 
1745
+ // Add an attribute to the transaction event to indicate that this transaction is an orphaned transaction
1746
+ if (root.parentNode && this._sentSpans.has(root.parentNode.id)) {
1747
+ const traceData = transactionEvent.contexts?.trace?.data;
1748
+ if (traceData) {
1749
+ traceData['sentry.parent_span_already_sent'] = true;
1750
+ }
1751
+ }
1752
+
1748
1753
  // We'll recursively add all the child spans to this array
1749
1754
  const spans = transactionEvent.spans || [];
1750
1755
 
@@ -2183,7 +2188,7 @@ class SentrySampler {
2183
2188
 
2184
2189
  const method = `${maybeSpanHttpMethod}`.toUpperCase();
2185
2190
  if (method === 'OPTIONS' || method === 'HEAD') {
2186
- DEBUG_BUILD && core.logger.log(`[Tracing] Not sampling span because HTTP method is '${method}' for ${spanName}`);
2191
+ DEBUG_BUILD && core.debug.log(`[Tracing] Not sampling span because HTTP method is '${method}' for ${spanName}`);
2187
2192
 
2188
2193
  return wrapSamplingDecision({
2189
2194
  decision: sdkTraceBase.SamplingDecision.NOT_RECORD,
@@ -2199,7 +2204,7 @@ class SentrySampler {
2199
2204
  // We check for `parentSampled === undefined` because we only want to record client reports for spans that are trace roots (ie. when there was incoming trace)
2200
2205
  parentSampled === undefined
2201
2206
  ) {
2202
- DEBUG_BUILD && core.logger.log('[Tracing] Discarding root span because its trace was not chosen to be sampled.');
2207
+ DEBUG_BUILD && core.debug.log('[Tracing] Discarding root span because its trace was not chosen to be sampled.');
2203
2208
  this._client.recordDroppedEvent('sample_rate', 'transaction');
2204
2209
  }
2205
2210
 
@@ -2233,12 +2238,12 @@ function getParentSampled(parentSpan, traceId, spanName) {
2233
2238
  if (parentContext.isRemote) {
2234
2239
  const parentSampled = getSamplingDecision(parentSpan.spanContext());
2235
2240
  DEBUG_BUILD &&
2236
- core.logger.log(`[Tracing] Inheriting remote parent's sampled decision for ${spanName}: ${parentSampled}`);
2241
+ core.debug.log(`[Tracing] Inheriting remote parent's sampled decision for ${spanName}: ${parentSampled}`);
2237
2242
  return parentSampled;
2238
2243
  }
2239
2244
 
2240
2245
  const parentSampled = getSamplingDecision(parentContext);
2241
- DEBUG_BUILD && core.logger.log(`[Tracing] Inheriting parent's sampled decision for ${spanName}: ${parentSampled}`);
2246
+ DEBUG_BUILD && core.debug.log(`[Tracing] Inheriting parent's sampled decision for ${spanName}: ${parentSampled}`);
2242
2247
  return parentSampled;
2243
2248
  }
2244
2249