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