Repository navigation
adding Profiler #3976
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
Merged
Merged
adding Profiler #3976
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
0651b82
adding Profiler
andimarek cc1de5e
progress
andimarek eef80ec
track running time
andimarek 15cf642
tracking datafetcher result types
andimarek b7379ef
operation details
andimarek 275eaac
wip
andimarek cd002c0
dataloader tracking
andimarek b75a14d
Merge branch 'master' into profiler-2
andimarek 450a9fc
track dataloader dispatch
andimarek 5e9e713
track dataloader dispatch
andimarek b3515b7
Merge branch 'master' into profiler-2
andimarek 1800f77
Merge branch 'master' into profiler-2
andimarek 221b416
non nullable handling
andimarek 2ba4123
Merge branch 'master' into profiler-2
andimarek 4008c11
master merging
andimarek f7e31e6
wip
andimarek 3e29da4
Merge branch 'master' into profiler-2
andimarek 999bb2f
handle non null case
andimarek 5dde0e3
handle non null case
andimarek 4a47b9d
add Map specific summary methods
andimarek 0b7c15b
collect instrumentations
andimarek e6faa18
manual dispatch collected
andimarek 0ab88da
wip
andimarek 8bcdef8
wip
andimarek 62f1e84
improve naming
andimarek 76cdbc1
stabilize test
andimarek ca618b4
wip
andimarek 535eb8e
counting wrapped trivial data fetchers
andimarek a04f5cb
introspection fields
andimarek 572090e
data fetcher type statistics
andimarek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
track running time
- Loading branch information
commit eef80ecbb53eb9b2f78f463190d6109d33f40a20
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -4,6 +4,9 @@ import graphql.schema.DataFetcher | |
| import graphql.schema.DataFetchingEnvironment | ||
| import spock.lang.Specification | ||
|
|
||
| import java.time.Duration | ||
| import java.util.concurrent.CompletableFuture | ||
|
|
||
| class ProfilerTest extends Specification { | ||
|
|
||
|
|
||
|
|
@@ -74,4 +77,53 @@ class ProfilerTest extends Specification { | |
| profilerResult.getTotalPropertyDataFetcherInvocations() == 3 | ||
| } | ||
|
|
||
| def "records timing"() { | ||
| given: | ||
| def sdl = ''' | ||
| type Query { | ||
| foo: Foo | ||
| } | ||
| type Foo { | ||
| id: String | ||
| } | ||
| ''' | ||
| def schema = TestUtil.schema(sdl, [ | ||
| Query: [ | ||
| foo: { DataFetchingEnvironment dfe -> | ||
| return CompletableFuture.supplyAsync { | ||
| Thread.sleep(500) | ||
| "1" | ||
| } | ||
| } as DataFetcher], | ||
| Foo : [ | ||
| id: { DataFetchingEnvironment dfe -> | ||
| return CompletableFuture.supplyAsync { | ||
| Thread.sleep(500) | ||
| dfe.source | ||
| } | ||
| } as DataFetcher | ||
| ]]) | ||
| def graphql = GraphQL.newGraphQL(schema).build(); | ||
|
|
||
| ExecutionInput ei = ExecutionInput.newExecutionInput() | ||
| .query("{ foo { id } }") | ||
| .profileExecution(true) | ||
| .build() | ||
|
|
||
| when: | ||
| def result = graphql.execute(ei) | ||
| def profilerResult = ei.getGraphQLContext().get(ProfilerResult.PROFILER_CONTEXT_KEY) as ProfilerResult | ||
|
|
||
| then: | ||
| result.getData() == [foo: [id: "1"]] | ||
| // the total execution time must be more than 1 second, | ||
| // the engine should take less than 500ms | ||
| profilerResult.getTotalExecutionTime() > Duration.ofSeconds(1).toNanos() | ||
| profilerResult.getEngineTotalRunningTime() > Duration.ofMillis(1).toNanos() | ||
| profilerResult.getEngineTotalRunningTime() < Duration.ofMillis(500).toNanos() | ||
|
|
||
|
|
||
| } | ||
|
|
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extra line - intentional? |
||
| } | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for this PR, but in the future, with more Profiler features you might want to introduce options to toggle sets of tracking on and off
e.g. toggle DataLoader related tracking on and off