Skip to content

feat(rust/gui-client): add sentry.io error reporting#6782

Merged
ReactorScram merged 51 commits intomainfrom
feat/sentry
Sep 27, 2024
Merged

feat(rust/gui-client): add sentry.io error reporting#6782
ReactorScram merged 51 commits intomainfrom
feat/sentry

Conversation

@ReactorScram
Copy link
Contributor

@ReactorScram ReactorScram commented Sep 19, 2024

Refs #6138

Sentry is always enabled for now. In the near future we'll make it opt-out per device and opt-in per org (see #6138 for details)

  • Replaces the crash_handling module
  • Catches panics in GUI process, tunnel daemon, and Headless Client
  • Added a couple "breadcrumbs" to play with that feature
  • User ID is not set yet
  • Environment is set to the API URL, e.g. wss://api.firezone.dev
  • Reports panics from the connlib async task
  • Release should be automatically pulled from the Cargo version which we automatically set in the version Makefile

Example screenshot of sentry.io with a caught panic:

image

@ReactorScram ReactorScram self-assigned this Sep 19, 2024
@vercel
Copy link

vercel bot commented Sep 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 27, 2024 4:22pm

github-merge-queue bot pushed a commit that referenced this pull request Sep 26, 2024
Also add `firezone-logging` which slipped through

This is factored out from #6782
Copy link
Member

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

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

LGTM

Just one ask around instrumenting caught panics in Session.

Comment on lines +219 to +223
telemetry::add_breadcrumb(telemetry::Breadcrumb {
ty: "fail_on_purpose".into(),
message: Some("Will crash / error / panic on purpose to test error handling.".into()),
..Default::default()
});
Copy link
Member

Choose a reason for hiding this comment

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

I guess we are not leaving this in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to, it's handy for testing error handling. The flags for it were already present since they were left in after testing the existing crash handling and logging.

.make_tun()
.map_err(|e| Error::TunnelDevice(e.to_string()))?;
connlib.set_tun(Box::new(tun));
tun_span.finish();
Copy link
Member

Choose a reason for hiding this comment

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

I think this might also be somewhat misleading because all we do as part of set_tun is writing it to a channel.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't make_tun run some of the platform-specific code like parts of WinTun?

Copy link
Member

Choose a reason for hiding this comment

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

Ah yeah, I didn't see that it is covering the make_tun part too. It would be nice if we could just get this data from tracing without having to depend on our telemetry module everywhere.

github-merge-queue bot pushed a commit that referenced this pull request Sep 27, 2024
Extracted from #6782 

This moves more of `main` inside the async block, which makes it easier
to set up telemetry in the future.

We also log errors for the DNS notifier, which was overlooked before.
github-merge-queue bot pushed a commit that referenced this pull request Sep 27, 2024
#6826)

This makes it easier to add more fields to the settings without writing
them twice

This is factored out from #6782
github-merge-queue bot pushed a commit that referenced this pull request Sep 27, 2024
This makes it easy to add more fields to `Controller` without making
them all public.

This is factored out from #6782

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tool: dump_syms,minidump-stackwalk
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't need this since Sentry reads crash dumps for us

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Something in here was causing a bug in sentry, so I deleted the file and let Cargo recreate it.

firezone-logging = { workspace = true }
futures = { version = "0.3", default-features = false }
hex = "0.4.3"
minidumper = "0.8.3"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't need any of our old crash handling stuff

tokio = { workspace = true, features = ["signal", "time", "macros", "rt", "rt-multi-thread"] }
tokio-util = { version = "0.7.11", features = ["codec"] }
tracing = { workspace = true }
tracing-panic = "0.1.2"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can't use this since there can only be one panic hook. (I guess we could wrap both of them but I didn't try that)

Comment on lines 136 to 147
sentry::add_breadcrumb(Breadcrumb {
ty: "logging_start".into(),
category: None,
data: {
let mut map = BTreeMap::default();
map.insert("directives".into(), directives.into());
map.insert("git_version".into(), git_version.into());
map.insert("system_uptime_seconds".into(), system_uptime_seconds.into());
map
},
..Default::default()
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This breadcrumb shows up in Sentry's web UI and I like the idea of breadcrumbs a lot

callbacks,
};
let _guard = rt.enter(); // Constructing `PhoenixChannel` requires a runtime context.
rt.block_on(async {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This refactor was extracted to #6835

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made firezone-telemetry its own crate even though the code is small, because Gateways and Relays may want it in the future.

Comment on lines +219 to +223
telemetry::add_breadcrumb(telemetry::Breadcrumb {
ty: "fail_on_purpose".into(),
message: Some("Will crash / error / panic on purpose to test error handling.".into()),
..Default::default()
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to, it's handy for testing error handling. The flags for it were already present since they were left in after testing the existing crash handling and logging.

.make_tun()
.map_err(|e| Error::TunnelDevice(e.to_string()))?;
connlib.set_tun(Box::new(tun));
tun_span.finish();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't make_tun run some of the platform-specific code like parts of WinTun?

@ReactorScram ReactorScram added this pull request to the merge queue Sep 27, 2024
Merged via the queue into main with commit 05a2b28 Sep 27, 2024
@ReactorScram ReactorScram deleted the feat/sentry branch September 27, 2024 16:47
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.

3 participants