11package graphql ;
22
3+ import graphql .execution .ExecutionId ;
4+
35import java .util .LinkedHashSet ;
46import java .util .Map ;
57import java .util .Set ;
911@ ExperimentalApi
1012public class ProfilerResult {
1113
12- public static String PROFILER_CONTEXT_KEY = "__GJ_PROFILER" ;
14+ public static final String PROFILER_CONTEXT_KEY = "__GJ_PROFILER" ;
15+
16+ private volatile ExecutionId executionId ;
17+ private long startTime ;
18+ private long endTime ;
19+ private long engineTotalRunningTime ;
20+ private final Set <String > fieldsFetched = ConcurrentHashMap .newKeySet ();
1321
1422 private final AtomicInteger totalDataFetcherInvocations = new AtomicInteger ();
1523 private final AtomicInteger totalPropertyDataFetcherInvocations = new AtomicInteger ();
1624
1725
18- private final Set <String > fieldsFetched = ConcurrentHashMap .newKeySet ();
1926 private final Map <String , Integer > dataFetcherInvocationCount = new ConcurrentHashMap <>();
2027 private final Map <String , DataFetcherType > dataFetcherTypeMap = new ConcurrentHashMap <>();
2128
29+
2230 public enum DataFetcherType {
2331 PROPERTY_DATA_FETCHER ,
2432 CUSTOM
@@ -31,7 +39,8 @@ public enum ResultType {
3139
3240 }
3341
34- private Map <String , ResultType > queryPathToResultType ;
42+
43+ // setters are package private to prevent exposure
3544
3645 void setDataFetcherType (String key , DataFetcherType dataFetcherType ) {
3746 dataFetcherTypeMap .putIfAbsent (key , dataFetcherType );
@@ -49,6 +58,16 @@ void addFieldFetched(String fieldPath) {
4958 fieldsFetched .add (fieldPath );
5059 }
5160
61+ void setExecutionId (ExecutionId executionId ) {
62+ this .executionId = executionId ;
63+ }
64+
65+ void setTimes (long startTime , long endTime , long engineTotalRunningTime ) {
66+ this .startTime = startTime ;
67+ this .endTime = endTime ;
68+ this .engineTotalRunningTime = engineTotalRunningTime ;
69+ }
70+
5271
5372 public Set <String > getFieldsFetched () {
5473 return fieldsFetched ;
@@ -87,4 +106,34 @@ public int getTotalCustomDataFetcherInvocations() {
87106 return totalDataFetcherInvocations .get () - totalPropertyDataFetcherInvocations .get ();
88107 }
89108
109+ public long getStartTime () {
110+ return startTime ;
111+ }
112+
113+ public long getEndTime () {
114+ return endTime ;
115+ }
116+
117+ public long getEngineTotalRunningTime () {
118+ return engineTotalRunningTime ;
119+ }
120+
121+ public long getTotalExecutionTime () {
122+ return endTime - startTime ;
123+ }
124+
125+ @ Override
126+ public String toString () {
127+ return "ProfilerResult{" +
128+ "executionId=" + executionId +
129+ ", startTime=" + startTime +
130+ ", endTime=" + endTime +
131+ ", engineTotalRunningTime=" + engineTotalRunningTime +
132+ ", fieldsFetched=" + fieldsFetched +
133+ ", totalDataFetcherInvocations=" + totalDataFetcherInvocations +
134+ ", totalPropertyDataFetcherInvocations=" + totalPropertyDataFetcherInvocations +
135+ ", dataFetcherInvocationCount=" + dataFetcherInvocationCount +
136+ ", dataFetcherTypeMap=" + dataFetcherTypeMap +
137+ '}' ;
138+ }
90139}
0 commit comments