@sentry/opentelemetry 10.32.1 → 10.33.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.js +17 -5
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.js +18 -6
- package/build/esm/index.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/types/constants.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/utils/contextData.d.ts.map +1 -1
- package/build/types/utils/isSentryRequest.d.ts.map +1 -1
- package/package.json +2 -2
package/build/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ATTR_URL_FULL, SEMATTRS_HTTP_URL, ATTR_HTTP_REQUEST_METHOD, SEMATTRS_HTTP_METHOD, 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 } from '@opentelemetry/semantic-conventions';
|
|
2
|
-
import { parseUrl, getSanitizedUrlString, SDK_VERSION, addNonEnumerableProperty, 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, parseBaggageHeader, SENTRY_BAGGAGE_KEY_PREFIX, generateSentryTraceHeader, generateTraceparentHeader, stringMatchesSomePattern, getDynamicSamplingContextFromSpan, getCurrentScope, getDynamicSamplingContextFromScope, getIsolationScope, propagationContextFromHeaders, shouldContinueTrace, spanToTraceContext, getTraceContextFromScope, handleCallbackErrors, getRootSpan, getCapturedScopesOnSpan, setAsyncContextStrategy, getDefaultIsolationScope, getDefaultCurrentScope, SPAN_STATUS_OK, SPAN_STATUS_ERROR, getSpanStatusFromHttpCode, debounce, timedEventsToMeasurements, captureEvent, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, convertSpanLinksForEnvelope, getStatusMessage, spanTimeInputToSeconds, addChildSpanToSpan, setCapturedScopesOnSpan, logSpanStart, logSpanEnd, parseSampleRate, sampleSpan } from '@sentry/core';
|
|
2
|
+
import { parseUrl, getSanitizedUrlString, SDK_VERSION, addNonEnumerableProperty, 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, parseBaggageHeader, SENTRY_BAGGAGE_KEY_PREFIX, generateSentryTraceHeader, generateTraceparentHeader, stringMatchesSomePattern, getDynamicSamplingContextFromSpan, getCurrentScope, getDynamicSamplingContextFromScope, getIsolationScope, propagationContextFromHeaders, shouldContinueTrace, spanToTraceContext, getTraceContextFromScope, handleCallbackErrors, getRootSpan, 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, parseSampleRate, _INTERNAL_safeMathRandom, sampleSpan } from '@sentry/core';
|
|
3
3
|
export { getClient, getDynamicSamplingContextFromSpan } from '@sentry/core';
|
|
4
4
|
import * as api from '@opentelemetry/api';
|
|
5
5
|
import { trace, SpanKind, createContextKey, TraceFlags, propagation, INVALID_TRACEID, context, SpanStatusCode, ROOT_CONTEXT, isSpanContextValid } from '@opentelemetry/api';
|
|
@@ -215,6 +215,10 @@ const SENTRY_TRACE_STATE_URL = 'sentry.url';
|
|
|
215
215
|
const SENTRY_TRACE_STATE_SAMPLE_RAND = 'sentry.sample_rand';
|
|
216
216
|
const SENTRY_TRACE_STATE_SAMPLE_RATE = 'sentry.sample_rate';
|
|
217
217
|
|
|
218
|
+
// NOTE: `@sentry/nextjs` has a local copy of this context key for Edge bundles:
|
|
219
|
+
// - `packages/nextjs/src/edge/index.ts` (`SENTRY_SCOPES_CONTEXT_KEY`)
|
|
220
|
+
//
|
|
221
|
+
// If you change the key name passed to `createContextKey(...)`, update that file too.
|
|
218
222
|
const SENTRY_SCOPES_CONTEXT_KEY = createContextKey('sentry_scopes');
|
|
219
223
|
|
|
220
224
|
const SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY = createContextKey('sentry_fork_isolation_scope');
|
|
@@ -230,6 +234,10 @@ const SCOPE_CONTEXT_FIELD = '_scopeContext';
|
|
|
230
234
|
* This requires a Context Manager that was wrapped with getWrappedContextManager.
|
|
231
235
|
*/
|
|
232
236
|
function getScopesFromContext(context) {
|
|
237
|
+
// NOTE: `@sentry/nextjs` has a local copy of this helper for Edge bundles:
|
|
238
|
+
// - `packages/nextjs/src/edge/index.ts` (`getScopesFromContext`)
|
|
239
|
+
//
|
|
240
|
+
// If you change how scopes are stored/read (key or retrieval), update that file too.
|
|
233
241
|
return context.getValue(SENTRY_SCOPES_CONTEXT_KEY) ;
|
|
234
242
|
}
|
|
235
243
|
|
|
@@ -262,6 +270,10 @@ function getContextFromScope(scope) {
|
|
|
262
270
|
* @returns boolean
|
|
263
271
|
*/
|
|
264
272
|
function isSentryRequestSpan(span) {
|
|
273
|
+
// NOTE: `@sentry/nextjs` has a local copy of this helper for Edge bundles:
|
|
274
|
+
// - `packages/nextjs/src/common/utils/dropMiddlewareTunnelRequests.ts` (`isSentryRequestSpan`)
|
|
275
|
+
//
|
|
276
|
+
// If you change supported OTEL attribute keys or request detection logic, update that file too.
|
|
265
277
|
if (!spanHasAttributes(span)) {
|
|
266
278
|
return false;
|
|
267
279
|
}
|
|
@@ -1676,7 +1688,7 @@ class SentrySpanExporter {
|
|
|
1676
1688
|
) {
|
|
1677
1689
|
this._finishedSpanBucketSize = options?.timeout || DEFAULT_TIMEOUT;
|
|
1678
1690
|
this._finishedSpanBuckets = new Array(this._finishedSpanBucketSize).fill(undefined);
|
|
1679
|
-
this._lastCleanupTimestampInS = Math.floor(
|
|
1691
|
+
this._lastCleanupTimestampInS = Math.floor(_INTERNAL_safeDateNow() / 1000);
|
|
1680
1692
|
this._spansToBucketEntry = new WeakMap();
|
|
1681
1693
|
this._sentSpans = new Map();
|
|
1682
1694
|
this._debouncedFlush = debounce(this.flush.bind(this), 1, { maxWait: 100 });
|
|
@@ -1687,7 +1699,7 @@ class SentrySpanExporter {
|
|
|
1687
1699
|
* This is called by the span processor whenever a span is ended.
|
|
1688
1700
|
*/
|
|
1689
1701
|
export(span) {
|
|
1690
|
-
const currentTimestampInS = Math.floor(
|
|
1702
|
+
const currentTimestampInS = Math.floor(_INTERNAL_safeDateNow() / 1000);
|
|
1691
1703
|
|
|
1692
1704
|
if (this._lastCleanupTimestampInS !== currentTimestampInS) {
|
|
1693
1705
|
let droppedSpanCount = 0;
|
|
@@ -1740,7 +1752,7 @@ class SentrySpanExporter {
|
|
|
1740
1752
|
`SpanExporter exported ${sentSpanCount} spans, ${remainingOpenSpanCount} spans are waiting for their parent spans to finish`,
|
|
1741
1753
|
);
|
|
1742
1754
|
|
|
1743
|
-
const expirationDate =
|
|
1755
|
+
const expirationDate = _INTERNAL_safeDateNow() + DEFAULT_TIMEOUT * 1000;
|
|
1744
1756
|
|
|
1745
1757
|
for (const span of sentSpans) {
|
|
1746
1758
|
this._sentSpans.set(span.spanContext().spanId, expirationDate);
|
|
@@ -1820,7 +1832,7 @@ class SentrySpanExporter {
|
|
|
1820
1832
|
|
|
1821
1833
|
/** Remove "expired" span id entries from the _sentSpans cache. */
|
|
1822
1834
|
_flushSentSpanCache() {
|
|
1823
|
-
const currentTimestamp =
|
|
1835
|
+
const currentTimestamp = _INTERNAL_safeDateNow();
|
|
1824
1836
|
// Note, it is safe to delete items from the map as we go: https://stackoverflow.com/a/35943995/90297
|
|
1825
1837
|
for (const [spanId, expirationTime] of this._sentSpans.entries()) {
|
|
1826
1838
|
if (expirationTime <= currentTimestamp) {
|
|
@@ -2215,7 +2227,7 @@ class SentrySampler {
|
|
|
2215
2227
|
const dscString = parentContext?.traceState ? parentContext.traceState.get(SENTRY_TRACE_STATE_DSC) : undefined;
|
|
2216
2228
|
const dsc = dscString ? baggageHeaderToDynamicSamplingContext(dscString) : undefined;
|
|
2217
2229
|
|
|
2218
|
-
const sampleRand = parseSampleRate(dsc?.sample_rand) ??
|
|
2230
|
+
const sampleRand = parseSampleRate(dsc?.sample_rand) ?? _INTERNAL_safeMathRandom();
|
|
2219
2231
|
|
|
2220
2232
|
const [sampled, sampleRate, localSampleRateWasApplied] = sampleSpan(
|
|
2221
2233
|
options,
|