-
Notifications
You must be signed in to change notification settings - Fork 14
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
fix: adding try/catch to initialize lsp server, added telemetry log events #320
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,17 @@ export class LspServer { | |
token: CancellationToken | ||
): Promise<PartialInitializeResult | ResponseError<InitializeError> | undefined> => { | ||
if (!params.initializationOptions?.aws) { | ||
if (this.lspConnection?.telemetry) { | ||
this.lspConnection.telemetry.logEvent({ | ||
name: 'Initialization error', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be good to also get approval for the structure from Toolkits. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Toolkit metric names and shapes are defined in a central place. If you look for the Given that the language servers will be used in more places than Toolkits, the language servers don't have to use the same convention or names as the Toolkit (in fact, the Toolkits may change their conventions at some point too). It is critical that the language servers use a convention, and have consistency in the data that is emitted through the telemetry logEvent calls. This is important because destinations have to ensure that the data is valid for where they emit telemetry to, and may need to perform post-processing transformations, which can only be done with an understanding of what the language server data will look like. I believe this is the first time that telemetry logEvent is being used, so this may take some time to produce a long-term design for. I'd like to see the following:
CC: @justinmk3 for additional thoughts on everything above Unless you have a convention that influences the name, I'd like to see this metric named something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Flare team was discussing OpenTelemetry, right? BTW: if possible, it will gain a lot if this project implements logging and telemetry as one system. There is no good reason for them to be separate. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
result: 'Failed', | ||
data: JSON.stringify(params.initializationOptions), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Here we should set the blob to a property, for example:
In case anyone asks, we should be deliberate about using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can If we are worried about mutable state during the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the callout, I shall update it based on the schema and would use deep copy here. Ack. |
||
errorData: { | ||
reason: 'Unknown initialization error with initialization options Error', | ||
dogusata marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
}) | ||
} | ||
|
||
this.logger.log( | ||
`Unknown initialization error\nwith initialization options: ${JSON.stringify(params.initializationOptions)}` | ||
) | ||
|
@@ -99,15 +110,20 @@ export class LspServer { | |
if (!this.initializeHandler) { | ||
return | ||
} | ||
const initializeResult = await asPromise(this.initializeHandler(params, token)) | ||
if (!(initializeResult instanceof ResponseError)) { | ||
this.initializeResult = initializeResult | ||
if (initializeResult?.serverInfo) { | ||
this.notificationRouter = new RouterByServerName(initializeResult.serverInfo.name, this.encoding) | ||
try { | ||
const initializeResult = await asPromise(this.initializeHandler(params, token)) | ||
if (!(initializeResult instanceof ResponseError)) { | ||
this.initializeResult = initializeResult | ||
if (initializeResult?.serverInfo) { | ||
this.notificationRouter = new RouterByServerName(initializeResult.serverInfo.name, this.encoding) | ||
} | ||
} | ||
} | ||
|
||
return initializeResult | ||
return initializeResult | ||
} catch (e) { | ||
this.logger.log(`Unknown initialization error\n${e}`) | ||
return new ResponseError(ErrorCodes.UnknownErrorCode, `Unknown initialization error\n${e}`) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably emit a separate metric here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ack. |
||
} | ||
} | ||
|
||
public tryExecuteCommand = async ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would
lspConnection
connection be undefined given it's expected in the constructor?lspConnection
is a must - nothing works without it.telemetry
is also expected to be defined. I do not think we should check everything forundefined
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, noted. I shall update.