@sentry/opentelemetry 10.51.0 → 10.53.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/build/cjs/index.browser.js +1 -1
- package/build/cjs/index.js +1 -1
- package/build/cjs/{resource-XtlN3b7H.js → resource-CD6NEt3L.js} +73 -10
- package/build/{esm/resource-CQdLBDrM.js.map → cjs/resource-CD6NEt3L.js.map} +1 -1
- package/build/esm/index.browser.js +1 -1
- package/build/esm/index.js +2 -2
- package/build/esm/package.json +1 -1
- package/build/esm/{resource-CQdLBDrM.js → resource-BDW0nlGH.js} +74 -11
- package/build/{cjs/resource-XtlN3b7H.js.map → esm/resource-BDW0nlGH.js.map} +1 -1
- package/build/types/resource.d.ts +4 -1
- package/build/types/resource.d.ts.map +1 -1
- package/build/types/sampler.d.ts.map +1 -1
- package/build/types/spanExporter.d.ts.map +1 -1
- package/build/types-ts3.8/resource.d.ts +4 -1
- package/package.json +2 -2
|
@@ -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-
|
|
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-BDW0nlGH.js';
|
|
4
4
|
import '@opentelemetry/api';
|
|
5
5
|
import '@opentelemetry/semantic-conventions';
|
|
6
6
|
import '@opentelemetry/core';
|
package/build/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { s as setIsSetup, b as buildContextWithSentryScopes, S as SENTRY_SCOPES_CONTEXT_KEY } from './resource-
|
|
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-
|
|
1
|
+
import { s as setIsSetup, b as buildContextWithSentryScopes, S as SENTRY_SCOPES_CONTEXT_KEY } from './resource-BDW0nlGH.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-BDW0nlGH.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';
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"10.
|
|
1
|
+
{"type":"module","version":"10.53.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,
|
|
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';
|
|
@@ -1876,8 +1876,11 @@ class SentrySpanExporter {
|
|
|
1876
1876
|
// We'll recursively add all the child spans to this array
|
|
1877
1877
|
const spans = transactionEvent.spans || [];
|
|
1878
1878
|
|
|
1879
|
+
let hasGenAiSpans = false;
|
|
1879
1880
|
for (const child of root.children) {
|
|
1880
|
-
createAndFinishSpanForOtelSpan(child, spans, sentSpans)
|
|
1881
|
+
if (createAndFinishSpanForOtelSpan(child, spans, sentSpans)) {
|
|
1882
|
+
hasGenAiSpans = true;
|
|
1883
|
+
}
|
|
1881
1884
|
}
|
|
1882
1885
|
|
|
1883
1886
|
// spans.sort() mutates the array, but we do not use this anymore after this point
|
|
@@ -1887,6 +1890,13 @@ class SentrySpanExporter {
|
|
|
1887
1890
|
? spans.sort((a, b) => a.start_timestamp - b.start_timestamp).slice(0, MAX_SPAN_COUNT)
|
|
1888
1891
|
: spans;
|
|
1889
1892
|
|
|
1893
|
+
if (hasGenAiSpans) {
|
|
1894
|
+
transactionEvent.sdkProcessingMetadata = {
|
|
1895
|
+
...transactionEvent.sdkProcessingMetadata,
|
|
1896
|
+
hasGenAiSpans: true,
|
|
1897
|
+
};
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1890
1900
|
const measurements = timedEventsToMeasurements(span.events);
|
|
1891
1901
|
if (measurements) {
|
|
1892
1902
|
transactionEvent.measurements = measurements;
|
|
@@ -2003,6 +2013,9 @@ function createTransactionForOtelSpan(span) {
|
|
|
2003
2013
|
return transactionEvent;
|
|
2004
2014
|
}
|
|
2005
2015
|
|
|
2016
|
+
/**
|
|
2017
|
+
* Returns `true` if this span or any descendant is a gen_ai span.
|
|
2018
|
+
*/
|
|
2006
2019
|
function createAndFinishSpanForOtelSpan(node, spans, sentSpans) {
|
|
2007
2020
|
const span = node.span;
|
|
2008
2021
|
|
|
@@ -2014,10 +2027,13 @@ function createAndFinishSpanForOtelSpan(node, spans, sentSpans) {
|
|
|
2014
2027
|
|
|
2015
2028
|
// If this span should be dropped, we still want to create spans for the children of this
|
|
2016
2029
|
if (shouldDrop) {
|
|
2030
|
+
let hasGenAiSpans = false;
|
|
2017
2031
|
node.children.forEach(child => {
|
|
2018
|
-
createAndFinishSpanForOtelSpan(child, spans, sentSpans)
|
|
2032
|
+
if (createAndFinishSpanForOtelSpan(child, spans, sentSpans)) {
|
|
2033
|
+
hasGenAiSpans = true;
|
|
2034
|
+
}
|
|
2019
2035
|
});
|
|
2020
|
-
return;
|
|
2036
|
+
return hasGenAiSpans;
|
|
2021
2037
|
}
|
|
2022
2038
|
|
|
2023
2039
|
const span_id = span.spanContext().spanId;
|
|
@@ -2054,9 +2070,13 @@ function createAndFinishSpanForOtelSpan(node, spans, sentSpans) {
|
|
|
2054
2070
|
|
|
2055
2071
|
spans.push(spanJSON);
|
|
2056
2072
|
|
|
2073
|
+
let hasGenAiSpans = !!op?.startsWith('gen_ai.');
|
|
2057
2074
|
node.children.forEach(child => {
|
|
2058
|
-
createAndFinishSpanForOtelSpan(child, spans, sentSpans)
|
|
2075
|
+
if (createAndFinishSpanForOtelSpan(child, spans, sentSpans)) {
|
|
2076
|
+
hasGenAiSpans = true;
|
|
2077
|
+
}
|
|
2059
2078
|
});
|
|
2079
|
+
return hasGenAiSpans;
|
|
2060
2080
|
}
|
|
2061
2081
|
|
|
2062
2082
|
function getSpanData(span)
|
|
@@ -2239,10 +2259,13 @@ class SentrySampler {
|
|
|
2239
2259
|
const maybeSpanHttpMethod = spanAttributes[SEMATTRS_HTTP_METHOD] || spanAttributes[ATTR_HTTP_REQUEST_METHOD];
|
|
2240
2260
|
|
|
2241
2261
|
// 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
|
|
2262
|
+
// but we want to leave downstream sampling decisions up to the server.
|
|
2263
|
+
// Exception: when span streaming is enabled, we always emit these spans.
|
|
2243
2264
|
if (spanKind === SpanKind.CLIENT && maybeSpanHttpMethod && (!parentSpan || parentContext?.isRemote)) {
|
|
2244
|
-
this.
|
|
2245
|
-
|
|
2265
|
+
if (!this._isSpanStreaming) {
|
|
2266
|
+
this._client.recordDroppedEvent('no_parent_span', 'span');
|
|
2267
|
+
return wrapSamplingDecision({ decision: undefined, context, spanAttributes });
|
|
2268
|
+
}
|
|
2246
2269
|
}
|
|
2247
2270
|
|
|
2248
2271
|
const parentSampled = parentSpan ? getParentSampled(parentSpan, traceId, spanName) : undefined;
|
|
@@ -2530,18 +2553,58 @@ class SentryResource {
|
|
|
2530
2553
|
}
|
|
2531
2554
|
}
|
|
2532
2555
|
|
|
2556
|
+
/**
|
|
2557
|
+
* Parses `OTEL_RESOURCE_ATTRIBUTES` env var (comma-separated `key=value` pairs).
|
|
2558
|
+
* Values are URL-decoded per the OTel spec.
|
|
2559
|
+
*/
|
|
2560
|
+
function parseOtelResourceAttributes(raw) {
|
|
2561
|
+
if (!raw) {
|
|
2562
|
+
return {};
|
|
2563
|
+
}
|
|
2564
|
+
const result = {};
|
|
2565
|
+
for (const pair of raw.split(',')) {
|
|
2566
|
+
const eq = pair.indexOf('=');
|
|
2567
|
+
if (eq === -1) {
|
|
2568
|
+
continue;
|
|
2569
|
+
}
|
|
2570
|
+
const key = pair.substring(0, eq).trim();
|
|
2571
|
+
const value = pair.substring(eq + 1).trim();
|
|
2572
|
+
if (key) {
|
|
2573
|
+
try {
|
|
2574
|
+
result[key] = decodeURIComponent(value);
|
|
2575
|
+
} catch {
|
|
2576
|
+
result[key] = value;
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
return result;
|
|
2581
|
+
}
|
|
2582
|
+
|
|
2533
2583
|
/**
|
|
2534
2584
|
* Returns a Resource for use in Sentry's OpenTelemetry TracerProvider setup.
|
|
2535
2585
|
*
|
|
2536
2586
|
* Combines the default OTel SDK telemetry attributes with Sentry-specific
|
|
2537
2587
|
* service attributes, equivalent to what was previously done via:
|
|
2538
2588
|
* `defaultResource().merge(resourceFromAttributes({ ... }))`
|
|
2589
|
+
*
|
|
2590
|
+
* Respects OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES environment variables
|
|
2591
|
+
* per the OpenTelemetry specification.
|
|
2539
2592
|
*/
|
|
2540
|
-
function getSentryResource(
|
|
2593
|
+
function getSentryResource(serviceNameFallback) {
|
|
2594
|
+
const env = typeof process !== 'undefined' ? process.env : {};
|
|
2595
|
+
const otelServiceName = env.OTEL_SERVICE_NAME;
|
|
2596
|
+
const otelResourceAttrs = parseOtelResourceAttributes(env.OTEL_RESOURCE_ATTRIBUTES);
|
|
2597
|
+
|
|
2541
2598
|
return new SentryResource({
|
|
2542
|
-
|
|
2599
|
+
// Lowest priority: Sentry defaults
|
|
2543
2600
|
// eslint-disable-next-line deprecation/deprecation
|
|
2544
2601
|
[SEMRESATTRS_SERVICE_NAMESPACE]: 'sentry',
|
|
2602
|
+
[ATTR_SERVICE_NAME]: serviceNameFallback,
|
|
2603
|
+
// OTEL_RESOURCE_ATTRIBUTES overrides defaults (including service.name and service.namespace)
|
|
2604
|
+
...otelResourceAttrs,
|
|
2605
|
+
// OTEL_SERVICE_NAME explicitly overrides service.name
|
|
2606
|
+
...(otelServiceName ? { [ATTR_SERVICE_NAME]: otelServiceName } : {}),
|
|
2607
|
+
// Highest priority: Sentry SDK telemetry attrs (cannot be overridden by env vars)
|
|
2545
2608
|
[ATTR_SERVICE_VERSION]: SDK_VERSION,
|
|
2546
2609
|
[ATTR_TELEMETRY_SDK_LANGUAGE]: SDK_INFO[ATTR_TELEMETRY_SDK_LANGUAGE],
|
|
2547
2610
|
[ATTR_TELEMETRY_SDK_NAME]: SDK_INFO[ATTR_TELEMETRY_SDK_NAME],
|
|
@@ -2550,4 +2613,4 @@ function getSentryResource(serviceName) {
|
|
|
2550
2613
|
}
|
|
2551
2614
|
|
|
2552
2615
|
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-
|
|
2616
|
+
//# sourceMappingURL=resource-BDW0nlGH.js.map
|