@sentry/opentelemetry 8.0.0-beta.3 → 8.0.0-beta.4

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
@@ -289,7 +289,10 @@ function parseSpanDescription(span) {
289
289
  const name = spanHasName(span) ? span.name : '<unknown>';
290
290
 
291
291
  // if http.method exists, this is an http request span
292
- const httpMethod = attributes[semanticConventions.SEMATTRS_HTTP_METHOD];
292
+ //
293
+ // TODO: Referencing `http.request.method` is a temporary workaround until the semantic
294
+ // conventions export an attribute key for it.
295
+ const httpMethod = attributes['http.request.method'] || attributes[semanticConventions.SEMATTRS_HTTP_METHOD];
293
296
  if (httpMethod) {
294
297
  return descriptionForHttpMethod({ attributes, name, kind: getSpanKind(span) }, httpMethod);
295
298
  }
@@ -1550,7 +1553,7 @@ function maybeSend(spans) {
1550
1553
  transactionEvent.spans = spans;
1551
1554
 
1552
1555
  const measurements = core.timedEventsToMeasurements(span.events);
1553
- if (Object.keys(measurements).length) {
1556
+ if (measurements) {
1554
1557
  transactionEvent.measurements = measurements;
1555
1558
  }
1556
1559
 
@@ -1688,6 +1691,7 @@ function createAndFinishSpanForOtelSpan(node, spans, remaining) {
1688
1691
  op,
1689
1692
  origin,
1690
1693
  _metrics_summary: core.getMetricSummaryJsonForSpan(span ),
1694
+ measurements: core.timedEventsToMeasurements(span.events),
1691
1695
  });
1692
1696
 
1693
1697
  spans.push(spanJSON);
@@ -1892,11 +1896,18 @@ class SentrySampler {
1892
1896
 
1893
1897
  const parentSampled = parentSpan ? getParentSampled(parentSpan, traceId, spanName) : undefined;
1894
1898
 
1895
- // If we encounter a span emitted by Next.js, we do not want to sample it
1896
- // The reason for this is that the data quality of the spans varies, it is different per version of Next,
1897
- // and we need to keep our manual instrumentation around for the edge runtime anyhow.
1898
- // BUT we only do this if we don't have a parent span with a sampling decision yet (or if the parent is remote)
1899
- if (spanAttributes['next.span_type'] && (typeof parentSampled !== 'boolean' || _optionalChain([parentContext, 'optionalAccess', _5 => _5.isRemote]))) {
1899
+ const mutableSamplingDecision = { decision: true };
1900
+ this._client.emit(
1901
+ 'beforeSampling',
1902
+ {
1903
+ spanAttributes: spanAttributes,
1904
+ spanName: spanName,
1905
+ parentSampled: parentSampled,
1906
+ parentContext: parentContext,
1907
+ },
1908
+ mutableSamplingDecision,
1909
+ );
1910
+ if (!mutableSamplingDecision.decision) {
1900
1911
  return { decision: sdkTraceBase.SamplingDecision.NOT_RECORD, traceState: traceState };
1901
1912
  }
1902
1913
 
@@ -1978,11 +1989,9 @@ function getParentSampled(parentSpan, traceId, spanName) {
1978
1989
  * This method takes an OpenTelemetry instrumentation or
1979
1990
  * array of instrumentations and registers them with OpenTelemetry.
1980
1991
  */
1981
- function addOpenTelemetryInstrumentation(
1982
- instrumentation$1,
1983
- ) {
1992
+ function addOpenTelemetryInstrumentation(...instrumentations) {
1984
1993
  instrumentation.registerInstrumentations({
1985
- instrumentations: Array.isArray(instrumentation$1) ? instrumentation$1 : [instrumentation$1],
1994
+ instrumentations,
1986
1995
  });
1987
1996
  }
1988
1997