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

plugin-ext-metrics extension for creating metrics from language plugins #6303

Merged
merged 1 commit into from
Nov 18, 2019

Conversation

JPinkney
Copy link
Contributor

@JPinkney JPinkney commented Oct 1, 2019

What it does

This PR introduces a new extension that creates metrics from language plugins. It creates metrics for two specific instances:

  • The time it takes for a language server request to be made for a specific request for a specific plugin
    E.g. vscode-yaml -> document symbols -> 13 ms

  • The percentage of success made for a specific request for a specific plugin
    E.g. vscode-yaml -> document symbols -> 99% successful

Spectrum discussion: https://spectrum.chat/theia/dev/current-state-of-metrics-in-theia~8efd05d2-a25b-4629-a1b1-1dd8a0ccef96
Related issues:
eclipse-che/che#14245

How to test

For testing I used a modified version of vscode-yaml that errors randomly in document symbols (just so you don't have to go out and find a plugin that errors on a language server request): you can download from https://github.com/JPinkney/Sample-vsix-repo/blob/master/0.5.2-beta7.vsix

You can actually use anything in this list though: https://github.com/eclipse-theia/theia/compare/master...JPinkney:plugin-ext-metrics?expand=1#diff-fb56011c00b860bfb7d05eedd825006eR33 it's just easier to verify that the percentage of successes is working when you know how to generate an error in the plugin.

Play around with the extension (autocompletion, document symbols, etc, etc) just so that we can get some data for metrics.

After you've played around with it go to ${yourUrl}/metrics and you should see the updated analytics for language_server_success_metrics and language_server_time_metrics.

Review checklist

Reminder for reviewers

@akosyakov akosyakov added metrics issues related to metrics and logging plug-in system issues related to the plug-in system labels Oct 2, 2019
@akosyakov
Copy link
Member

I see during the build:

The following dependency issues were detected in '@theia/plugin-ext-metrics':
 - error: Dependency 'vscode-jsonrpc' [4.0.0] was not hoisted to the root 'node_modules' folder. The same dependency already exists with version 4.1.0-next.3 at '/workspace/theia/node_modules/vscode-jsonrpc'.
 - error: Dependency 'vscode-languageserver-protocol' [3.14.1] was not hoisted to the root 'node_modules' folder. The same dependency already exists with version 3.15.0-next.8 at '/workspace/theia/node_modules/vscode-languageserver-protocol'.
 - error: Dependency 'vscode-languageserver-types' [3.14.0] was not hoisted to the root 'node_modules' folder. The same dependency already exists with version 3.15.0-next.4 at '/workspace/theia/node_modules/vscode-languageserver-types'.
⚠️  This is a reminder to fix the dependency issues.

Please use vscode-languageserver-types of the same version which is used in core, i.e. ^3.15.0-next. If i remember correctly it is required in order to package electron distr. cc @kittaakos

packages/plugin-ext-metrics/README.md Outdated Show resolved Hide resolved
packages/plugin-ext-metrics/README.md Outdated Show resolved Hide resolved
packages/plugin-ext-metrics/README.md Outdated Show resolved Hide resolved
Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

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

I've looked through code, someone has to test that metrics are actually collected.

@kittaakos
Copy link
Contributor

If i remember correctly it is required in order to package electron distr.

Correct. Here: https://spectrum.chat/theia/general/our-theia-electron-builder-app-no-longer-starts~f5cf09a0-6d88-448b-8818-24ad0ec2ee7c?m=MTU3MDcxNjg1OTMwNA==

@skabashnyuk
Copy link

@JPinkney can you please add an output example of metrics endpoint?

@JPinkney
Copy link
Contributor Author

@skabashnyuk example would be something like:

# HELP language_server_success_metrics Percentage of successful language requests # TYPE language_server_success_metrics gauge language_server_success_metrics{id="ms-vscode.go" method="textDocument/codeAction"} 100 language_server_success_metrics{id="ms-vscode.go" method="textDocument/codeLens"} 100 language_server_success_metrics{id="ms-vscode.go" method="textDocument/documentSymbol"} 100 language_server_success_metrics{id="ms-vscode.go" method="textDocument/completion"} 100 language_server_success_metrics{id="ms-vscode.go" method="textDocument/hover"} 100 language_server_success_metrics{id="ms-vscode.go" method="textDocument/formatting"} 88.88888888888889 language_server_success_metrics{id="ms-vscode.go" method="textDocument/signatureHelp"} 100

@skabashnyuk
Copy link

@JPinkney I see The percentage of success . What about The time it takes for a language server request?

@JPinkney
Copy link
Contributor Author

It's also there, it just wasn't pasted in. Heres the full output:

# HELP language_server_success_metrics Percentage of successful language requests # TYPE language_server_success_metrics gauge language_server_success_metrics{id="ms-vscode.go" method="textDocument/codeAction"} 100 language_server_success_metrics{id="ms-vscode.go" method="textDocument/codeLens"} 100 language_server_success_metrics{id="ms-vscode.go" method="textDocument/documentSymbol"} 100 language_server_success_metrics{id="ms-vscode.go" method="textDocument/completion"} 100 # HELP language_server_time_metrics Number of milliseconds it takes on average for a language server request # TYPE language_server_time_metrics gauge language_server_time_metrics{id="ms-vscode.go" method="textDocument/codeAction"} 24.225000001024455 language_server_time_metrics{id="ms-vscode.go" method="textDocument/codeLens"} 3.427499992540106 language_server_time_metrics{id="ms-vscode.go" method="textDocument/documentSymbol"} 15.69250000466127 language_server_time_metrics{id="ms-vscode.go" method="textDocument/completion"} 314.4249999895692

@skabashnyuk
Copy link

@JPinkney ok I see

# HELP language_server_success_metrics Percentage of successful language requests 
# TYPE language_server_success_metrics gauge 
language_server_success_metrics{id="ms-vscode.go" method="textDocument/codeAction"} 100 
language_server_success_metrics{id="ms-vscode.go" method="textDocument/codeLens"} 100 
language_server_success_metrics{id="ms-vscode.go" method="textDocument/documentSymbol"} 100
language_server_success_metrics{id="ms-vscode.go" method="textDocument/completion"} 100 
# HELP language_server_time_metrics Number of milliseconds it takes on average for a language server request 
# TYPE language_server_time_metrics gauge 
language_server_time_metrics{id="ms-vscode.go" method="textDocument/codeAction"} 24.225000001024455 
language_server_time_metrics{id="ms-vscode.go" method="textDocument/codeLens"} 3.427499992540106 
language_server_time_metrics{id="ms-vscode.go" method="textDocument/documentSymbol"} 15.69250000466127 
language_server_time_metrics{id="ms-vscode.go" method="textDocument/completion"} 314.4249999895692

I have such a question: instead of Percentage can we get raw counters? It would be much easier to calculate different derivative metrics from raw values on the Prometheus side.

@JPinkney
Copy link
Contributor Author

@skabashnyuk For sure I can make that switch. How should I output the metric? like:
language_server_success_metrics{id="ms-vscode.go" method="textDocument/codeAction" totalRequests="15"} 4

where 4 is the number of successful requests?

@skabashnyuk
Copy link

what about

language_server_success_metrics{id="ms-vscode.go" method="textDocument/codeAction" result="fail" } 4
language_server_success_metrics{id="ms-vscode.go" method="textDocument/codeAction" result="success" } 47629

@skabashnyuk
Copy link

where 4523423 is the sum of all time taken for requests?

yes

Would you also want the total requests as well? something like:
language_server_time_metrics{id="ms-vscode.go" method="textDocument/codeAction" totalRequests="4587"} 4523423

yes and no.

I want to see

language_server_time_sum{id="ms-vscode.go" method="textDocument/codeAction" resutl="success"} 3349590
language_server_time_count{id="ms-vscode.go" method="textDocument/codeAction" resutl="success"} 34345
language_server_time_sum{id="ms-vscode.go" method="textDocument/codeAction" resutl="fail"} 533
language_server_time_count{id="ms-vscode.go" method="textDocument/codeAction" resutl="fail"} 23

@tsmaeder
Copy link
Contributor

@skabashnyuk so what you want are really not metrics, but raw events, right? If we go down that way, I would suggest we do it in a way that keeps computation of the metrics local to the front end: that would mean that the collection of events would be general, whereas the computation of metrics would be a che-specific Theia extension.

@skabashnyuk
Copy link

@skabashnyuk so what you want are really not metrics, but raw events, right?

Sort of. It's much easier to get different reports from raw data.

@JPinkney
Copy link
Contributor Author

JPinkney commented Nov 5, 2019

@skabashnyuk Regarding:

language_server_time_count{id="ms-vscode.go" method="textDocument/codeAction" result="success"} 34345

is 34345 just the number of times that we've measured time for a succesful request?

Would that be any different from this metric?

language_server_success_metrics{id="ms-vscode.go" method="textDocument/codeAction" result="success" } 47629

@skabashnyuk
Copy link

skabashnyuk commented Nov 5, 2019

@skabashnyuk Regarding:

language_server_time_count{id="ms-vscode.go" method="textDocument/codeAction" result="success"} 34345

is 34345 just the number of times that we've measured time for a succesful request?

yes

Would that be any different from this metric?

language_server_success_metrics{id="ms-vscode.go" method="textDocument/codeAction" result="success" } 47629

I'm not sure metrics language_server_success_metrics with a result attribute is a good thing to do.

@tsmaeder tsmaeder mentioned this pull request Nov 6, 2019
25 tasks
Signed-off-by: Josh Pinkney <joshpinkney@gmail.com>
@JPinkney
Copy link
Contributor Author

JPinkney commented Nov 7, 2019

@skabashnyuk

I've updated the full metrics to be:

# HELP language_server_time_count Number of language server requests 
# TYPE language_server_time_count gauge
language_server_time_count{id="redhat.vscode-yaml" method="textDocument/documentSymbol" result="success"} 211
language_server_time_count{id="redhat.vscode-yaml" method="textDocument/documentSymbol" result="fail"} 0
language_server_time_count{id="redhat.vscode-yaml" method="textDocument/completion" result="success"} 100
language_server_time_count{id="redhat.vscode-yaml" method="textDocument/completion" result="fail"} 0

# HELP language_server_time_sum Sum of time in milliseconds that language server requests take 
# TYPE language_server_time_sum gauge
language_server_time_sum{id="redhat.vscode-yaml" method="textDocument/documentSymbol" result="success"} 7032.7149999943795
language_server_time_sum{id="redhat.vscode-yaml" method="textDocument/documentSymbol" result="failure"} 0
language_server_time_sum{id="redhat.vscode-yaml" method="textDocument/completion" result="success"} 2778.539999999688
language_server_time_sum{id="redhat.vscode-yaml" method="textDocument/completion" result="failure"} 0

Do those capture all the metrics needed?

@skabashnyuk
Copy link

Do those capture all the metrics needed?

I don't know, but they look fantastic.

@skabashnyuk
Copy link

Any plans for this pr do be merged?

@JPinkney
Copy link
Contributor Author

@skabashnyuk Its just waiting for a +1

@akosyakov @benoitf Can you take a quick look again

@akosyakov
Copy link
Member

Some files don't match types or don't have Plugin prefix, but it is minor. Generally I'm fine with changes.

@skabashnyuk
Copy link

@JPinkney can you take a look at @akosyakov's comment #6303 (comment) ?

Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

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

@skabashnyuk it can be fixed as follow-ups, I forgot to select approve last time 🙈

@tsmaeder
Copy link
Contributor

@akosyakov, @skabashnyuk @JPinkney is away this week. Should I press "rebase and merge" before it needs another rebase?

@akosyakov
Copy link
Member

akosyakov commented Nov 18, 2019

Should I press "rebase and merge" before it needs another rebase?

+1 It looks like it can be auto-rebased. The build failure on Mac seems to be accidental.

@tsmaeder tsmaeder merged commit 7a1aa74 into eclipse-theia:master Nov 18, 2019
@tolusha
Copy link
Contributor

tolusha commented Nov 18, 2019

PR was outdated and build failed

@akosyakov
Copy link
Member

@tolusha Oh, it broke the master:

 yarn run clean && yarn run build
$ theiaext clean
$ theiaext build
[compile] src/browser/plugin-metrics-frontend-module.ts(31,34): error TS2345: Argument of type 'typeof LanguagesMainPluginMetrics' is not assignable to parameter of type 'new (...args: any[]) => LanguagesMainImpl'.
[compile]   Type 'LanguagesMainPluginMetrics' is not assignable to type 'LanguagesMainImpl'.
[compile]     Types of property 'provideCodeActions' are incompatible.
[compile]       Type '(handle: number, model: ITextModel, rangeOrSelection: Range, context: CodeActionContext, token: CancellationToken) => Promise<CodeActionList | Promise<CodeActionList>>' is not assignable to type '(handle: number, model: ITextModel, rangeOrSelection: Range, context: CodeActionContext, token: CancellationToken) => Promise<CodeActionList>'.
[compile]         Type 'Promise<CodeActionList | Promise<CodeActionList>>' is not assignable to type 'Promise<CodeActionList>'.
[compile] src/browser/plugin-metrics-languages-main.ts(194,21): error TS2416: Property 'provideCodeActions' in type 'LanguagesMainPluginMetrics' is not assignable to the same property in base type 'LanguagesMainImpl'.
[compile]   Type '(handle: number, model: ITextModel, rangeOrSelection: Range, context: CodeActionContext, token: CancellationToken) => Promise<CodeActionList | Promise<CodeActionList>>' is not assignable to type '(handle: number, model: ITextModel, rangeOrSelection: Range, context: CodeActionContext, token: CancellationToken) => Promise<CodeActionList>'.
[compile]     Type 'Promise<CodeActionList | Promise<CodeActionList>>' is not assignable to type 'Promise<CodeActionList>'.
[compile]       Type 'CodeActionList | Promise<CodeActionList>' is not assignable to type 'CodeActionList'.
[compile]         Type 'Promise<CodeActionList>' is missing the following properties from type 'CodeActionList': actions, dispose
[compile] theiaext compile exited with code 2
[lint] theiaext lint exited with code 0
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Could you have a look at it or revert please?

@tsmaeder
Copy link
Contributor

Looks like the type of LanguagesMainImpl changed 3 days ago to

Promise<monaco.languages.CodeActionList | monaco.languages.CodeActionList>

Maybe @svenefftinge knows the correct fix to apply then?

@tsmaeder
Copy link
Contributor

tsmaeder commented Nov 18, 2019

Changing the return type in LanguagesMainPluginMetrics to Promise<monaco.languages.CodeActionList> fixes the build

@tsmaeder
Copy link
Contributor

@akosyakov how to best provide a fix for this?

@tolusha
Copy link
Contributor

tolusha commented Nov 18, 2019

I will create a PR. The fix seems simple

@tolusha
Copy link
Contributor

tolusha commented Nov 18, 2019

#6571


private _extensionIDAnalytics: MetricsMap;

private NODE_BASED_REGEX = /(?<=Request)(.*?)(?=failed)/;
Copy link
Member

@paul-marechal paul-marechal Nov 19, 2019

Choose a reason for hiding this comment

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

Why not /Request(.*)failed/?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
metrics issues related to metrics and logging plug-in system issues related to the plug-in system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants