@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.
- package/build/cjs/index.browser.js +1 -1
- package/build/cjs/index.js +1 -1
- package/build/cjs/{resource-XtlN3b7H.js → resource-C7SKXNJp.js} +49 -6
- package/build/{esm/resource-CQdLBDrM.js.map → cjs/resource-C7SKXNJp.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-Bhpm2sLf.js} +50 -7
- package/build/{cjs/resource-XtlN3b7H.js.map → esm/resource-Bhpm2sLf.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-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-C7SKXNJp.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-C7SKXNJp.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');
|
|
@@ -2238,10 +2238,13 @@ class SentrySampler {
|
|
|
2238
2238
|
const maybeSpanHttpMethod = spanAttributes[semanticConventions.SEMATTRS_HTTP_METHOD] || spanAttributes[semanticConventions.ATTR_HTTP_REQUEST_METHOD];
|
|
2239
2239
|
|
|
2240
2240
|
// 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
|
|
2241
|
+
// but we want to leave downstream sampling decisions up to the server.
|
|
2242
|
+
// Exception: when span streaming is enabled, we always emit these spans.
|
|
2242
2243
|
if (spanKind === api.SpanKind.CLIENT && maybeSpanHttpMethod && (!parentSpan || parentContext?.isRemote)) {
|
|
2243
|
-
this.
|
|
2244
|
-
|
|
2244
|
+
if (!this._isSpanStreaming) {
|
|
2245
|
+
this._client.recordDroppedEvent('no_parent_span', 'span');
|
|
2246
|
+
return wrapSamplingDecision({ decision: undefined, context, spanAttributes });
|
|
2247
|
+
}
|
|
2245
2248
|
}
|
|
2246
2249
|
|
|
2247
2250
|
const parentSampled = parentSpan ? getParentSampled(parentSpan, traceId, spanName) : undefined;
|
|
@@ -2529,18 +2532,58 @@ class SentryResource {
|
|
|
2529
2532
|
}
|
|
2530
2533
|
}
|
|
2531
2534
|
|
|
2535
|
+
/**
|
|
2536
|
+
* Parses `OTEL_RESOURCE_ATTRIBUTES` env var (comma-separated `key=value` pairs).
|
|
2537
|
+
* Values are URL-decoded per the OTel spec.
|
|
2538
|
+
*/
|
|
2539
|
+
function parseOtelResourceAttributes(raw) {
|
|
2540
|
+
if (!raw) {
|
|
2541
|
+
return {};
|
|
2542
|
+
}
|
|
2543
|
+
const result = {};
|
|
2544
|
+
for (const pair of raw.split(',')) {
|
|
2545
|
+
const eq = pair.indexOf('=');
|
|
2546
|
+
if (eq === -1) {
|
|
2547
|
+
continue;
|
|
2548
|
+
}
|
|
2549
|
+
const key = pair.substring(0, eq).trim();
|
|
2550
|
+
const value = pair.substring(eq + 1).trim();
|
|
2551
|
+
if (key) {
|
|
2552
|
+
try {
|
|
2553
|
+
result[key] = decodeURIComponent(value);
|
|
2554
|
+
} catch {
|
|
2555
|
+
result[key] = value;
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
return result;
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2532
2562
|
/**
|
|
2533
2563
|
* Returns a Resource for use in Sentry's OpenTelemetry TracerProvider setup.
|
|
2534
2564
|
*
|
|
2535
2565
|
* Combines the default OTel SDK telemetry attributes with Sentry-specific
|
|
2536
2566
|
* service attributes, equivalent to what was previously done via:
|
|
2537
2567
|
* `defaultResource().merge(resourceFromAttributes({ ... }))`
|
|
2568
|
+
*
|
|
2569
|
+
* Respects OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES environment variables
|
|
2570
|
+
* per the OpenTelemetry specification.
|
|
2538
2571
|
*/
|
|
2539
|
-
function getSentryResource(
|
|
2572
|
+
function getSentryResource(serviceNameFallback) {
|
|
2573
|
+
const env = typeof process !== 'undefined' ? process.env : {};
|
|
2574
|
+
const otelServiceName = env.OTEL_SERVICE_NAME;
|
|
2575
|
+
const otelResourceAttrs = parseOtelResourceAttributes(env.OTEL_RESOURCE_ATTRIBUTES);
|
|
2576
|
+
|
|
2540
2577
|
return new SentryResource({
|
|
2541
|
-
|
|
2578
|
+
// Lowest priority: Sentry defaults
|
|
2542
2579
|
// eslint-disable-next-line deprecation/deprecation
|
|
2543
2580
|
[semanticConventions.SEMRESATTRS_SERVICE_NAMESPACE]: 'sentry',
|
|
2581
|
+
[semanticConventions.ATTR_SERVICE_NAME]: serviceNameFallback,
|
|
2582
|
+
// OTEL_RESOURCE_ATTRIBUTES overrides defaults (including service.name and service.namespace)
|
|
2583
|
+
...otelResourceAttrs,
|
|
2584
|
+
// OTEL_SERVICE_NAME explicitly overrides service.name
|
|
2585
|
+
...(otelServiceName ? { [semanticConventions.ATTR_SERVICE_NAME]: otelServiceName } : {}),
|
|
2586
|
+
// Highest priority: Sentry SDK telemetry attrs (cannot be overridden by env vars)
|
|
2544
2587
|
[semanticConventions.ATTR_SERVICE_VERSION]: core.SDK_VERSION,
|
|
2545
2588
|
[semanticConventions.ATTR_TELEMETRY_SDK_LANGUAGE]: core$1.SDK_INFO[semanticConventions.ATTR_TELEMETRY_SDK_LANGUAGE],
|
|
2546
2589
|
[semanticConventions.ATTR_TELEMETRY_SDK_NAME]: core$1.SDK_INFO[semanticConventions.ATTR_TELEMETRY_SDK_NAME],
|
|
@@ -2581,4 +2624,4 @@ exports.withActiveSpan = withActiveSpan;
|
|
|
2581
2624
|
exports.wrapClientClass = wrapClientClass;
|
|
2582
2625
|
exports.wrapContextManagerClass = wrapContextManagerClass;
|
|
2583
2626
|
exports.wrapSamplingDecision = wrapSamplingDecision;
|
|
2584
|
-
//# sourceMappingURL=resource-
|
|
2627
|
+
//# sourceMappingURL=resource-C7SKXNJp.js.map
|