@sentry/opentelemetry 10.62.0 → 10.63.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/{resource-DuZKnQnC.js → asyncContextStrategy-CvLbRw2N.js} +95 -101
- package/build/cjs/asyncContextStrategy-CvLbRw2N.js.map +1 -0
- package/build/cjs/index.browser.js +31 -35
- package/build/cjs/index.browser.js.map +1 -1
- package/build/cjs/index.js +64 -38
- package/build/cjs/index.js.map +1 -1
- package/build/esm/{resource-DazDAxCp.js → asyncContextStrategy-DfM95hx5.js} +99 -105
- package/build/esm/asyncContextStrategy-DfM95hx5.js.map +1 -0
- package/build/esm/index.browser.js +1 -5
- package/build/esm/index.browser.js.map +1 -1
- package/build/esm/index.js +35 -7
- package/build/esm/index.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/types/asyncContextStrategy.d.ts +4 -1
- package/build/types/asyncContextStrategy.d.ts.map +1 -1
- package/build/types/asyncLocalStorageContextManager.d.ts.map +1 -1
- package/build/types/exports.d.ts +0 -1
- package/build/types/exports.d.ts.map +1 -1
- package/build/types/index.browser.d.ts +1 -0
- package/build/types/index.browser.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/nodeAsyncContextStrategy.d.ts +4 -0
- package/build/types/nodeAsyncContextStrategy.d.ts.map +1 -0
- package/build/types/utils/parseSpanDescription.d.ts.map +1 -1
- package/build/types/utils/suppressTracing.d.ts +2 -0
- package/build/types/utils/suppressTracing.d.ts.map +1 -1
- package/build/types-ts3.8/asyncContextStrategy.d.ts +4 -1
- package/build/types-ts3.8/exports.d.ts +0 -1
- package/build/types-ts3.8/index.browser.d.ts +1 -0
- package/build/types-ts3.8/index.d.ts +1 -0
- package/build/types-ts3.8/nodeAsyncContextStrategy.d.ts +4 -0
- package/build/types-ts3.8/utils/suppressTracing.d.ts +2 -0
- package/package.json +2 -2
- package/build/cjs/resource-DuZKnQnC.js.map +0 -1
- package/build/esm/resource-DazDAxCp.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const api = require('@opentelemetry/api');
|
|
2
2
|
const core = require('@sentry/core');
|
|
3
3
|
const attributes = require('@sentry/conventions/attributes');
|
|
4
|
-
const core$1 = require('@opentelemetry/core');
|
|
5
4
|
const sdkTraceBase = require('@opentelemetry/sdk-trace-base');
|
|
5
|
+
const core$1 = require('@opentelemetry/core');
|
|
6
6
|
|
|
7
7
|
const SEMANTIC_ATTRIBUTE_SENTRY_PARENT_IS_REMOTE = "sentry.parentIsRemote";
|
|
8
8
|
const SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION = "sentry.graphql.operation";
|
|
@@ -247,10 +247,10 @@ function descriptionForHttpMethod({ name, kind, attributes }, httpMethod) {
|
|
|
247
247
|
data.url = url;
|
|
248
248
|
}
|
|
249
249
|
if (query) {
|
|
250
|
-
data["http.query"] = query;
|
|
250
|
+
data["http.query"] = query.slice(1);
|
|
251
251
|
}
|
|
252
252
|
if (fragment) {
|
|
253
|
-
data["http.fragment"] = fragment;
|
|
253
|
+
data["http.fragment"] = fragment.slice(1);
|
|
254
254
|
}
|
|
255
255
|
const isClientOrServerKind = kind === api.SpanKind.CLIENT || kind === api.SpanKind.SERVER;
|
|
256
256
|
const origin = attributes[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] || "manual";
|
|
@@ -745,6 +745,10 @@ function suppressTracing(callback) {
|
|
|
745
745
|
const ctx = core$1.suppressTracing(api.context.active());
|
|
746
746
|
return api.context.with(ctx, callback);
|
|
747
747
|
}
|
|
748
|
+
function isTracingSuppressed(scope) {
|
|
749
|
+
const ctx = scope ? getContextFromScope(scope) : api.context.active();
|
|
750
|
+
return ctx ? core$1.isTracingSuppressed(ctx) : false;
|
|
751
|
+
}
|
|
748
752
|
|
|
749
753
|
function setupEventContextTrace(client) {
|
|
750
754
|
client.on("preprocessEvent", (event) => {
|
|
@@ -765,103 +769,6 @@ function setupEventContextTrace(client) {
|
|
|
765
769
|
});
|
|
766
770
|
}
|
|
767
771
|
|
|
768
|
-
function getTraceData({
|
|
769
|
-
span,
|
|
770
|
-
scope,
|
|
771
|
-
client,
|
|
772
|
-
propagateTraceparent
|
|
773
|
-
} = {}) {
|
|
774
|
-
let ctx = (scope && getContextFromScope(scope)) ?? api.context.active();
|
|
775
|
-
if (span) {
|
|
776
|
-
const { scope: scope2 } = core.getCapturedScopesOnSpan(span);
|
|
777
|
-
ctx = scope2 && getContextFromScope(scope2) || api.trace.setSpan(api.context.active(), span);
|
|
778
|
-
}
|
|
779
|
-
const { traceId, spanId, sampled, dynamicSamplingContext } = getInjectionData(ctx, { scope, client });
|
|
780
|
-
const traceData = {
|
|
781
|
-
"sentry-trace": core.generateSentryTraceHeader(traceId, spanId, sampled),
|
|
782
|
-
baggage: core.dynamicSamplingContextToSentryBaggageHeader(dynamicSamplingContext)
|
|
783
|
-
};
|
|
784
|
-
if (propagateTraceparent) {
|
|
785
|
-
traceData.traceparent = core.generateTraceparentHeader(traceId, spanId, sampled);
|
|
786
|
-
}
|
|
787
|
-
return traceData;
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
function setOpenTelemetryContextAsyncContextStrategy() {
|
|
791
|
-
function getScopes() {
|
|
792
|
-
const ctx = api.context.active();
|
|
793
|
-
const scopes = getScopesFromContext(ctx);
|
|
794
|
-
if (scopes) {
|
|
795
|
-
return scopes;
|
|
796
|
-
}
|
|
797
|
-
return {
|
|
798
|
-
scope: core.getDefaultCurrentScope(),
|
|
799
|
-
isolationScope: core.getDefaultIsolationScope()
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
function withScope(callback) {
|
|
803
|
-
const ctx = api.context.active();
|
|
804
|
-
return api.context.with(ctx, () => {
|
|
805
|
-
return callback(getCurrentScope());
|
|
806
|
-
});
|
|
807
|
-
}
|
|
808
|
-
function withSetScope(scope, callback) {
|
|
809
|
-
const ctx = getContextFromScope(scope) || api.context.active();
|
|
810
|
-
return api.context.with(ctx.setValue(SENTRY_FORK_SET_SCOPE_CONTEXT_KEY, scope), () => {
|
|
811
|
-
return callback(scope);
|
|
812
|
-
});
|
|
813
|
-
}
|
|
814
|
-
function withIsolationScope(callback) {
|
|
815
|
-
const ctx = api.context.active();
|
|
816
|
-
return api.context.with(ctx.setValue(SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY, true), () => {
|
|
817
|
-
return callback(getIsolationScope());
|
|
818
|
-
});
|
|
819
|
-
}
|
|
820
|
-
function withSetIsolationScope(isolationScope, callback) {
|
|
821
|
-
const ctx = api.context.active();
|
|
822
|
-
return api.context.with(ctx.setValue(SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY, isolationScope), () => {
|
|
823
|
-
return callback(getIsolationScope());
|
|
824
|
-
});
|
|
825
|
-
}
|
|
826
|
-
function getCurrentScope() {
|
|
827
|
-
return getScopes().scope;
|
|
828
|
-
}
|
|
829
|
-
function getIsolationScope() {
|
|
830
|
-
return getScopes().isolationScope;
|
|
831
|
-
}
|
|
832
|
-
core.setAsyncContextStrategy({
|
|
833
|
-
withScope,
|
|
834
|
-
withSetScope,
|
|
835
|
-
withSetIsolationScope,
|
|
836
|
-
withIsolationScope,
|
|
837
|
-
getCurrentScope,
|
|
838
|
-
getIsolationScope,
|
|
839
|
-
startSpan,
|
|
840
|
-
startSpanManual,
|
|
841
|
-
startInactiveSpan,
|
|
842
|
-
getActiveSpan,
|
|
843
|
-
suppressTracing,
|
|
844
|
-
getTraceData,
|
|
845
|
-
continueTrace,
|
|
846
|
-
startNewTrace,
|
|
847
|
-
// The types here don't fully align, because our own `Span` type is narrower
|
|
848
|
-
// than the OTEL one - but this is OK for here, as we now we'll only have OTEL spans passed around
|
|
849
|
-
withActiveSpan,
|
|
850
|
-
getTracingChannelBinding: () => {
|
|
851
|
-
try {
|
|
852
|
-
const contextManager = api.context._getContextManager();
|
|
853
|
-
const lookup = contextManager.getAsyncLocalStorageLookup();
|
|
854
|
-
return {
|
|
855
|
-
asyncLocalStorage: lookup.asyncLocalStorage,
|
|
856
|
-
getStoreWithActiveSpan: (span) => api.trace.setSpan(api.context.active(), span)
|
|
857
|
-
};
|
|
858
|
-
} catch {
|
|
859
|
-
return void 0;
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
});
|
|
863
|
-
}
|
|
864
|
-
|
|
865
772
|
function buildContextWithSentryScopes(context, activeContext) {
|
|
866
773
|
const span = api.trace.getSpan(context);
|
|
867
774
|
let effectiveContext;
|
|
@@ -1666,6 +1573,93 @@ function getSentryResource(serviceNameFallback) {
|
|
|
1666
1573
|
});
|
|
1667
1574
|
}
|
|
1668
1575
|
|
|
1576
|
+
function getTraceData({
|
|
1577
|
+
span,
|
|
1578
|
+
scope,
|
|
1579
|
+
client,
|
|
1580
|
+
propagateTraceparent
|
|
1581
|
+
} = {}) {
|
|
1582
|
+
let ctx = (scope && getContextFromScope(scope)) ?? api.context.active();
|
|
1583
|
+
if (span) {
|
|
1584
|
+
const { scope: scope2 } = core.getCapturedScopesOnSpan(span);
|
|
1585
|
+
ctx = scope2 && getContextFromScope(scope2) || api.trace.setSpan(api.context.active(), span);
|
|
1586
|
+
}
|
|
1587
|
+
const { traceId, spanId, sampled, dynamicSamplingContext } = getInjectionData(ctx, { scope, client });
|
|
1588
|
+
const traceData = {
|
|
1589
|
+
"sentry-trace": core.generateSentryTraceHeader(traceId, spanId, sampled),
|
|
1590
|
+
baggage: core.dynamicSamplingContextToSentryBaggageHeader(dynamicSamplingContext)
|
|
1591
|
+
};
|
|
1592
|
+
if (propagateTraceparent) {
|
|
1593
|
+
traceData.traceparent = core.generateTraceparentHeader(traceId, spanId, sampled);
|
|
1594
|
+
}
|
|
1595
|
+
return traceData;
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
function setOpenTelemetryContextAsyncContextStrategy(options) {
|
|
1599
|
+
function getScopes() {
|
|
1600
|
+
const ctx = api.context.active();
|
|
1601
|
+
const scopes = getScopesFromContext(ctx);
|
|
1602
|
+
if (scopes) {
|
|
1603
|
+
return scopes;
|
|
1604
|
+
}
|
|
1605
|
+
return {
|
|
1606
|
+
scope: core.getDefaultCurrentScope(),
|
|
1607
|
+
isolationScope: core.getDefaultIsolationScope()
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
function withScope(callback) {
|
|
1611
|
+
const ctx = api.context.active();
|
|
1612
|
+
return api.context.with(ctx, () => {
|
|
1613
|
+
return callback(getCurrentScope());
|
|
1614
|
+
});
|
|
1615
|
+
}
|
|
1616
|
+
function withSetScope(scope, callback) {
|
|
1617
|
+
const ctx = getContextFromScope(scope) || api.context.active();
|
|
1618
|
+
return api.context.with(ctx.setValue(SENTRY_FORK_SET_SCOPE_CONTEXT_KEY, scope), () => {
|
|
1619
|
+
return callback(scope);
|
|
1620
|
+
});
|
|
1621
|
+
}
|
|
1622
|
+
function withIsolationScope(callback) {
|
|
1623
|
+
const ctx = api.context.active();
|
|
1624
|
+
return api.context.with(ctx.setValue(SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY, true), () => {
|
|
1625
|
+
return callback(getIsolationScope());
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
function withSetIsolationScope(isolationScope, callback) {
|
|
1629
|
+
const ctx = api.context.active();
|
|
1630
|
+
return api.context.with(ctx.setValue(SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY, isolationScope), () => {
|
|
1631
|
+
return callback(getIsolationScope());
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
function getCurrentScope() {
|
|
1635
|
+
return getScopes().scope;
|
|
1636
|
+
}
|
|
1637
|
+
function getIsolationScope() {
|
|
1638
|
+
return getScopes().isolationScope;
|
|
1639
|
+
}
|
|
1640
|
+
core.setAsyncContextStrategy({
|
|
1641
|
+
withScope,
|
|
1642
|
+
withSetScope,
|
|
1643
|
+
withSetIsolationScope,
|
|
1644
|
+
withIsolationScope,
|
|
1645
|
+
getCurrentScope,
|
|
1646
|
+
getIsolationScope,
|
|
1647
|
+
startSpan,
|
|
1648
|
+
startSpanManual,
|
|
1649
|
+
startInactiveSpan,
|
|
1650
|
+
getActiveSpan,
|
|
1651
|
+
suppressTracing,
|
|
1652
|
+
isTracingSuppressed,
|
|
1653
|
+
getTraceData,
|
|
1654
|
+
continueTrace,
|
|
1655
|
+
startNewTrace,
|
|
1656
|
+
// The types here don't fully align, because our own `Span` type is narrower
|
|
1657
|
+
// than the OTEL one - but this is OK for here, as we now we'll only have OTEL spans passed around
|
|
1658
|
+
withActiveSpan,
|
|
1659
|
+
getTracingChannelBinding: options?.getTracingChannelBinding
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1669
1663
|
exports.SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION = SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION;
|
|
1670
1664
|
exports.SENTRY_SCOPES_CONTEXT_KEY = SENTRY_SCOPES_CONTEXT_KEY;
|
|
1671
1665
|
exports.SentryPropagator = SentryPropagator;
|
|
@@ -1699,4 +1693,4 @@ exports.withActiveSpan = withActiveSpan;
|
|
|
1699
1693
|
exports.wrapClientClass = wrapClientClass;
|
|
1700
1694
|
exports.wrapContextManagerClass = wrapContextManagerClass;
|
|
1701
1695
|
exports.wrapSamplingDecision = wrapSamplingDecision;
|
|
1702
|
-
//# sourceMappingURL=
|
|
1696
|
+
//# sourceMappingURL=asyncContextStrategy-CvLbRw2N.js.map
|