@sentry/opentelemetry 10.32.0-alpha.0 → 10.32.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.
@@ -1648,7 +1648,7 @@ const DEFAULT_TIMEOUT = 300; // 5 min
1648
1648
  /**
1649
1649
  * A Sentry-specific exporter that converts OpenTelemetry Spans to Sentry Spans & Transactions.
1650
1650
  */
1651
- class SentrySpanExporter {
1651
+ class SentrySpanExporter {
1652
1652
  /*
1653
1653
  * A quick explanation on the buckets: We do bucketing of finished spans for efficiency. This span exporter is
1654
1654
  * accumulating spans until a root span is encountered and then it flushes all the spans that are descendants of that
@@ -1979,9 +1979,6 @@ function createAndFinishSpanForOtelSpan(node, spans, sentSpans) {
1979
1979
  });
1980
1980
  }
1981
1981
 
1982
- /**
1983
- * Get span data from the OTEL span
1984
- */
1985
1982
  function getSpanData(span)
1986
1983
 
1987
1984
  {
@@ -2048,63 +2045,6 @@ function getData(span) {
2048
2045
  return data;
2049
2046
  }
2050
2047
 
2051
- /**
2052
- * A Sentry-specific exporter that buffers span JSON objects and streams them to Sentry
2053
- * in Span v2 envelopes. This exporter works with pre-serialized span JSON rather than
2054
- * OTel span instances to avoid mutating already-ended spans.
2055
- */
2056
- class StreamingSpanExporter {
2057
-
2058
- constructor(client, options) {
2059
- this._client = client;
2060
- this._buffer = new core.SpanBuffer(client, {
2061
- maxSpanLimit: options?.maxSpanLimit,
2062
- flushInterval: options?.flushInterval,
2063
- });
2064
-
2065
- // OTel-specific: add span attributes from ReadableSpan
2066
- this._client.on('processSpan', (spanJSON, hint) => {
2067
- const { readOnlySpan } = hint;
2068
- // TODO: This can be simplified by using spanJSON to get the data instead of the readOnlySpan
2069
- // for now this is the easiest backwards-compatible way to get the data.
2070
- const { op, description, data, origin = 'manual' } = getSpanData(readOnlySpan );
2071
- const allData = {
2072
- [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: origin,
2073
- [core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: op,
2074
- ...data,
2075
- };
2076
- core.safeSetSpanJSONAttributes(spanJSON, allData);
2077
- spanJSON.name = description;
2078
- });
2079
-
2080
- this._client.on('enqueueSpan', spanJSON => {
2081
- this._buffer.addSpan(spanJSON);
2082
- });
2083
- }
2084
-
2085
- /**
2086
- * Enqueue a span JSON into the buffer
2087
- */
2088
- export(span) {
2089
- core.captureSpan(span, this._client);
2090
- }
2091
-
2092
- /**
2093
- * Try to flush any pending spans immediately.
2094
- */
2095
- flush() {
2096
- this._buffer.flush();
2097
- }
2098
-
2099
- /**
2100
- * Clear the exporter.
2101
- * This is called when the span processor is shut down.
2102
- */
2103
- clear() {
2104
- // No-op for streaming exporter - spans are flushed immediately on interval
2105
- }
2106
- }
2107
-
2108
2048
  function onSpanStart(span, parentContext) {
2109
2049
  // This is a reliable way to get the parent span - because this is exactly how the parent is identified in the OTEL SDK
2110
2050
  const parentSpan = api.trace.getSpan(parentContext);
@@ -2141,6 +2081,13 @@ function onSpanStart(span, parentContext) {
2141
2081
  client?.emit('spanStart', span);
2142
2082
  }
2143
2083
 
2084
+ function onSpanEnd(span) {
2085
+ core.logSpanEnd(span);
2086
+
2087
+ const client = core.getClient();
2088
+ client?.emit('spanEnd', span);
2089
+ }
2090
+
2144
2091
  /**
2145
2092
  * Converts OpenTelemetry Spans to Sentry Spans and sends them to Sentry via
2146
2093
  * the Sentry SDK.
@@ -2149,12 +2096,7 @@ class SentrySpanProcessor {
2149
2096
 
2150
2097
  constructor(options) {
2151
2098
  setIsSetup('SentrySpanProcessor');
2152
- this._client = options?.client ?? core.getClient();
2153
- if (this._client?.getOptions().traceLifecycle === 'stream') {
2154
- this._exporter = new StreamingSpanExporter(this._client, { flushInterval: options?.timeout });
2155
- } else {
2156
- this._exporter = new SentrySpanExporter(options);
2157
- }
2099
+ this._exporter = new SentrySpanExporter(options);
2158
2100
  }
2159
2101
 
2160
2102
  /**
@@ -2180,9 +2122,7 @@ class SentrySpanProcessor {
2180
2122
 
2181
2123
  /** @inheritDoc */
2182
2124
  onEnd(span) {
2183
- core.logSpanEnd(span);
2184
-
2185
- this._client?.emit('spanEnd', span);
2125
+ onSpanEnd(span);
2186
2126
 
2187
2127
  this._exporter.export(span);
2188
2128
  }