@sentry/opentelemetry 9.1.0 → 9.1.1-alpha.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.
@@ -1,5 +1,5 @@
1
1
  import { ATTR_URL_FULL, SEMATTRS_HTTP_URL, ATTR_HTTP_REQUEST_METHOD, SEMATTRS_HTTP_METHOD, SEMATTRS_DB_SYSTEM, SEMATTRS_RPC_SERVICE, SEMATTRS_MESSAGING_SYSTEM, SEMATTRS_FAAS_TRIGGER, SEMATTRS_DB_STATEMENT, SEMATTRS_HTTP_TARGET, ATTR_HTTP_ROUTE, ATTR_HTTP_RESPONSE_STATUS_CODE, SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_RPC_GRPC_STATUS_CODE } from '@opentelemetry/semantic-conventions';
2
- import { parseUrl, getSanitizedUrlString, SDK_VERSION, addNonEnumerableProperty, isSentryRequestUrl, getClient, baggageHeaderToDynamicSamplingContext, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, stripUrlQueryAndFragment, spanToJSON, hasSpansEnabled, dynamicSamplingContextToSentryBaggageHeader, LRUMap, logger, parseBaggageHeader, SENTRY_BAGGAGE_KEY_PREFIX, generateSentryTraceHeader, stringMatchesSomePattern, getDynamicSamplingContextFromSpan, getCurrentScope, getDynamicSamplingContextFromScope, propagationContextFromHeaders, getIsolationScope, handleCallbackErrors, getRootSpan, spanToTraceContext, getTraceContextFromScope, getCapturedScopesOnSpan, setAsyncContextStrategy, getDefaultCurrentScope, getDefaultIsolationScope, SPAN_STATUS_OK, SPAN_STATUS_ERROR, getSpanStatusFromHttpCode, timedEventsToMeasurements, captureEvent, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, dropUndefinedKeys, getStatusMessage, spanTimeInputToSeconds, addChildSpanToSpan, setCapturedScopesOnSpan, logSpanStart, logSpanEnd, parseSampleRate, sampleSpan } from '@sentry/core';
2
+ import { parseUrl, getSanitizedUrlString, SDK_VERSION, addNonEnumerableProperty, isSentryRequestUrl, getClient, baggageHeaderToDynamicSamplingContext, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, stripUrlQueryAndFragment, spanToJSON, hasSpansEnabled, dynamicSamplingContextToSentryBaggageHeader, LRUMap, logger, parseBaggageHeader, SENTRY_BAGGAGE_KEY_PREFIX, generateSentryTraceHeader, stringMatchesSomePattern, getDynamicSamplingContextFromSpan, getCurrentScope, getDynamicSamplingContextFromScope, propagationContextFromHeaders, getIsolationScope, handleCallbackErrors, getRootSpan, spanToTraceContext, getTraceContextFromScope, getCapturedScopesOnSpan, setAsyncContextStrategy, getDefaultCurrentScope, getDefaultIsolationScope, SPAN_STATUS_OK, SPAN_STATUS_ERROR, getSpanStatusFromHttpCode, timedEventsToMeasurements, captureEvent, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, dropUndefinedKeys, getStatusMessage, convertSpanLinksForEnvelope, spanTimeInputToSeconds, addChildSpanToSpan, setCapturedScopesOnSpan, logSpanStart, logSpanEnd, parseSampleRate, sampleSpan } from '@sentry/core';
3
3
  export { getClient, getDynamicSamplingContextFromSpan } from '@sentry/core';
4
4
  import * as api from '@opentelemetry/api';
5
5
  import { trace, SpanKind, createContextKey, TraceFlags, propagation, INVALID_TRACEID, context, SpanStatusCode, ROOT_CONTEXT, isSpanContextValid } from '@opentelemetry/api';
@@ -1079,7 +1079,7 @@ function getTracer() {
1079
1079
  }
1080
1080
 
1081
1081
  function getSpanOptions(options) {
1082
- const { startTime, attributes, kind, op } = options;
1082
+ const { startTime, attributes, kind, op, links } = options;
1083
1083
 
1084
1084
  // OTEL expects timestamps in ms, not seconds
1085
1085
  const fixedStartTime = typeof startTime === 'number' ? ensureTimestampInMilliseconds(startTime) : startTime;
@@ -1092,6 +1092,7 @@ function getSpanOptions(options) {
1092
1092
  }
1093
1093
  : attributes,
1094
1094
  kind,
1095
+ links,
1095
1096
  startTime: fixedStartTime,
1096
1097
  };
1097
1098
  }
@@ -1783,6 +1784,7 @@ function createTransactionForOtelSpan(span) {
1783
1784
  ...removeSentryAttributes(span.attributes),
1784
1785
  });
1785
1786
 
1787
+ const { links } = span;
1786
1788
  const { traceId: trace_id, spanId: span_id } = span.spanContext();
1787
1789
 
1788
1790
  // If parentSpanIdFromTraceState is defined at all, we want it to take precedence
@@ -1802,6 +1804,7 @@ function createTransactionForOtelSpan(span) {
1802
1804
  origin,
1803
1805
  op,
1804
1806
  status: getStatusMessage(status), // As per protocol, span status is allowed to be undefined
1807
+ links: convertSpanLinksForEnvelope(links),
1805
1808
  });
1806
1809
 
1807
1810
  const statusCode = attributes[ATTR_HTTP_RESPONSE_STATUS_CODE];
@@ -1858,7 +1861,7 @@ function createAndFinishSpanForOtelSpan(node, spans, sentSpans) {
1858
1861
  const span_id = span.spanContext().spanId;
1859
1862
  const trace_id = span.spanContext().traceId;
1860
1863
 
1861
- const { attributes, startTime, endTime, parentSpanId } = span;
1864
+ const { attributes, startTime, endTime, parentSpanId, links } = span;
1862
1865
 
1863
1866
  const { op, description, data, origin = 'manual' } = getSpanData(span);
1864
1867
  const allData = dropUndefinedKeys({
@@ -1883,6 +1886,7 @@ function createAndFinishSpanForOtelSpan(node, spans, sentSpans) {
1883
1886
  op,
1884
1887
  origin,
1885
1888
  measurements: timedEventsToMeasurements(span.events),
1889
+ links: convertSpanLinksForEnvelope(links),
1886
1890
  });
1887
1891
 
1888
1892
  spans.push(spanJSON);