@sentry/opentelemetry 10.39.0-alpha.0 → 10.40.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.
@@ -1618,7 +1618,7 @@ const DEFAULT_TIMEOUT = 300; // 5 min
1618
1618
  /**
1619
1619
  * A Sentry-specific exporter that converts OpenTelemetry Spans to Sentry Spans & Transactions.
1620
1620
  */
1621
- class SentrySpanExporter {
1621
+ class SentrySpanExporter {
1622
1622
  /*
1623
1623
  * A quick explanation on the buckets: We do bucketing of finished spans for efficiency. This span exporter is
1624
1624
  * accumulating spans until a root span is encountered and then it flushes all the spans that are descendants of that
@@ -1949,9 +1949,6 @@ function createAndFinishSpanForOtelSpan(node, spans, sentSpans) {
1949
1949
  });
1950
1950
  }
1951
1951
 
1952
- /**
1953
- * Get span data from the OTEL span
1954
- */
1955
1952
  function getSpanData(span)
1956
1953
 
1957
1954
  {
@@ -2018,66 +2015,6 @@ function getData(span) {
2018
2015
  return data;
2019
2016
  }
2020
2017
 
2021
- /**
2022
- * A Sentry-specific exporter that buffers span JSON objects and streams them to Sentry
2023
- * in Span v2 envelopes. This exporter works with pre-serialized span JSON rather than
2024
- * OTel span instances to avoid mutating already-ended spans.
2025
- */
2026
- class StreamingSpanExporter {
2027
-
2028
- constructor(client, options) {
2029
- this._client = client;
2030
- this._buffer = new core.SpanBuffer(client, {
2031
- maxSpanLimit: options?.maxSpanLimit,
2032
- flushInterval: options?.flushInterval,
2033
- });
2034
-
2035
- // OTel-specific: add span attributes from ReadableSpan
2036
- this._client.on('processSpan', (spanJSON, hint) => {
2037
- const { readOnlySpan } = hint;
2038
- // TODO: This can be simplified by using spanJSON to get the data instead of the readOnlySpan
2039
- // for now this is the easiest backwards-compatible way to get the data.
2040
- const { op, description, data, origin = 'manual' } = getSpanData(readOnlySpan );
2041
- const allData = {
2042
- [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: origin,
2043
- [core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: op,
2044
- [core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',
2045
- ...data,
2046
- };
2047
- core.safeSetSpanJSONAttributes(spanJSON, allData);
2048
- spanJSON.name = description;
2049
- });
2050
-
2051
- this._client.on('enqueueSpan', spanJSON => {
2052
- this._buffer.addSpan(spanJSON);
2053
- });
2054
-
2055
- DEBUG_BUILD && core.debug.log('[Tracing] Initialized StreamingSpanExporter');
2056
- }
2057
-
2058
- /**
2059
- * Enqueue a span JSON into the buffer
2060
- */
2061
- export(span) {
2062
- core.captureSpan(span, this._client);
2063
- }
2064
-
2065
- /**
2066
- * Try to flush any pending spans immediately.
2067
- */
2068
- flush() {
2069
- this._buffer.flush();
2070
- }
2071
-
2072
- /**
2073
- * Clear the exporter.
2074
- * This is called when the span processor is shut down.
2075
- */
2076
- clear() {
2077
- // No-op for streaming exporter - spans are flushed immediately on interval
2078
- }
2079
- }
2080
-
2081
2018
  function onSpanStart(span, parentContext) {
2082
2019
  // This is a reliable way to get the parent span - because this is exactly how the parent is identified in the OTEL SDK
2083
2020
  const parentSpan = api.trace.getSpan(parentContext);
@@ -2114,6 +2051,13 @@ function onSpanStart(span, parentContext) {
2114
2051
  client?.emit('spanStart', span);
2115
2052
  }
2116
2053
 
2054
+ function onSpanEnd(span) {
2055
+ core.logSpanEnd(span);
2056
+
2057
+ const client = core.getClient();
2058
+ client?.emit('spanEnd', span);
2059
+ }
2060
+
2117
2061
  /**
2118
2062
  * Converts OpenTelemetry Spans to Sentry Spans and sends them to Sentry via
2119
2063
  * the Sentry SDK.
@@ -2122,12 +2066,7 @@ class SentrySpanProcessor {
2122
2066
 
2123
2067
  constructor(options) {
2124
2068
  setIsSetup('SentrySpanProcessor');
2125
- this._client = options?.client ?? core.getClient();
2126
- if (this._client?.getOptions().traceLifecycle === 'stream') {
2127
- this._exporter = new StreamingSpanExporter(this._client, { flushInterval: options?.timeout });
2128
- } else {
2129
- this._exporter = new SentrySpanExporter(options);
2130
- }
2069
+ this._exporter = new SentrySpanExporter(options);
2131
2070
  }
2132
2071
 
2133
2072
  /**
@@ -2153,9 +2092,7 @@ class SentrySpanProcessor {
2153
2092
 
2154
2093
  /** @inheritDoc */
2155
2094
  onEnd(span) {
2156
- core.logSpanEnd(span);
2157
-
2158
- this._client?.emit('spanEnd', span);
2095
+ onSpanEnd(span);
2159
2096
 
2160
2097
  this._exporter.export(span);
2161
2098
  }