You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/profiler.md
+32-31Lines changed: 32 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,9 @@ description: How to avoid the dreaded N+1 calls for data and make your graphql s
6
6
7
7
# Profiling GraphQL requests
8
8
9
-
We've introduced a new query profiling feature to help you understand the performance characteristics of your GraphQL executions. It provides detailed insights into data fetcher calls, data loader usage, and execution timing. This guide will show you how to use it and interpret the results.
9
+
We've introduced a new profiling feature to help you understand the performance of your GraphQL executions. It provides detailed insights into DataFetcher calls, Dataloader usage, and execution timing. This guide will show you how to use it and interpret the results.
10
10
11
-
The Profiler is available in all versions after v25.0.beta-5. If you're not using a beta version, it will be included in the official v25.0 release.
11
+
The Profiler is available in all versions after v25.0.beta-5. It will also be included in the forthcoming official v25.0 release.
You could alternatively access and log the request's `ProfilerResult` from an `Instrumentation`.
57
+
57
58
## Understanding the Profiler Results
58
59
59
-
The `ProfilerResult` object contains a wealth of information. A great way to get a quick overview is by using the `shortSummaryMap()` method. It returns a map with key metrics about the execution. Let's break down what each key means.
60
+
A great way to get a quick overview about `ProfilerResult`is by using the `shortSummaryMap()` method. It returns a map with key metrics about the execution, which you can use for logging. Let's break down what each key means.
60
61
61
-
### The Short Summary Map
62
+
### The ProfilerResult Short Summary Map
62
63
63
64
Here's a detailed explanation of the fields you'll find in the map returned by `shortSummaryMap()`:
|`executionId`|`String`| The unique ID for this GraphQL execution. |
68
-
|`operationName`|`String`| The name of the operation, if one was provided in the query (e.g., `query MyQuery { ... }`). |
69
-
|`operationType`|`String`| The type of operation, such as `QUERY`, `MUTATION`, or `SUBSCRIPTION`. |
70
-
|`startTimeNs`|`long`| The system monotonic time in nanoseconds when the execution started. |
71
-
|`endTimeNs`|`long`| The system monotonic time in nanoseconds when the execution finished. |
72
-
|`totalRunTimeNs`|`long`| The total wall-clock time of the execution (`endTimeNs - startTimeNs`). This includes time spent waiting for asynchronous operations like database calls or external API requests within your data fetchers.|
|`executionId`|`String`| The unique ID for this GraphQL execution. |
69
+
|`operationName`|`String`| The name of the operation, if one was provided in the query (e.g., `query MyQuery { ... }`). |
70
+
|`operationType`|`String`| The type of operation, such as `QUERY`, `MUTATION`, or `SUBSCRIPTION`. |
71
+
|`startTimeNs`|`long`| The system time in nanoseconds when the execution started.|
72
+
|`endTimeNs`|`long`| The system time in nanoseconds when the execution finished.|
73
+
|`totalRunTimeNs`|`long`| The total wall-clock time of the execution (`endTimeNs - startTimeNs`). This includes time spent waiting for asynchronous operations like database calls or external API requests within your DataFetchers. |
73
74
|`engineTotalRunningTimeNs`|`long`| The total time the GraphQL engine spent actively running on a thread. This is like the "CPU time" of the execution and excludes time spent waiting for `CompletableFuture`s to complete. Comparing this with `totalRunTimeNs` can give you a good idea of how much time is spent on I/O. |
74
-
|`totalDataFetcherInvocations`|`int`| The total number of times any data fetcher was invoked. |
75
-
|`totalCustomDataFetcherInvocations`|`int`| The number of invocations for data fetchers you've written yourself (i.e., not the built-in `PropertyDataFetcher`). This is often the most interesting data fetcher metric.|
76
-
|`totalTrivialDataFetcherInvocations`|`int`| The number of invocations for the built-in `PropertyDataFetcher`, which simply retrieves a property from a POJO.|
77
-
|`totalWrappedTrivialDataFetcherInvocations`|`int`| The number of invocations for data fetchers that wrap a `PropertyDataFetcher`. This usually happens when you use instrumentation to wrap data fetchers.|
78
-
|`fieldsFetchedCount`|`int`| The number of unique fields fetched during the execution. |
79
-
|`dataLoaderChainingEnabled`|`boolean`|`true` if the experimental data loader chaining feature was enabled for this execution. |
80
-
|`dataLoaderLoadInvocations`|`Map`| A map where keys are data loader names and values are the number of times `load()` was called on them. Note that this counts all `load()` calls, including those that hit the data loader cache. |
81
-
|`oldStrategyDispatchingAll`|`Set`|An advanced metric related to an older data loader dispatching strategy. It contains the execution levels where all data loaders were dispatched at once.|
82
-
|`dispatchEvents`|`List<Map>`| A list of events, one for each time a data loader was dispatched. See below for details. |
83
-
|`instrumentationClasses`|`List<String>`| A list of the fully qualified class names of the `Instrumentation` implementations used during this execution. |
84
-
|`dataFetcherResultTypes`|`Map`| A summary of the types of values returned by your custom data fetchers. See below for details. |
75
+
|`totalDataFetcherInvocations`|`int`| The total number of times any DataFetcher was invoked.|
76
+
|`totalCustomDataFetcherInvocations`|`int`| The number of invocations for DataFetchers you've written yourself (i.e., not the built-in `PropertyDataFetcher`). |
77
+
|`totalTrivialDataFetcherInvocations`|`int`| The number of invocations for the built-in `PropertyDataFetcher`. |
78
+
|`totalWrappedTrivialDataFetcherInvocations`|`int`| The number of invocations for DataFetchers that wrap a `PropertyDataFetcher`. |
79
+
|`fieldsFetchedCount`|`int`| The number of unique fields fetched during the execution. |
80
+
|`dataLoaderChainingEnabled`|`boolean`|`true` if the experimental Dataloader chaining feature was enabled for this execution.|
81
+
|`dataLoaderLoadInvocations`|`Map`| A map where keys are Dataloader names and values are the number of times `load()` was called on them. Note that this counts all `load()` calls, including those that hit the Dataloader cache.|
82
+
|`oldStrategyDispatchingAll`|`Set`|If Chained DataLoaders are not used, the older dispatching strategy is used instead. This key lists the levels where DataLoaders were dispatched. |
83
+
|`dispatchEvents`|`List<Map>`| A list of events, one for each time a Dataloader was dispatched. See below for details.|
84
+
|`instrumentationClasses`|`List<String>`| A list of the class names of the `Instrumentation`s used during this execution.|
85
+
|`dataFetcherResultTypes`|`Map`| A summary of the types of values returned by your custom DataFetchers. See below for details.|
85
86
86
87
#### `dispatchEvents`
87
88
@@ -96,17 +97,17 @@ This is a list of maps, each detailing a `DataLoader` dispatch event.
96
97
97
98
#### `dataFetcherResultTypes`
98
99
99
-
This map gives you insight into the nature of your data fetchers' return values. This is especially useful for understanding the asynchronous behavior of your schema.
100
+
This map gives you more information into the type of your DataFetchers' return values.
100
101
101
102
The keys are `COMPLETABLE_FUTURE_COMPLETED`, `COMPLETABLE_FUTURE_NOT_COMPLETED`, and `MATERIALIZED`.
102
103
Each key maps to another map with two keys:
103
-
*`count`: The number of unique fields with data fetchers that returned this result type.
104
+
*`count`: The number of unique fields with DataFetchers that returned this result type.
104
105
*`invocations`: The total number of invocations across all fields that returned this result type.
0 commit comments