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

Improve properties capture for the sendErrorData method #191

Merged
merged 1 commit into from
Nov 22, 2023

Conversation

ilia-db
Copy link
Contributor

@ilia-db ilia-db commented Nov 13, 2023

Hey, I'm using this package and noticed that all unhandled errors reported by it don't have any common properties (like extension or vscode versions).

It seems like sender.sendErrorData doesn't always receive data objects with the properties field, in which case common properties that the vscode usually supplies to all events or errors will not be sent.

In the case of unhandled errors vscode itself calls sender.sendErrorData method providing the data object without properties field.

Internally (and publicly through TelemetryLogger extension API) vscode seem to always treat data argument as Record<string, any> type. It acknowledges that properties might exist while mixing in common props, but it doesn't create such data objects itself.

This PR accounts for that and fallbacks to using full data object if the properties field doesn't exist, fixing the reporting of unhandled errors.

`sender.sendErrorData` doesn't always receive data object with a properties
field. In the case of unhandled errors vscode itself calls this with all the
properties being in the top level of the `data` argument. This PR accounts for
that and fallbacks to using full data object if a properties field doesn't exist
@ilia-db
Copy link
Contributor Author

ilia-db commented Nov 15, 2023

@microsoft-github-policy-service agree company="Databricks"

@lramos15
Copy link
Member

@Joouis this seems to be solving the same problem as microsoft/vscode#193208 but one in the module in one in core.

I was curious if either of you had preferences as to where the solution lived. I quite like this one as I feel like it's pretty clean. Downside being that sendErrorData now has a different call signature then the rest

@ilia-db
Copy link
Contributor Author

ilia-db commented Nov 15, 2023

I might be mistaken, but to me it looks like the linked PR in the VSCode core is not backwards compatible - it only mixes common properties to the data.properties object. It's ok for this telemetry package, but there might be others who would expect the common properties to be mixed into the the data object itself (which is the current behaviour when the properties field doesn't exist, and it's also mentioned in the VSCode API docs for additionalCommonProperties option).

Downside being that sendErrorData now has a different call signature then the rest

True, but sendErrorData isn't publicly exposed by this package, and public sendTelemetryErrorEvent method is the same.

@lramos15 lramos15 added this to the November 2023 milestone Nov 15, 2023
@lramos15 lramos15 merged commit 60e0864 into microsoft:main Nov 22, 2023
4 checks passed
@Joouis
Copy link

Joouis commented Jan 19, 2024

@lramos15 This can work as I thought of it at beginning, and I fully understand the compatibility concern. I don't prefer the idea because this is more like clean shit by downstream comsumers, letting all telemetry packages adapt to this different data structure design?

I would say sendErrorData(exception: Error, data?: SenderData | Record<string, any>) is a compromise, and could be difficult to understand for the future maintainers.

Just my 2 cents, still respect @ilia-db 's and your contribution.

@lramos15
Copy link
Member

@Joouis I created some new test cases just to validate the VS Code side is working as expected and I believe it is.

The issue here is that the telemetry API doesn't know what special format your sender needs because it supports more than just app insights. Some might want all data at top level and others might want it split into properties and measurements. We try not to manipulate the data structure too much, which is why I believe the manipulation should be done by the library implementer as they know what the end ingestion result needs to be. Maybe the mistake in the API design was trying to manipulate the data structure at all as now we do have some app insights specific knowledge and not instead returning common properties separate for the sender to mixin.

Anyways my stance is that this is the better and more consistent approach that doesn't change the expected behavior of the API.

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.

None yet

4 participants