Skip to content

Conversation

@eray-felek-sonarsource
Copy link
Contributor

No description provided.

@eray-felek-sonarsource eray-felek-sonarsource force-pushed the feature/ef/SLVS-2764-start-collecting-reqest-level-exceptions branch 5 times, most recently from 6082677 to 27be1b5 Compare January 6, 2026 12:37
@eray-felek-sonarsource eray-felek-sonarsource changed the title SLVS-2764 tart collecting reqest level exceptions SLVS-2764 Start collecting reqest level exceptions Jan 6, 2026
@eray-felek-sonarsource eray-felek-sonarsource changed the title SLVS-2764 Start collecting reqest level exceptions SLVS-2764 Start collecting request level exceptions Jan 6, 2026
@eray-felek-sonarsource eray-felek-sonarsource force-pushed the feature/ef/SLVS-2764-start-collecting-reqest-level-exceptions branch from 56a0b3a to 28c247f Compare January 6, 2026 15:15
{
logger.WriteLine(SLCoreStrings.SLCoreHandler_StartingInstance);
await currentInstanceHandle.InitializeAsync();
monitoringService.Init();

Choose a reason for hiding this comment

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

This will re-initialize on every SLCore restart (if it crashed, for example). Do we still want that or do we only want to initialize once?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Telemetry is re-initialized every time SLCORE crashes, I think it it a good practice the keep the same behavior also we rely on telemetry to decide if we initialize monitoring


protected override JsonRpcError.ErrorDetail CreateErrorDetails(JsonRpcRequest request, Exception exception)
{
monitoringService.ReportException(exception, $"JsonRpcWrapper.CreateErrorDetails:{request.Method ?? "unknown"}");

Choose a reason for hiding this comment

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

I need to check if there's anything useful in those exceptions. Unfortunately, from the top of my head, it always says "Internal error" and not much more

Copy link
Contributor Author

@eray-felek-sonarsource eray-felek-sonarsource Jan 7, 2026

Choose a reason for hiding this comment

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

This is one example: https://sonar-x0.sentry.io/issues/7167581220/?project=4510622904877056&query=is%3Aunresolved&referrer=issue-stream
We at least get the request causing the exception. We discussed and did the same capturing for IntelliJ, I think it's a good start.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not familiar with the .NET implementation, but there is normally a way to get the SLCORE stack trace that led to the 'internal error'. There is probably a certain type of exception, in which you can access those details, by running in debug mode you might be able to find that.
The 2nd thing is that reporting all exceptions from this method might be too much. I think we could try to focus only on exceptions that are uncaught by SLCORE and translate to 'internal errors'.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They have InternalError = -32603, defined, I guess we could only report these as a start then

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also added error data information

@eray-felek-sonarsource eray-felek-sonarsource force-pushed the feature/ef/SLVS-2764-start-collecting-reqest-level-exceptions branch from 28c247f to 89a67a7 Compare January 6, 2026 16:12
@eray-felek-sonarsource eray-felek-sonarsource force-pushed the feature/ef/SLVS-2764-start-collecting-reqest-level-exceptions branch from 89a67a7 to 65b9d6c Compare January 6, 2026 16:28
Copy link
Contributor

Choose a reason for hiding this comment

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

A few more comments + please test this on an old VS on the VM that we have

@eray-felek-sonarsource eray-felek-sonarsource force-pushed the feature/ef/SLVS-2764-start-collecting-reqest-level-exceptions branch from 868e45c to c48e777 Compare January 7, 2026 10:52
@eray-felek-sonarsource eray-felek-sonarsource changed the base branch from master to feature/ef/SLVS-enable-sentry January 7, 2026 10:53
Copy link
Contributor

Choose a reason for hiding this comment

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

Some things to fix with synchronization, otherwise looks good. Please only merge once those are fixed

{
try
{
sentrySdk.Init(options =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you find a way to turn off automatic collection of uncaught exceptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have a separate ticket for this

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 will start working on it after I merge this to feature branch. We decided to merge to feature since that ticket is implemented to avoid noise

{
try
{
sentrySdk.Init(options =>
Copy link
Contributor

Choose a reason for hiding this comment

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

We will probably need a way to uniquely identify users on the VS side too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed we can start implementing this after the unhandled exception task is finished

@eray-felek-sonarsource eray-felek-sonarsource force-pushed the feature/ef/SLVS-2764-start-collecting-reqest-level-exceptions branch from 66b1200 to 1b9cd37 Compare January 8, 2026 17:08

private static void TryAddCommonErrorData(Sentry.Scope scope, Exception exception)
{
if (exception is not LocalRpcException localRpcException)

Choose a reason for hiding this comment

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

Why only local exceptions? Do we rely on SLCore to capture other exceptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes we also have a exception catching mechanism on SLCORE, currently only for intellij, but I will also include other IDEs as well

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 9, 2026

SonarQube reviewer guide

Important

We are currently testing different models for AI Summary.
Please give us your feedback by filling this form.

Model A:

Summary: Adds Sentry SDK integration and monitoring service for error reporting with telemetry opt-in/out support.

Review Focus: The monitoring service initialization and error reporting flow, particularly the integration with JsonRpcWrapper's CreateErrorDetails method which reports internal/invalid parameter errors to Sentry. Verify exception handling doesn't interfere with normal operation and that telemetry status correctly controls Sentry activation.

Start review at: src/Integration/Telemetry/MonitoringService.cs. This is the core implementation that manages the Sentry lifecycle and exception reporting logic.

Model B:

Summary: Add Sentry error monitoring integration with telemetry-aware exception reporting to enable crash tracking based on user telemetry preferences.

Review Focus:

  • The MonitoringService initialization logic that queries telemetry status and conditionally enables Sentry
  • How exceptions are captured and enriched with RPC error context in JsonRpcWrapper
  • The integration points where monitoring is initialized/reinitialized based on telemetry opt-in/out
  • Thread safety with the state lock in MonitoringService and proper error swallowing for unsupported VS versions

Start review at: src/Integration/Telemetry/MonitoringService.cs. This is the core service managing Sentry initialization and exception reporting. Understanding its lifecycle (Init/Reinit/Close) and the telemetry-aware behavior is essential for validating the overall monitoring strategy.

Review in SonarQube
See all code changes, issues, and quality metrics in one place.

Quality Gate Passed Quality Gate passed

Issues
0 New issues
4 Accepted issues
0 Dependency risks

Measures
0 Security Hotspots
90.1% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud


if (errorDetail.Code == JsonRpcErrorCode.InternalError)
if (errorDetail.Code == JsonRpcErrorCode.InternalError ||
errorDetail.Code == JsonRpcErrorCode.InvalidParams)

Choose a reason for hiding this comment

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

well, this one was just an example, there are other types. there are also other exception types such as https://learn.microsoft.com/en-us/dotnet/api/streamjsonrpc.remoterpcexception?view=streamjsonrpc-2.21

It's a bit unclear to me why we only choose some of them and not all

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We would like to limit the exceptions to ones that we are interested to look first. InternalError was one thing we wanted to tackle first. It doesn't mean we will not look at the others, when we spend enough time and tackle these we might actually disable internal errors and tackle other exceptions. The purpose is to have focus during such investigations

@eray-felek-sonarsource eray-felek-sonarsource merged commit 03158cf into feature/ef/SLVS-enable-sentry Jan 9, 2026
5 checks passed
@eray-felek-sonarsource eray-felek-sonarsource deleted the feature/ef/SLVS-2764-start-collecting-reqest-level-exceptions branch January 9, 2026 10:11
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