@sentry/opentelemetry 10.51.0 → 10.52.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,6 +1,6 @@
1
1
  import { consoleSandbox } from '@sentry/core';
2
2
  export { getClient, getDynamicSamplingContextFromSpan, shouldPropagateTraceForUrl, withStreamedSpan } from '@sentry/core';
3
- export { a as SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, c as SentryPropagator, d as SentrySampler, e as SentrySpanProcessor, f as continueTrace, g as enhanceDscWithOpenTelemetryRootSpanName, h as getActiveSpan, i as getRequestSpanData, j as getScopesFromContext, k as getSentryResource, l as getSpanKind, m as getTraceContextForScope, n as isSentryRequestSpan, o as openTelemetrySetupCheck, p as setOpenTelemetryContextAsyncContextStrategy, q as setupEventContextTrace, r as spanHasAttributes, t as spanHasEvents, u as spanHasKind, v as spanHasName, w as spanHasParentId, x as spanHasStatus, y as startInactiveSpan, z as startSpan, A as startSpanManual, B as suppressTracing, C as withActiveSpan, D as wrapClientClass, E as wrapContextManagerClass, F as wrapSamplingDecision } from './resource-CQdLBDrM.js';
3
+ export { a as SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, c as SentryPropagator, d as SentrySampler, e as SentrySpanProcessor, f as continueTrace, g as enhanceDscWithOpenTelemetryRootSpanName, h as getActiveSpan, i as getRequestSpanData, j as getScopesFromContext, k as getSentryResource, l as getSpanKind, m as getTraceContextForScope, n as isSentryRequestSpan, o as openTelemetrySetupCheck, p as setOpenTelemetryContextAsyncContextStrategy, q as setupEventContextTrace, r as spanHasAttributes, t as spanHasEvents, u as spanHasKind, v as spanHasName, w as spanHasParentId, x as spanHasStatus, y as startInactiveSpan, z as startSpan, A as startSpanManual, B as suppressTracing, C as withActiveSpan, D as wrapClientClass, E as wrapContextManagerClass, F as wrapSamplingDecision } from './resource-Bhpm2sLf.js';
4
4
  import '@opentelemetry/api';
5
5
  import '@opentelemetry/semantic-conventions';
6
6
  import '@opentelemetry/core';
@@ -1,5 +1,5 @@
1
- import { s as setIsSetup, b as buildContextWithSentryScopes, S as SENTRY_SCOPES_CONTEXT_KEY } from './resource-CQdLBDrM.js';
2
- export { a as SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, c as SentryPropagator, d as SentrySampler, e as SentrySpanProcessor, f as continueTrace, g as enhanceDscWithOpenTelemetryRootSpanName, h as getActiveSpan, i as getRequestSpanData, j as getScopesFromContext, k as getSentryResource, l as getSpanKind, m as getTraceContextForScope, n as isSentryRequestSpan, o as openTelemetrySetupCheck, p as setOpenTelemetryContextAsyncContextStrategy, q as setupEventContextTrace, r as spanHasAttributes, t as spanHasEvents, u as spanHasKind, v as spanHasName, w as spanHasParentId, x as spanHasStatus, y as startInactiveSpan, z as startSpan, A as startSpanManual, B as suppressTracing, C as withActiveSpan, D as wrapClientClass, E as wrapContextManagerClass, F as wrapSamplingDecision } from './resource-CQdLBDrM.js';
1
+ import { s as setIsSetup, b as buildContextWithSentryScopes, S as SENTRY_SCOPES_CONTEXT_KEY } from './resource-Bhpm2sLf.js';
2
+ export { a as SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, c as SentryPropagator, d as SentrySampler, e as SentrySpanProcessor, f as continueTrace, g as enhanceDscWithOpenTelemetryRootSpanName, h as getActiveSpan, i as getRequestSpanData, j as getScopesFromContext, k as getSentryResource, l as getSpanKind, m as getTraceContextForScope, n as isSentryRequestSpan, o as openTelemetrySetupCheck, p as setOpenTelemetryContextAsyncContextStrategy, q as setupEventContextTrace, r as spanHasAttributes, t as spanHasEvents, u as spanHasKind, v as spanHasName, w as spanHasParentId, x as spanHasStatus, y as startInactiveSpan, z as startSpan, A as startSpanManual, B as suppressTracing, C as withActiveSpan, D as wrapClientClass, E as wrapContextManagerClass, F as wrapSamplingDecision } from './resource-Bhpm2sLf.js';
3
3
  export { getClient, getDynamicSamplingContextFromSpan, shouldPropagateTraceForUrl, withStreamedSpan } from '@sentry/core';
4
4
  import { ROOT_CONTEXT } from '@opentelemetry/api';
5
5
  import { AsyncLocalStorage } from 'node:async_hooks';
@@ -1 +1 @@
1
- {"type":"module","version":"10.51.0","sideEffects":false}
1
+ {"type":"module","version":"10.52.0","sideEffects":false}
@@ -1,7 +1,7 @@
1
1
  import * as api from '@opentelemetry/api';
2
2
  import { trace, SpanKind, createContextKey, TraceFlags, propagation, INVALID_TRACEID, context, SpanStatusCode, ROOT_CONTEXT, isSpanContextValid } from '@opentelemetry/api';
3
3
  import { parseUrl, getSanitizedUrlString, SDK_VERSION, derefWeakRef, addNonEnumerableProperty, makeWeakRef, isSentryRequestUrl, getClient, baggageHeaderToDynamicSamplingContext, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME, stripUrlQueryAndFragment, spanToJSON, hasSpansEnabled, dynamicSamplingContextToSentryBaggageHeader, LRUMap, debug, shouldPropagateTraceForUrl, parseBaggageHeader, SENTRY_BAGGAGE_KEY_PREFIX, generateSentryTraceHeader, generateTraceparentHeader, getDynamicSamplingContextFromSpan, getCurrentScope, getDynamicSamplingContextFromScope, getIsolationScope, propagationContextFromHeaders, shouldContinueTrace, spanToTraceContext, getTraceContextFromScope, generateTraceId, generateSpanId, _INTERNAL_safeMathRandom, getRootSpan, handleCallbackErrors, getCapturedScopesOnSpan, setAsyncContextStrategy, getDefaultIsolationScope, getDefaultCurrentScope, SPAN_STATUS_OK, SPAN_STATUS_ERROR, getSpanStatusFromHttpCode, _INTERNAL_safeDateNow, debounce, timedEventsToMeasurements, captureEvent, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, convertSpanLinksForEnvelope, getStatusMessage, spanTimeInputToSeconds, addChildSpanToSpan, setCapturedScopesOnSpan, logSpanStart, logSpanEnd, hasSpanStreamingEnabled, shouldIgnoreSpan, parseSampleRate, sampleSpan } from '@sentry/core';
4
- import { ATTR_URL_FULL, SEMATTRS_HTTP_URL, ATTR_HTTP_REQUEST_METHOD, SEMATTRS_HTTP_METHOD, ATTR_DB_SYSTEM_NAME, 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, ATTR_TELEMETRY_SDK_VERSION, ATTR_TELEMETRY_SDK_NAME, ATTR_TELEMETRY_SDK_LANGUAGE, ATTR_SERVICE_VERSION, SEMRESATTRS_SERVICE_NAMESPACE, ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
4
+ import { ATTR_URL_FULL, SEMATTRS_HTTP_URL, ATTR_HTTP_REQUEST_METHOD, SEMATTRS_HTTP_METHOD, ATTR_DB_SYSTEM_NAME, 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, ATTR_TELEMETRY_SDK_VERSION, ATTR_TELEMETRY_SDK_NAME, ATTR_TELEMETRY_SDK_LANGUAGE, ATTR_SERVICE_VERSION, ATTR_SERVICE_NAME, SEMRESATTRS_SERVICE_NAMESPACE } from '@opentelemetry/semantic-conventions';
5
5
  import { TraceState, W3CBaggagePropagator, isTracingSuppressed, suppressTracing as suppressTracing$1, SDK_INFO } from '@opentelemetry/core';
6
6
  import { D as DEBUG_BUILD } from './debug-build-DcLzdrV_.js';
7
7
  import { SamplingDecision } from '@opentelemetry/sdk-trace-base';
@@ -2239,10 +2239,13 @@ class SentrySampler {
2239
2239
  const maybeSpanHttpMethod = spanAttributes[SEMATTRS_HTTP_METHOD] || spanAttributes[ATTR_HTTP_REQUEST_METHOD];
2240
2240
 
2241
2241
  // If we have a http.client span that has no local parent, we never want to sample it
2242
- // but we want to leave downstream sampling decisions up to the server
2242
+ // but we want to leave downstream sampling decisions up to the server.
2243
+ // Exception: when span streaming is enabled, we always emit these spans.
2243
2244
  if (spanKind === SpanKind.CLIENT && maybeSpanHttpMethod && (!parentSpan || parentContext?.isRemote)) {
2244
- this._client.recordDroppedEvent('no_parent_span', 'span');
2245
- return wrapSamplingDecision({ decision: undefined, context, spanAttributes });
2245
+ if (!this._isSpanStreaming) {
2246
+ this._client.recordDroppedEvent('no_parent_span', 'span');
2247
+ return wrapSamplingDecision({ decision: undefined, context, spanAttributes });
2248
+ }
2246
2249
  }
2247
2250
 
2248
2251
  const parentSampled = parentSpan ? getParentSampled(parentSpan, traceId, spanName) : undefined;
@@ -2530,18 +2533,58 @@ class SentryResource {
2530
2533
  }
2531
2534
  }
2532
2535
 
2536
+ /**
2537
+ * Parses `OTEL_RESOURCE_ATTRIBUTES` env var (comma-separated `key=value` pairs).
2538
+ * Values are URL-decoded per the OTel spec.
2539
+ */
2540
+ function parseOtelResourceAttributes(raw) {
2541
+ if (!raw) {
2542
+ return {};
2543
+ }
2544
+ const result = {};
2545
+ for (const pair of raw.split(',')) {
2546
+ const eq = pair.indexOf('=');
2547
+ if (eq === -1) {
2548
+ continue;
2549
+ }
2550
+ const key = pair.substring(0, eq).trim();
2551
+ const value = pair.substring(eq + 1).trim();
2552
+ if (key) {
2553
+ try {
2554
+ result[key] = decodeURIComponent(value);
2555
+ } catch {
2556
+ result[key] = value;
2557
+ }
2558
+ }
2559
+ }
2560
+ return result;
2561
+ }
2562
+
2533
2563
  /**
2534
2564
  * Returns a Resource for use in Sentry's OpenTelemetry TracerProvider setup.
2535
2565
  *
2536
2566
  * Combines the default OTel SDK telemetry attributes with Sentry-specific
2537
2567
  * service attributes, equivalent to what was previously done via:
2538
2568
  * `defaultResource().merge(resourceFromAttributes({ ... }))`
2569
+ *
2570
+ * Respects OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES environment variables
2571
+ * per the OpenTelemetry specification.
2539
2572
  */
2540
- function getSentryResource(serviceName) {
2573
+ function getSentryResource(serviceNameFallback) {
2574
+ const env = typeof process !== 'undefined' ? process.env : {};
2575
+ const otelServiceName = env.OTEL_SERVICE_NAME;
2576
+ const otelResourceAttrs = parseOtelResourceAttributes(env.OTEL_RESOURCE_ATTRIBUTES);
2577
+
2541
2578
  return new SentryResource({
2542
- [ATTR_SERVICE_NAME]: serviceName,
2579
+ // Lowest priority: Sentry defaults
2543
2580
  // eslint-disable-next-line deprecation/deprecation
2544
2581
  [SEMRESATTRS_SERVICE_NAMESPACE]: 'sentry',
2582
+ [ATTR_SERVICE_NAME]: serviceNameFallback,
2583
+ // OTEL_RESOURCE_ATTRIBUTES overrides defaults (including service.name and service.namespace)
2584
+ ...otelResourceAttrs,
2585
+ // OTEL_SERVICE_NAME explicitly overrides service.name
2586
+ ...(otelServiceName ? { [ATTR_SERVICE_NAME]: otelServiceName } : {}),
2587
+ // Highest priority: Sentry SDK telemetry attrs (cannot be overridden by env vars)
2545
2588
  [ATTR_SERVICE_VERSION]: SDK_VERSION,
2546
2589
  [ATTR_TELEMETRY_SDK_LANGUAGE]: SDK_INFO[ATTR_TELEMETRY_SDK_LANGUAGE],
2547
2590
  [ATTR_TELEMETRY_SDK_NAME]: SDK_INFO[ATTR_TELEMETRY_SDK_NAME],
@@ -2550,4 +2593,4 @@ function getSentryResource(serviceName) {
2550
2593
  }
2551
2594
 
2552
2595
  export { startSpanManual as A, suppressTracing as B, withActiveSpan as C, wrapClientClass as D, wrapContextManagerClass as E, wrapSamplingDecision as F, SENTRY_SCOPES_CONTEXT_KEY as S, SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION as a, buildContextWithSentryScopes as b, SentryPropagator as c, SentrySampler as d, SentrySpanProcessor as e, continueTrace as f, enhanceDscWithOpenTelemetryRootSpanName as g, getActiveSpan as h, getRequestSpanData as i, getScopesFromContext as j, getSentryResource as k, getSpanKind as l, getTraceContextForScope as m, isSentryRequestSpan as n, openTelemetrySetupCheck as o, setOpenTelemetryContextAsyncContextStrategy as p, setupEventContextTrace as q, spanHasAttributes as r, setIsSetup as s, spanHasEvents as t, spanHasKind as u, spanHasName as v, spanHasParentId as w, spanHasStatus as x, startInactiveSpan as y, startSpan as z };
2553
- //# sourceMappingURL=resource-CQdLBDrM.js.map
2596
+ //# sourceMappingURL=resource-Bhpm2sLf.js.map