Skip to content

Commit be19213

Browse files
committed
Update to latest SDK and re-add measurements
1 parent 0620ad8 commit be19213

File tree

3 files changed

+84
-84
lines changed

3 files changed

+84
-84
lines changed

packages/bundler-plugin-core/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@
7070
"@rollup/plugin-replace": "^4.0.0",
7171
"@sentry-internal/eslint-config": "2.22.4",
7272
"@sentry-internal/sentry-bundler-plugin-tsconfig": "2.22.4",
73-
"@sentry/core": "8.28.0",
74-
"@sentry/types": "8.28.0",
75-
"@sentry/utils": "8.28.0",
73+
"@sentry/core": "8.30.0",
74+
"@sentry/types": "8.30.0",
75+
"@sentry/utils": "8.30.0",
7676
"@swc/core": "^1.2.205",
7777
"@swc/jest": "^0.2.21",
7878
"@types/jest": "^28.1.3",

packages/bundler-plugin-core/src/debug-id-upload.ts

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import SentryCli from "@sentry/cli";
99
import { dynamicSamplingContextToSentryBaggageHeader } from "@sentry/utils";
1010
import { safeFlushTelemetry } from "./sentry/telemetry";
1111
import { stripQueryAndHashFromPath } from "./utils";
12-
import { spanToTraceHeader, startSpan } from "@sentry/core";
12+
import { setMeasurement, spanToTraceHeader, startSpan } from "@sentry/core";
1313
import { getDynamicSamplingContextFromSpan, Scope } from "@sentry/core";
1414
import { Client } from "@sentry/types";
1515

@@ -107,76 +107,76 @@ export function createDebugIdUploadFunction({
107107
"Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option."
108108
);
109109
} else {
110-
await startSpan({ name: "prepare-bundles", scope: sentryScope }, async () => {
111-
// Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so
112-
// instead we do it with a maximum of 16 concurrent workers
113-
const preparationTasks = debugIdChunkFilePaths.map(
114-
(chunkFilePath, chunkIndex) => async () => {
115-
await prepareBundleForDebugIdUpload(
116-
chunkFilePath,
117-
tmpUploadFolder,
118-
chunkIndex,
119-
logger,
120-
rewriteSourcesHook ?? defaultRewriteSourcesHook
121-
);
122-
}
123-
);
124-
const workers: Promise<void>[] = [];
125-
const worker = async () => {
126-
while (preparationTasks.length > 0) {
127-
const task = preparationTasks.shift();
128-
if (task) {
129-
await task();
110+
await startSpan(
111+
{ name: "prepare-bundles", scope: sentryScope },
112+
async (prepBundlesSpan) => {
113+
// Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so
114+
// instead we do it with a maximum of 16 concurrent workers
115+
const preparationTasks = debugIdChunkFilePaths.map(
116+
(chunkFilePath, chunkIndex) => async () => {
117+
await prepareBundleForDebugIdUpload(
118+
chunkFilePath,
119+
tmpUploadFolder,
120+
chunkIndex,
121+
logger,
122+
rewriteSourcesHook ?? defaultRewriteSourcesHook
123+
);
130124
}
125+
);
126+
const workers: Promise<void>[] = [];
127+
const worker = async () => {
128+
while (preparationTasks.length > 0) {
129+
const task = preparationTasks.shift();
130+
if (task) {
131+
await task();
132+
}
133+
}
134+
};
135+
for (let workerIndex = 0; workerIndex < 16; workerIndex++) {
136+
workers.push(worker());
131137
}
132-
};
133-
for (let workerIndex = 0; workerIndex < 16; workerIndex++) {
134-
workers.push(worker());
135-
}
136138

137-
await Promise.all(workers);
138-
139-
// TODO: Bring back measurements
140-
// There's no easy way to get the root span when not using a global client.
141-
142-
// const files = await fs.promises.readdir(tmpUploadFolder);
143-
// const stats = files.map((file) => fs.promises.stat(path.join(tmpUploadFolder, file)));
144-
// const uploadSize = (await Promise.all(stats)).reduce(
145-
// (accumulator, { size }) => accumulator + size,
146-
// 0
147-
// );
148-
149-
// artifactBundleUploadTransaction.setMeasurement("files", files.length, "none");
150-
// artifactBundleUploadTransaction.setMeasurement("upload_size", uploadSize, "byte");
151-
152-
await startSpan({ name: "upload", scope: sentryScope }, async (uploadSpan) => {
153-
const cliInstance = new SentryCli(null, {
154-
...sentryCliOptions,
155-
headers: {
156-
"sentry-trace": spanToTraceHeader(uploadSpan),
157-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
158-
baggage: dynamicSamplingContextToSentryBaggageHeader(
159-
getDynamicSamplingContextFromSpan(uploadSpan)
160-
)!,
161-
...sentryCliOptions.headers,
162-
},
163-
});
139+
await Promise.all(workers);
164140

165-
await cliInstance.releases.uploadSourceMaps(
166-
releaseName ?? "undefined", // unfortunetly this needs a value for now but it will not matter since debug IDs overpower releases anyhow
167-
{
168-
include: [
169-
{
170-
paths: [tmpUploadFolder],
171-
rewrite: false,
172-
dist: dist,
173-
},
174-
],
175-
useArtifactBundle: true,
176-
}
141+
const files = await fs.promises.readdir(tmpUploadFolder);
142+
const stats = files.map((file) => fs.promises.stat(path.join(tmpUploadFolder, file)));
143+
const uploadSize = (await Promise.all(stats)).reduce(
144+
(accumulator, { size }) => accumulator + size,
145+
0
177146
);
178-
});
179-
});
147+
148+
setMeasurement("files", files.length, "none", prepBundlesSpan);
149+
setMeasurement("upload_size", uploadSize, "byte", prepBundlesSpan);
150+
151+
await startSpan({ name: "upload", scope: sentryScope }, async (uploadSpan) => {
152+
const cliInstance = new SentryCli(null, {
153+
...sentryCliOptions,
154+
headers: {
155+
"sentry-trace": spanToTraceHeader(uploadSpan),
156+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
157+
baggage: dynamicSamplingContextToSentryBaggageHeader(
158+
getDynamicSamplingContextFromSpan(uploadSpan)
159+
)!,
160+
...sentryCliOptions.headers,
161+
},
162+
});
163+
164+
await cliInstance.releases.uploadSourceMaps(
165+
releaseName ?? "undefined", // unfortunetly this needs a value for now but it will not matter since debug IDs overpower releases anyhow
166+
{
167+
include: [
168+
{
169+
paths: [tmpUploadFolder],
170+
rewrite: false,
171+
dist: dist,
172+
},
173+
],
174+
useArtifactBundle: true,
175+
}
176+
);
177+
});
178+
}
179+
);
180180

181181
logger.info("Successfully uploaded source maps to Sentry");
182182
}

yarn.lock

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2789,13 +2789,13 @@
27892789
"@sentry/utils" "7.50.0"
27902790
tslib "^1.9.3"
27912791

2792-
"@sentry/core@8.28.0":
2793-
version "8.28.0"
2794-
resolved "https://registry.npmjs.org/@sentry/core/-/core-8.28.0.tgz#dd28fa913c296b443d4070f147c63e81edf429c8"
2795-
integrity sha512-+If9uubvpZpvaQQw4HLiKPhrSS9/KcoA/AcdQkNm+5CVwAoOmDPtyYfkPBgfo2hLZnZQqR1bwkz/PrNoOm+gqA==
2792+
"@sentry/core@8.30.0":
2793+
version "8.30.0"
2794+
resolved "https://registry.npmjs.org/@sentry/core/-/core-8.30.0.tgz#f929e42e9a537bfa3eb6024082714e9ab98d822b"
2795+
integrity sha512-CJ/FuWLw0QEKGKXGL/nm9eaOdajEcmPekLuHAuOCxID7N07R9l9laz3vFbAkUZ97GGDv3sYrJZgywfY3Moropg==
27962796
dependencies:
2797-
"@sentry/types" "8.28.0"
2798-
"@sentry/utils" "8.28.0"
2797+
"@sentry/types" "8.30.0"
2798+
"@sentry/utils" "8.30.0"
27992799

28002800
28012801
version "7.50.0"
@@ -2826,10 +2826,10 @@
28262826
resolved "https://registry.npmjs.org/@sentry/types/-/types-7.50.0.tgz#52a035cad83a80ca26fa53c09eb1241250c3df3e"
28272827
integrity sha512-Zo9vyI98QNeYT0K0y57Rb4JRWDaPEgmp+QkQ4CRQZFUTWetO5fvPZ4Gb/R7TW16LajuHZlbJBHmvmNj2pkL2kw==
28282828

2829-
"@sentry/types@8.28.0":
2830-
version "8.28.0"
2831-
resolved "https://registry.npmjs.org/@sentry/types/-/types-8.28.0.tgz#a1cfc004d5714679cb3fed06c27298b0275d13b5"
2832-
integrity sha512-hOfqfd92/AzBrEdMgmmV1VfOXJbIfleFTnerRl0mg/+CcNgP/6+Fdonp354TD56ouWNF2WkOM6sEKSXMWp6SEQ==
2829+
"@sentry/types@8.30.0":
2830+
version "8.30.0"
2831+
resolved "https://registry.npmjs.org/@sentry/types/-/types-8.30.0.tgz#5f5011f5b16bafd30a039ca5e8c337e948c703fb"
2832+
integrity sha512-kgWW2BCjBmVlSQRG32GonHEVyeDbys74xf9mLPvynwHTgw3+NUlNAlEdu05xnb2ow4bCTHfbkS5G1zRgyv5k4Q==
28332833

28342834
28352835
version "7.50.0"
@@ -2839,12 +2839,12 @@
28392839
"@sentry/types" "7.50.0"
28402840
tslib "^1.9.3"
28412841

2842-
"@sentry/utils@8.28.0":
2843-
version "8.28.0"
2844-
resolved "https://registry.npmjs.org/@sentry/utils/-/utils-8.28.0.tgz#0feb46015033879b2a3cee4c0661386610025f47"
2845-
integrity sha512-smhk7PJpvDMQ2DB5p2qn9UeoUHdU41IgjMmS2xklZpa8tjzBTxDeWpGvrX2fuH67D9bAJuLC/XyZjJCHLoEW5g==
2842+
"@sentry/utils@8.30.0":
2843+
version "8.30.0"
2844+
resolved "https://registry.npmjs.org/@sentry/utils/-/utils-8.30.0.tgz#2343dd8593ea83890b3e0d792ed3fa257955a26b"
2845+
integrity sha512-wZxU2HWlzsnu8214Xy7S7cRIuD6h8Z5DnnkojJfX0i0NLooepZQk2824el1Q13AakLb7/S8CHSHXOMnCtoSduw==
28462846
dependencies:
2847-
"@sentry/types" "8.28.0"
2847+
"@sentry/types" "8.30.0"
28482848

28492849
"@sigstore/protobuf-specs@^0.1.0":
28502850
version "0.1.0"

0 commit comments

Comments
 (0)