Skip to content
This repository was archived by the owner on Oct 2, 2021. It is now read-only.

Introduces a telemetry collector. #314

Merged
merged 1 commit into from
Mar 23, 2018
Merged

Conversation

changsi-an
Copy link
Contributor

@changsi-an changsi-an commented Mar 22, 2018

so a request handling logic can append additional properties reported in the request telemetry.

Currently there is no easy way for a request handler to report additional properties other than the ones universally added, as success state, time spent etc.

Returning additional fields in the return value might compromise the current semantic of the return value of each request. So I introduced an additional parameter to receive the additional telemetry properties.

This collector can also be used in the handlers for the notifications as needed.

@@ -179,7 +181,7 @@ export interface IDebugAdapter {
shutdown(): void;

initialize(args: DebugProtocol.InitializeRequestArguments, requestSeq?: number): PromiseOrNot<DebugProtocol.Capabilities>;
launch(args: ILaunchRequestArgs, requestSeq?: number): PromiseOrNot<void>;
launch(args: ILaunchRequestArgs, telemetryPropertyCollector: ITelemetryPropertyCollector, requestSeq?: number): PromiseOrNot<void>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

After I get some consensus about this design. I can modify all the request methods as well.

@@ -124,8 +124,9 @@ export class ChromeDebugSession extends LoggingDebugSession implements IObservab
* Overload dispatchRequest to the debug adapters' Promise-based methods instead of DebugSession's callback-based methods
*/
protected dispatchRequest(request: DebugProtocol.Request): void {
const telemetryPropertyCollector = new TelemetryPropertyCollector();
Copy link
Contributor

Choose a reason for hiding this comment

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

What are the advantages of creating the TelemetryPropertyCollector here instead of receiving it from the reportTelemetry method?

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 think they are equivalent.

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think would make the code simpler and easier to maintain?
A. Keeping as much of the telemetry implementation inside the reportTelemetry method, and having reportTelemetry create the telemetryPropertyCollector so that the business methods don't need to deal with details of the telemetry implementation?
B. Spreading the telemetry implementation between reportTelemetry and the business methods, and having each business method that uses telemetry having to create it's own telemetryPropertyCollector?

…end additional properties reported in the request telemetry.

# Conflicts:
#	src/chrome/chromeDebugAdapter.ts
#	src/chrome/chromeDebugSession.ts
@roblourens
Copy link
Member

What extra properties will this be used for?

@changsi-an
Copy link
Contributor Author

@roblourens This will be highly re-used for some notification handlers. Say when a breakpoint is hit, we need to know whether is a real or pesudo(break-on-load) breakpoint, whether it's for JS or TS. Currently our telemetry facility can only measure a processing time, successfulness etc. It does not support adding customized properties per the business of each handler.

@roblourens
Copy link
Member

I don't understand, since this is hooked up for client requests, how would you use it for notifications like onPaused?

I think it makes sense for client requests but for cases where ChromeDebugAdapter fires the telemetry events itself, it could just pass in any extra properties to reportEvent that it needs to, right?

@changsi-an
Copy link
Contributor Author

changsi-an commented Mar 23, 2018

You are right. We haven't implemented that for notifications. This PR is just an example showing how a TelemetryCollector can be used.

For OnPaused. since we already has a wrapper to measure processing time in a universal way like this:

            this.runAndMeasureProcessingTime('target/notification/onPaused', () => {
                return this.onPaused(params);
            });

(The method will be refactored in a similar fashion)

The runAndMeasureProcessingTime method will create a telemetry entry to describe what/how the onPause handler does. It is true that we can have onPause call another telemetry.reportEvent(), but that would become a new telemetry entry. We want to merge everything into the one emitted by runAndMeasureProcessingTime, so we don't have to join/correlate telemetry entries down the pipeline.

@changsi-an changsi-an merged commit bfc8fb4 into microsoft:master Mar 23, 2018
@roblourens roblourens added this to the March 2018 milestone Apr 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants