Instrumentation support of DataLoaders
A new org.dataloader.instrumentation.DataLoaderInstrumentation
has been added that is a callback to allow you to know when certain DataLoader
actions start and when they finish.
DataLoaderInstrumentation timingInstrumentation = new DataLoaderInstrumentation() {
@Override
public DataLoaderInstrumentationContext<DispatchResult<?>> beginDispatch(DataLoader<?, ?> dataLoader) {
long then = System.currentTimeMillis();
return DataLoaderInstrumentationHelper.whenCompleted((result, err) -> {
long ms = System.currentTimeMillis() - then;
System.out.println(format("dispatch time: %d ms", ms));
});
}
@Override
public DataLoaderInstrumentationContext<List<?>> beginBatchLoader(DataLoader<?, ?> dataLoader, List<?> keys, BatchLoaderEnvironment environment) {
long then = System.currentTimeMillis();
return DataLoaderInstrumentationHelper.whenCompleted((result, err) -> {
long ms = System.currentTimeMillis() - then;
System.out.println(format("batch loader time: %d ms", ms));
});
}
};
DataLoaderOptions options = DataLoaderOptions.newOptions().setInstrumentation(timingInstrumentation);
DataLoader<String, User> userDataLoader = DataLoaderFactory.newDataLoader(userBatchLoader, options);
Immutable classes
Some of the key classes like org.dataloader.DataLoaderOptions
have been made immutable so as to provide more surety in how they get used and transformed. This is technically a breaking change if you code relied on the old mutability, however on balance we think this is a better code position to be in.
What's Changed
- Update version to 3.4.0 by @dondonz in #168
- Add stale bot by @dondonz in #169
- Removing unused slf4j references by @dondonz in #170
- Parameterise more tests across DataLoader implementations by @AlexandreCarlton in #171
- Allow ValueCache to work with Publisher DataLoader by @AlexandreCarlton in #172
- Transform support for DataLoaders by @bbakerman in #174
- Making DataLoaderOptions immutable by @bbakerman in #176
- Instrumentation support for dataloader by @bbakerman in #175
- add jspecify by @andimarek in #180
- Fixed a bug that the Spring team found by @bbakerman in #181
- Added a instrumentation of load calls by @bbakerman in #178
- Added support for a delegating data loader by @bbakerman in #182
- Update documentation for new release by @dondonz in #183
New Contributors
- @andimarek made their first contribution in #180
Full Changelog: v3.4.0...v4.0.0