Skip to content

Commit

Permalink
Update to latest SDK and re-add measurements
Browse files Browse the repository at this point in the history
  • Loading branch information
timfish committed Sep 12, 2024
1 parent 0620ad8 commit be19213
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 84 deletions.
6 changes: 3 additions & 3 deletions packages/bundler-plugin-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@
"@rollup/plugin-replace": "^4.0.0",
"@sentry-internal/eslint-config": "2.22.4",
"@sentry-internal/sentry-bundler-plugin-tsconfig": "2.22.4",
"@sentry/core": "8.28.0",
"@sentry/types": "8.28.0",
"@sentry/utils": "8.28.0",
"@sentry/core": "8.30.0",
"@sentry/types": "8.30.0",
"@sentry/utils": "8.30.0",
"@swc/core": "^1.2.205",
"@swc/jest": "^0.2.21",
"@types/jest": "^28.1.3",
Expand Down
132 changes: 66 additions & 66 deletions packages/bundler-plugin-core/src/debug-id-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SentryCli from "@sentry/cli";
import { dynamicSamplingContextToSentryBaggageHeader } from "@sentry/utils";
import { safeFlushTelemetry } from "./sentry/telemetry";
import { stripQueryAndHashFromPath } from "./utils";
import { spanToTraceHeader, startSpan } from "@sentry/core";
import { setMeasurement, spanToTraceHeader, startSpan } from "@sentry/core";
import { getDynamicSamplingContextFromSpan, Scope } from "@sentry/core";
import { Client } from "@sentry/types";

Expand Down Expand Up @@ -107,76 +107,76 @@ export function createDebugIdUploadFunction({
"Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option."
);
} else {
await startSpan({ name: "prepare-bundles", scope: sentryScope }, async () => {
// Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so
// instead we do it with a maximum of 16 concurrent workers
const preparationTasks = debugIdChunkFilePaths.map(
(chunkFilePath, chunkIndex) => async () => {
await prepareBundleForDebugIdUpload(
chunkFilePath,
tmpUploadFolder,
chunkIndex,
logger,
rewriteSourcesHook ?? defaultRewriteSourcesHook
);
}
);
const workers: Promise<void>[] = [];
const worker = async () => {
while (preparationTasks.length > 0) {
const task = preparationTasks.shift();
if (task) {
await task();
await startSpan(
{ name: "prepare-bundles", scope: sentryScope },
async (prepBundlesSpan) => {
// Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so
// instead we do it with a maximum of 16 concurrent workers
const preparationTasks = debugIdChunkFilePaths.map(
(chunkFilePath, chunkIndex) => async () => {
await prepareBundleForDebugIdUpload(
chunkFilePath,
tmpUploadFolder,
chunkIndex,
logger,
rewriteSourcesHook ?? defaultRewriteSourcesHook
);
}
);
const workers: Promise<void>[] = [];
const worker = async () => {
while (preparationTasks.length > 0) {
const task = preparationTasks.shift();
if (task) {
await task();
}
}
};
for (let workerIndex = 0; workerIndex < 16; workerIndex++) {
workers.push(worker());
}
};
for (let workerIndex = 0; workerIndex < 16; workerIndex++) {
workers.push(worker());
}

await Promise.all(workers);

// TODO: Bring back measurements
// There's no easy way to get the root span when not using a global client.

// const files = await fs.promises.readdir(tmpUploadFolder);
// const stats = files.map((file) => fs.promises.stat(path.join(tmpUploadFolder, file)));
// const uploadSize = (await Promise.all(stats)).reduce(
// (accumulator, { size }) => accumulator + size,
// 0
// );

// artifactBundleUploadTransaction.setMeasurement("files", files.length, "none");
// artifactBundleUploadTransaction.setMeasurement("upload_size", uploadSize, "byte");

await startSpan({ name: "upload", scope: sentryScope }, async (uploadSpan) => {
const cliInstance = new SentryCli(null, {
...sentryCliOptions,
headers: {
"sentry-trace": spanToTraceHeader(uploadSpan),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
baggage: dynamicSamplingContextToSentryBaggageHeader(
getDynamicSamplingContextFromSpan(uploadSpan)
)!,
...sentryCliOptions.headers,
},
});
await Promise.all(workers);

await cliInstance.releases.uploadSourceMaps(
releaseName ?? "undefined", // unfortunetly this needs a value for now but it will not matter since debug IDs overpower releases anyhow
{
include: [
{
paths: [tmpUploadFolder],
rewrite: false,
dist: dist,
},
],
useArtifactBundle: true,
}
const files = await fs.promises.readdir(tmpUploadFolder);
const stats = files.map((file) => fs.promises.stat(path.join(tmpUploadFolder, file)));
const uploadSize = (await Promise.all(stats)).reduce(
(accumulator, { size }) => accumulator + size,
0
);
});
});

setMeasurement("files", files.length, "none", prepBundlesSpan);
setMeasurement("upload_size", uploadSize, "byte", prepBundlesSpan);

await startSpan({ name: "upload", scope: sentryScope }, async (uploadSpan) => {
const cliInstance = new SentryCli(null, {
...sentryCliOptions,
headers: {
"sentry-trace": spanToTraceHeader(uploadSpan),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
baggage: dynamicSamplingContextToSentryBaggageHeader(
getDynamicSamplingContextFromSpan(uploadSpan)
)!,
...sentryCliOptions.headers,
},
});

await cliInstance.releases.uploadSourceMaps(
releaseName ?? "undefined", // unfortunetly this needs a value for now but it will not matter since debug IDs overpower releases anyhow
{
include: [
{
paths: [tmpUploadFolder],
rewrite: false,
dist: dist,
},
],
useArtifactBundle: true,
}
);
});
}
);

logger.info("Successfully uploaded source maps to Sentry");
}
Expand Down
30 changes: 15 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2789,13 +2789,13 @@
"@sentry/utils" "7.50.0"
tslib "^1.9.3"

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

"@sentry/integrations@7.50":
version "7.50.0"
Expand Down Expand Up @@ -2826,10 +2826,10 @@
resolved "https://registry.npmjs.org/@sentry/types/-/types-7.50.0.tgz#52a035cad83a80ca26fa53c09eb1241250c3df3e"
integrity sha512-Zo9vyI98QNeYT0K0y57Rb4JRWDaPEgmp+QkQ4CRQZFUTWetO5fvPZ4Gb/R7TW16LajuHZlbJBHmvmNj2pkL2kw==

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

"@sentry/utils@7.50.0":
version "7.50.0"
Expand All @@ -2839,12 +2839,12 @@
"@sentry/types" "7.50.0"
tslib "^1.9.3"

"@sentry/utils@8.28.0":
version "8.28.0"
resolved "https://registry.npmjs.org/@sentry/utils/-/utils-8.28.0.tgz#0feb46015033879b2a3cee4c0661386610025f47"
integrity sha512-smhk7PJpvDMQ2DB5p2qn9UeoUHdU41IgjMmS2xklZpa8tjzBTxDeWpGvrX2fuH67D9bAJuLC/XyZjJCHLoEW5g==
"@sentry/utils@8.30.0":
version "8.30.0"
resolved "https://registry.npmjs.org/@sentry/utils/-/utils-8.30.0.tgz#2343dd8593ea83890b3e0d792ed3fa257955a26b"
integrity sha512-wZxU2HWlzsnu8214Xy7S7cRIuD6h8Z5DnnkojJfX0i0NLooepZQk2824el1Q13AakLb7/S8CHSHXOMnCtoSduw==
dependencies:
"@sentry/types" "8.28.0"
"@sentry/types" "8.30.0"

"@sigstore/protobuf-specs@^0.1.0":
version "0.1.0"
Expand Down

0 comments on commit be19213

Please sign in to comment.