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