@sentry/opentelemetry 8.25.0 → 8.26.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/README.md CHANGED
@@ -12,8 +12,8 @@
12
12
 
13
13
  This package allows you to send your OpenTelemetry trace data to Sentry via OpenTelemetry SpanProcessors.
14
14
 
15
- This SDK is **considered experimental and in an alpha state**. It may experience breaking changes. Please reach out on
16
- [GitHub](https://github.com/getsentry/sentry-javascript/issues/new/choose) if you have any feedback/concerns.
15
+ If you are using `@sentry/node`, OpenTelemetry support is included out of the box. This package is only necessary if you
16
+ are setting up OpenTelemetry support for Sentry yourself.
17
17
 
18
18
  ## Installation
19
19
 
@@ -402,10 +402,22 @@ function descriptionForHttpMethod(
402
402
  data['http.fragment'] = fragment;
403
403
  }
404
404
 
405
+ // If the span kind is neither client nor server, we use the original name
406
+ // this infers that somebody manually started this span, in which case we don't want to overwrite the name
407
+ const isClientOrServerKind = kind === api.SpanKind.CLIENT || kind === api.SpanKind.SERVER;
408
+
409
+ // If the span is an auto-span (=it comes from one of our instrumentations),
410
+ // we always want to infer the name
411
+ // this is necessary because some of the auto-instrumentation we use uses kind=INTERNAL
412
+ const origin = attributes[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] || 'manual';
413
+ const isManualSpan = !`${origin}`.startsWith('auto');
414
+
415
+ const useInferredDescription = isClientOrServerKind || !isManualSpan;
416
+
405
417
  return {
406
418
  op: opParts.join('.'),
407
- description,
408
- source,
419
+ description: useInferredDescription ? description : name,
420
+ source: useInferredDescription ? source : 'custom',
409
421
  data,
410
422
  };
411
423
  }
@@ -1186,6 +1198,25 @@ function setupEventContextTrace(client) {
1186
1198
  });
1187
1199
  }
1188
1200
 
1201
+ /**
1202
+ * Otel-specific implementation of `getTraceData`.
1203
+ * @see `@sentry/core` version of `getTraceData` for more information
1204
+ */
1205
+ function getTraceData() {
1206
+ const headersObject = {};
1207
+
1208
+ api.propagation.inject(api.context.active(), headersObject);
1209
+
1210
+ if (!headersObject['sentry-trace']) {
1211
+ return {};
1212
+ }
1213
+
1214
+ return utils.dropUndefinedKeys({
1215
+ 'sentry-trace': headersObject['sentry-trace'],
1216
+ baggage: headersObject.baggage,
1217
+ });
1218
+ }
1219
+
1189
1220
  /**
1190
1221
  * Sets the async context strategy to use follow the OTEL context under the hood.
1191
1222
  * We handle forking a hub inside of our custom OTEL Context Manager (./otelContextManager.ts)
@@ -1274,10 +1305,11 @@ function setOpenTelemetryContextAsyncContextStrategy() {
1274
1305
  startSpanManual,
1275
1306
  startInactiveSpan,
1276
1307
  getActiveSpan,
1308
+ suppressTracing,
1309
+ getTraceData,
1277
1310
  // The types here don't fully align, because our own `Span` type is narrower
1278
1311
  // than the OTEL one - but this is OK for here, as we now we'll only have OTEL spans passed around
1279
1312
  withActiveSpan: withActiveSpan ,
1280
- suppressTracing: suppressTracing,
1281
1313
  });
1282
1314
  }
1283
1315