question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve extensions telemetry API

See original GitHub issue

In todays API there are some symbols that help extensions with telemetry, e.g machineId, sessionId, and most importantly isTelemetryEnabled. These are used by our telemetry module and by others.

The existing APIs help you to get the job done but offer little quality of life, aren’t always easy to use, and lack hooks that we would like for transparency and cleansing. Our goal is to make it easy for extensions to do the right thing and to be transparent to our user what’s happening.

Below is an alternative API that is around a TelemetryLogger and TelemetryAppender. The appender is what does the actual data collecting but it should be used through a logger. With that “indirection” we can do many nice things:

  • we can do extra PII cleansing for extensions, e.g remove everything that looks like path-name, URI, user-name etc
  • we can enable/disable telemetry per extension
  • we echo everything that is logged to the telemetry output channel
  • we check enablements: logger.logUsage() -> setting say NO ⛔ -> we don’t call appender
  • we can call logError on provider-errors and unhandled extension errors (superseeding https://github.com/microsoft/vscode/issues/45264)
declare module 'vscode' {

	export interface TelemetryLogger {
		readonly onDidChangeEnableStates: Event<TelemetryLogger>;
		readonly isUsageEnabled: boolean;
		readonly isErrorsEnabled: boolean;

                // calls TelemetryAppender#logUsage iff usage telemetry is enabled, echos data to output channel
                // called by extension
		logUsage(...args: any[]): void;

                // calls TelemetryAppender#logError iff error telemetry is enabled, echos data to output channel
                // called by extension
                // ALSO called by VS Code when the owning extension throws, e.g provider or command errors
		logError(err: Error): void;
	}

	export interface TelemetryAppender {
		logUsage(...args: any[]): void;
		logError(err: Error): void;
	}

	export namespace env {
		// BYOTA
		export function createTelemetryLogger(appender: TelemetryAppender): TelemetryLogger;
	}
}

The vscode-extension-telemetry-module would become an instance of a telemetry appender.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:4
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
bwateratmsftcommented, Nov 18, 2022

I really like this idea, especially unifying all of the PII masking into one better-maintained place. One thing I wanted to bring up, though–there will always be examples of PII that the default filters can’t catch. These could be domain-specific things like resource names, or more generic things like an obscure string ID format that isn’t well known–perhaps an ID that’s unique to a particular country or region.

As such, would it be possible to include a means of adding custom PII filtering logic? e.g. a method or list of methods to pass things through that input a string and output an amended string (or the same string if no changes are needed)?

1reaction
isidorncommented, Sep 23, 2022

Once we get this API in a good proposed state let me know and I can reach out to all extension authors that report telemetry so they slowly start transitioning to this API.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS Lambda announces Telemetry API, further enriching ...
AWS Lambda now enables Lambda Extensions to collect enhanced monitoring and observability data about your function execution through the new ...
Read more >
Telemetry extension authors guide - Visual Studio Code
Telemetry extension authors guide. Visual Studio Code collects usage data and sends it to Microsoft to help improve our products and services.
Read more >
AWS Lambda Extensions Telemetry API integration
Send your logs, events, metrics, and traces by adding the extension as the layer, and get insights from your data instantly on the...
Read more >
AWS Lambda Telemetry API Provides Enhanced Observability ...
The new API allows extensions to subscribe to platform telemetry, function logs, and extension logs. Platform telemetry includes logs, metrics, ...
Read more >
Simpler Observability with Lambda Telemetry API
The extension is still in development and there is certainly room for improvement. However, it's still a good proof-of-concept work that shows ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found