Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sentry support #9598

Merged
merged 13 commits into from
Apr 21, 2024
Merged

Add sentry support #9598

merged 13 commits into from
Apr 21, 2024

Conversation

Nikola-3
Copy link
Contributor

↪️ Pull Request

Canary builds now release and parcel rust code can be conditionally compiled with support for sentry in rust. This is useful for providing error logging in rust at runtime.

💻 Examples

🚨 Test instructions

✔️ PR Todo

  • Added/updated unit tests for this change
  • Filled out test instructions (In case there aren't any unit tests)
  • Included links to related issues/PRs

@@ -15,6 +15,7 @@ jobs:
uses: ./.github/workflows/release.yml
secrets: inherit
with:
profile: canary
Copy link
Contributor

@MonicaOlejniczak MonicaOlejniczak Mar 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be enabled for dev releases as well? Regardless, it feels like the option should be more generic (i.e. a profiling build) and use the same release command, but pass in a env variable / cli option that you read

@@ -26,7 +28,8 @@ async function build() {
console.log(`Building ${pkg}...`);
await new Promise((resolve, reject) => {
let args = [
(wasm ? 'wasm:' : '') + (release ? 'build-release' : 'build'),
(wasm ? 'wasm:' : '') +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we split this out into an if statement? Nested ternaries are hard to read

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha this is on me. Nik said the same thing - I agreed but was feeling lazy.

} catch (e) {
// Fallthrough
// eslint-disable-next-line no-console
console.warn(e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine to continue startup if sentry fails, but we should log a bit more effectively here. logger is available and we should provide some context to the error

};

let sentry_tags = if let Ok(sentry_tags_raw) = std::env::var("PARCEL_SENTRY_TAGS") {
println!("{}", sentry_tags_raw);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to log these?

return Ok(());
}

println!("Initialising Sentry in rust...");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally this would use log - https://crates.io/crates/log

[dependencies]
napi-derive = "2.12.5"
parcel-js-swc-core = { path = "../../packages/transformers/js/core" }
parcel-resolver = { path = "../../packages/utils/node-resolver-rs" }
dashmap = "5.4.0"
xxhash-rust = { version = "0.8.2", features = ["xxh3"] }
sentry = "0.32.2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

if you only use these dependencies for sentry you can make them optional then add them into the canary = [] array to only compile them when this feature is enabled.

you'd first make once_cell = { version = "1.19.0", optional = true } then add to the array; see "optional dependencies" https://doc.rust-lang.org/cargo/reference/features.html#optional-dependencies

Copy link
Contributor

@yamadapc yamadapc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm ; despite comments

@Nikola-3 Nikola-3 merged commit f9c978e into v2 Apr 21, 2024
16 of 17 checks passed
marcins added a commit that referenced this pull request Apr 22, 2024
@mischnic mischnic deleted the add-sentry-support branch April 23, 2024 08:35
marcins added a commit that referenced this pull request Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants