forked from sorbet/sorbet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests for foundational language server metrics (sorbet#2706)
* Add tests for counters. * Assertions for last_diagnostic_latency. * If the first typecheck for edit 2 gets canceled by edit 3, the typecheck for edit 2+3 should use 2's timer. * Basic histogram test * Explicit null check. * Canonicalize counters.
- Loading branch information
1 parent
3290b12
commit 5add669
Showing
17 changed files
with
369 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "main/lsp/requests/get_counters.h" | ||
#include "main/lsp/LSPOutput.h" | ||
#include "main/lsp/lsp.h" | ||
|
||
using namespace std; | ||
|
||
namespace sorbet::realmain::lsp { | ||
GetCountersTask::GetCountersTask(const LSPConfiguration &config, MessageId id) | ||
: LSPTask(config, LSPMethod::GETCOUNTERS), id(move(id)) {} | ||
|
||
LSPTask::Phase GetCountersTask::finalPhase() const { | ||
return LSPTask::Phase::INDEX; | ||
} | ||
|
||
bool GetCountersTask::canPreempt(const LSPIndexer &) const { | ||
return false; | ||
} | ||
|
||
// Has to run on indexing thread, which is what coordinates all threads and collects all of the metrics. | ||
void GetCountersTask::index(LSPIndexer &indexer) { | ||
auto response = make_unique<ResponseMessage>("2.0", id, LSPMethod::GETCOUNTERS); | ||
unique_ptr<SorbetCounters> counters = make_unique<SorbetCounters>(); | ||
counters->counters = getAndClearThreadCounters(); | ||
response->result = move(counters); | ||
config.output->write(move(response)); | ||
} | ||
|
||
void GetCountersTask::run(LSPTypecheckerDelegate &typechecker) {} | ||
|
||
} // namespace sorbet::realmain::lsp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef RUBY_TYPER_LSP_REQUESTS_GET_COUNTERS_H | ||
#define RUBY_TYPER_LSP_REQUESTS_GET_COUNTERS_H | ||
|
||
#include "main/lsp/LSPTask.h" | ||
|
||
namespace sorbet::realmain::lsp { | ||
class GetCountersTask final : public LSPTask { | ||
MessageId id; | ||
|
||
public: | ||
GetCountersTask(const LSPConfiguration &config, MessageId id); | ||
|
||
bool canPreempt(const LSPIndexer &) const override; | ||
|
||
LSPTask::Phase finalPhase() const override; | ||
|
||
void index(LSPIndexer &indexer) override; | ||
|
||
void run(LSPTypecheckerDelegate &typechecker) override; | ||
}; | ||
} // namespace sorbet::realmain::lsp | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.