2323import java .util .Map ;
2424import java .util .concurrent .CompletableFuture ;
2525import java .util .function .Function ;
26+ import lombok .extern .slf4j .Slf4j ;
2627import org .dataloader .DataLoader ;
2728import org .dataloader .DataLoaderRegistry ;
2829import org .dataloader .stats .Statistics ;
29- import org .slf4j .Logger ;
30- import org .slf4j .LoggerFactory ;
3130
31+ @ Slf4j
3232public class ConfigurableDispatchInstrumentation extends DataLoaderDispatcherInstrumentation {
3333
34- private static final Logger log = LoggerFactory
35- .getLogger (ConfigurableDispatchInstrumentation .class );
36-
3734 private final DataLoaderDispatcherInstrumentationOptions options ;
3835
3936 private final Function <DataLoaderRegistry , TrackingApproach > approachFunction ;
@@ -78,26 +75,26 @@ public DataFetcher<?> instrumentDataFetcher(DataFetcher<?> dataFetcher,
7875 // which allows them to work if used.
7976 return (DataFetcher <Object >) environment -> {
8077 Object obj = dataFetcher .get (environment );
81- immediatelyDispatch (state );
78+ doImmediatelyDispatch (state );
8279 return obj ;
8380 };
8481 }
8582
86- private void immediatelyDispatch (DataLoaderDispatcherInstrumentationState state ) {
83+ private void doImmediatelyDispatch (DataLoaderDispatcherInstrumentationState state ) {
8784 state .getApproach ().dispatch ();
8885 }
8986
9087 @ Override
9188 public InstrumentationContext <ExecutionResult > beginExecuteOperation (
9289 InstrumentationExecuteOperationParameters parameters ) {
93- if (!isDataLoaderCompatibleExecution (parameters .getExecutionContext ())) {
90+ if (!isDataLoaderCompatible (parameters .getExecutionContext ())) {
9491 DataLoaderDispatcherInstrumentationState state = parameters .getInstrumentationState ();
9592 state .setAggressivelyBatching (false );
9693 }
9794 return new SimpleInstrumentationContext <>();
9895 }
9996
100- private boolean isDataLoaderCompatibleExecution (ExecutionContext executionContext ) {
97+ private boolean isDataLoaderCompatible (ExecutionContext executionContext ) {
10198 //
10299 // currently we only support Query operations and ONLY with AsyncExecutionStrategy as the query ES
103100 // This may change in the future but this is the fix for now
@@ -121,10 +118,12 @@ public ExecutionStrategyInstrumentationContext beginExecutionStrategy(
121118 return new ExecutionStrategyInstrumentationContext () {
122119 @ Override
123120 public void onDispatched (CompletableFuture <ExecutionResult > result ) {
121+ // default empty implementation
124122 }
125123
126124 @ Override
127125 public void onCompleted (ExecutionResult result , Throwable t ) {
126+ // default empty implementation
128127 }
129128 };
130129
@@ -157,7 +156,7 @@ public CompletableFuture<ExecutionResult> instrumentExecutionResult(
157156 Map <Object , Object > currentExt = executionResult .getExtensions ();
158157 Map <Object , Object > statsMap = new LinkedHashMap <>(
159158 currentExt == null ? Collections .emptyMap () : currentExt );
160- Map <Object , Object > dataLoaderStats = buildStatsMap (state );
159+ Map <Object , Object > dataLoaderStats = buildStatisticsMap (state );
161160 statsMap .put ("dataloader" , dataLoaderStats );
162161
163162 log .debug ("Data loader stats : {}" , dataLoaderStats );
@@ -169,7 +168,7 @@ public CompletableFuture<ExecutionResult> instrumentExecutionResult(
169168 }
170169 }
171170
172- private Map <Object , Object > buildStatsMap (DataLoaderDispatcherInstrumentationState state ) {
171+ private Map <Object , Object > buildStatisticsMap (DataLoaderDispatcherInstrumentationState state ) {
173172 DataLoaderRegistry dataLoaderRegistry = state .getDataLoaderRegistry ();
174173 Statistics allStats = dataLoaderRegistry .getStatistics ();
175174 Map <Object , Object > statsMap = new LinkedHashMap <>();
0 commit comments