@sentry/opentelemetry 10.49.0 → 10.50.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.
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.
3
+ *
4
+ * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.
5
+ */
6
+ const DEBUG_BUILD = (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__);
7
+
8
+ exports.DEBUG_BUILD = DEBUG_BUILD;
9
+ //# sourceMappingURL=debug-build-ntZrglYX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-build-ntZrglYX.js","sources":["../../src/debug-build.ts"],"sourcesContent":["declare const __DEBUG_BUILD__: boolean;\n\n/**\n * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nexport const DEBUG_BUILD = __DEBUG_BUILD__;\n"],"names":[],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACO,MAAM,WAAA,IAAc,OAAA,gBAAA,KAAA,WAAA,IAAA,gBAAA;;;;"}
@@ -4,6 +4,7 @@ const semanticConventions = require('@opentelemetry/semantic-conventions');
4
4
  const core = require('@sentry/core');
5
5
  const api = require('@opentelemetry/api');
6
6
  const core$1 = require('@opentelemetry/core');
7
+ const debugBuild = require('./debug-build-ntZrglYX.js');
7
8
  const node_async_hooks = require('node:async_hooks');
8
9
  const node_events = require('node:events');
9
10
  const sdkTraceBase = require('@opentelemetry/sdk-trace-base');
@@ -654,13 +655,6 @@ function getActiveSpan() {
654
655
  return api.trace.getActiveSpan();
655
656
  }
656
657
 
657
- /**
658
- * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.
659
- *
660
- * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.
661
- */
662
- const DEBUG_BUILD = (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__);
663
-
664
658
  /**
665
659
  * Generate a TraceState for the given data.
666
660
  */
@@ -713,7 +707,7 @@ class SentryPropagator extends core$1.W3CBaggagePropagator {
713
707
  */
714
708
  inject(context, carrier, setter) {
715
709
  if (core$1.isTracingSuppressed(context)) {
716
- DEBUG_BUILD && core.debug.log('[Tracing] Not injecting trace data for url because tracing is suppressed.');
710
+ debugBuild.DEBUG_BUILD && core.debug.log('[Tracing] Not injecting trace data for url because tracing is suppressed.');
717
711
  return;
718
712
  }
719
713
 
@@ -722,7 +716,7 @@ class SentryPropagator extends core$1.W3CBaggagePropagator {
722
716
 
723
717
  const { tracePropagationTargets, propagateTraceparent } = core.getClient()?.getOptions() || {};
724
718
  if (!core.shouldPropagateTraceForUrl(url, tracePropagationTargets, this._urlMatchesTargetsMap)) {
725
- DEBUG_BUILD &&
719
+ debugBuild.DEBUG_BUILD &&
726
720
  core.debug.log('[Tracing] Not injecting trace data for url because it does not match tracePropagationTargets:', url);
727
721
  return;
728
722
  }
@@ -991,8 +985,12 @@ function _startSpan(options, callback, autoEnd) {
991
985
 
992
986
  return wrapper(() => {
993
987
  const activeCtx = getContext(options.scope, options.forceTransaction);
994
- const shouldSkipSpan = options.onlyIfParent && !api.trace.getSpan(activeCtx);
995
- const ctx = shouldSkipSpan ? core$1.suppressTracing(activeCtx) : activeCtx;
988
+ const missingRequiredParent = options.onlyIfParent && !api.trace.getSpan(activeCtx);
989
+ const ctx = missingRequiredParent ? core$1.suppressTracing(activeCtx) : activeCtx;
990
+
991
+ if (missingRequiredParent) {
992
+ core.getClient()?.recordDroppedEvent('no_parent_span', 'span');
993
+ }
996
994
 
997
995
  const spanOptions = getSpanOptions(options);
998
996
 
@@ -1094,8 +1092,12 @@ function startInactiveSpan(options) {
1094
1092
 
1095
1093
  return wrapper(() => {
1096
1094
  const activeCtx = getContext(options.scope, options.forceTransaction);
1097
- const shouldSkipSpan = options.onlyIfParent && !api.trace.getSpan(activeCtx);
1098
- let ctx = shouldSkipSpan ? core$1.suppressTracing(activeCtx) : activeCtx;
1095
+ const missingRequiredParent = options.onlyIfParent && !api.trace.getSpan(activeCtx);
1096
+ let ctx = missingRequiredParent ? core$1.suppressTracing(activeCtx) : activeCtx;
1097
+
1098
+ if (missingRequiredParent) {
1099
+ core.getClient()?.recordDroppedEvent('no_parent_span', 'span');
1100
+ }
1099
1101
 
1100
1102
  const spanOptions = getSpanOptions(options);
1101
1103
 
@@ -1955,7 +1957,7 @@ class SentrySpanExporter {
1955
1957
  }
1956
1958
  });
1957
1959
  if (droppedSpanCount > 0) {
1958
- DEBUG_BUILD &&
1960
+ debugBuild.DEBUG_BUILD &&
1959
1961
  core.debug.log(
1960
1962
  `SpanExporter dropped ${droppedSpanCount} spans because they were pending for more than ${this._finishedSpanBucketSize} seconds.`,
1961
1963
  );
@@ -1992,7 +1994,7 @@ class SentrySpanExporter {
1992
1994
 
1993
1995
  const sentSpanCount = sentSpans.size;
1994
1996
  const remainingOpenSpanCount = finishedSpans.length - sentSpanCount;
1995
- DEBUG_BUILD &&
1997
+ debugBuild.DEBUG_BUILD &&
1996
1998
  core.debug.log(
1997
1999
  `SpanExporter exported ${sentSpanCount} spans, ${remainingOpenSpanCount} spans are waiting for their parent spans to finish`,
1998
2000
  );
@@ -2418,6 +2420,7 @@ class SentrySampler {
2418
2420
  // If we have a http.client span that has no local parent, we never want to sample it
2419
2421
  // but we want to leave downstream sampling decisions up to the server
2420
2422
  if (spanKind === api.SpanKind.CLIENT && maybeSpanHttpMethod && (!parentSpan || parentContext?.isRemote)) {
2423
+ this._client.recordDroppedEvent('no_parent_span', 'span');
2421
2424
  return wrapSamplingDecision({ decision: undefined, context, spanAttributes });
2422
2425
  }
2423
2426
 
@@ -2533,7 +2536,7 @@ class SentrySampler {
2533
2536
 
2534
2537
  const method = `${maybeSpanHttpMethod}`.toUpperCase();
2535
2538
  if (method === 'OPTIONS' || method === 'HEAD') {
2536
- DEBUG_BUILD && core.debug.log(`[Tracing] Not sampling span because HTTP method is '${method}' for ${spanName}`);
2539
+ debugBuild.DEBUG_BUILD && core.debug.log(`[Tracing] Not sampling span because HTTP method is '${method}' for ${spanName}`);
2537
2540
 
2538
2541
  return wrapSamplingDecision({
2539
2542
  decision: sdkTraceBase.SamplingDecision.NOT_RECORD,
@@ -2549,7 +2552,7 @@ class SentrySampler {
2549
2552
  // 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)
2550
2553
  parentSampled === undefined
2551
2554
  ) {
2552
- DEBUG_BUILD && core.debug.log('[Tracing] Discarding root span because its trace was not chosen to be sampled.');
2555
+ debugBuild.DEBUG_BUILD && core.debug.log('[Tracing] Discarding root span because its trace was not chosen to be sampled.');
2553
2556
  this._client.recordDroppedEvent('sample_rate', this._isSpanStreaming ? 'span' : 'transaction');
2554
2557
  }
2555
2558
 
@@ -2582,13 +2585,13 @@ function getParentSampled(parentSpan, traceId, spanName) {
2582
2585
  if (api.isSpanContextValid(parentContext) && parentContext.traceId === traceId) {
2583
2586
  if (parentContext.isRemote) {
2584
2587
  const parentSampled = getSamplingDecision(parentSpan.spanContext());
2585
- DEBUG_BUILD &&
2588
+ debugBuild.DEBUG_BUILD &&
2586
2589
  core.debug.log(`[Tracing] Inheriting remote parent's sampled decision for ${spanName}: ${parentSampled}`);
2587
2590
  return parentSampled;
2588
2591
  }
2589
2592
 
2590
2593
  const parentSampled = getSamplingDecision(parentContext);
2591
- DEBUG_BUILD && core.debug.log(`[Tracing] Inheriting parent's sampled decision for ${spanName}: ${parentSampled}`);
2594
+ debugBuild.DEBUG_BUILD && core.debug.log(`[Tracing] Inheriting parent's sampled decision for ${spanName}: ${parentSampled}`);
2592
2595
  return parentSampled;
2593
2596
  }
2594
2597