18
18
19
19
import org .dataloader .annotations .PublicApi ;
20
20
import org .dataloader .impl .Assertions ;
21
+ import org .dataloader .instrumentation .DataLoaderInstrumentation ;
22
+ import org .dataloader .instrumentation .DataLoaderInstrumentationHelper ;
21
23
import org .dataloader .scheduler .BatchLoaderScheduler ;
22
24
import org .dataloader .stats .NoOpStatisticsCollector ;
23
25
import org .dataloader .stats .StatisticsCollector ;
@@ -48,6 +50,7 @@ public class DataLoaderOptions {
48
50
private BatchLoaderContextProvider environmentProvider ;
49
51
private ValueCacheOptions valueCacheOptions ;
50
52
private BatchLoaderScheduler batchLoaderScheduler ;
53
+ private DataLoaderInstrumentation instrumentation ;
51
54
52
55
/**
53
56
* Creates a new data loader options with default settings.
@@ -61,6 +64,7 @@ public DataLoaderOptions() {
61
64
environmentProvider = NULL_PROVIDER ;
62
65
valueCacheOptions = ValueCacheOptions .newOptions ();
63
66
batchLoaderScheduler = null ;
67
+ instrumentation = DataLoaderInstrumentationHelper .NOOP_INSTRUMENTATION ;
64
68
}
65
69
66
70
/**
@@ -80,7 +84,8 @@ public DataLoaderOptions(DataLoaderOptions other) {
80
84
this .statisticsCollector = other .statisticsCollector ;
81
85
this .environmentProvider = other .environmentProvider ;
82
86
this .valueCacheOptions = other .valueCacheOptions ;
83
- batchLoaderScheduler = other .batchLoaderScheduler ;
87
+ this .batchLoaderScheduler = other .batchLoaderScheduler ;
88
+ this .instrumentation = other .instrumentation ;
84
89
}
85
90
86
91
/**
@@ -103,7 +108,6 @@ public boolean batchingEnabled() {
103
108
* Sets the option that determines whether batch loading is enabled.
104
109
*
105
110
* @param batchingEnabled {@code true} to enable batch loading, {@code false} otherwise
106
- *
107
111
* @return the data loader options for fluent coding
108
112
*/
109
113
public DataLoaderOptions setBatchingEnabled (boolean batchingEnabled ) {
@@ -124,7 +128,6 @@ public boolean cachingEnabled() {
124
128
* Sets the option that determines whether caching is enabled.
125
129
*
126
130
* @param cachingEnabled {@code true} to enable caching, {@code false} otherwise
127
- *
128
131
* @return the data loader options for fluent coding
129
132
*/
130
133
public DataLoaderOptions setCachingEnabled (boolean cachingEnabled ) {
@@ -134,7 +137,7 @@ public DataLoaderOptions setCachingEnabled(boolean cachingEnabled) {
134
137
135
138
/**
136
139
* Option that determines whether to cache exceptional values (the default), or not.
137
- *
140
+ * <p>
138
141
* For short-lived caches (that is request caches) it makes sense to cache exceptions since
139
142
* it's likely the key is still poisoned. However, if you have long-lived caches, then it may make
140
143
* sense to set this to false since the downstream system may have recovered from its failure
@@ -150,7 +153,6 @@ public boolean cachingExceptionsEnabled() {
150
153
* Sets the option that determines whether exceptional values are cache enabled.
151
154
*
152
155
* @param cachingExceptionsEnabled {@code true} to enable caching exceptional values, {@code false} otherwise
153
- *
154
156
* @return the data loader options for fluent coding
155
157
*/
156
158
public DataLoaderOptions setCachingExceptionsEnabled (boolean cachingExceptionsEnabled ) {
@@ -173,7 +175,6 @@ public Optional<CacheKey> cacheKeyFunction() {
173
175
* Sets the function to use for creating the cache key, if caching is enabled.
174
176
*
175
177
* @param cacheKeyFunction the cache key function to use
176
- *
177
178
* @return the data loader options for fluent coding
178
179
*/
179
180
public DataLoaderOptions setCacheKeyFunction (CacheKey <?> cacheKeyFunction ) {
@@ -196,7 +197,6 @@ public DataLoaderOptions setCacheKeyFunction(CacheKey<?> cacheKeyFunction) {
196
197
* Sets the cache map implementation to use for caching, if caching is enabled.
197
198
*
198
199
* @param cacheMap the cache map instance
199
- *
200
200
* @return the data loader options for fluent coding
201
201
*/
202
202
public DataLoaderOptions setCacheMap (CacheMap <?, ?> cacheMap ) {
@@ -219,7 +219,6 @@ public int maxBatchSize() {
219
219
* before they are split into multiple class
220
220
*
221
221
* @param maxBatchSize the maximum batch size
222
- *
223
222
* @return the data loader options for fluent coding
224
223
*/
225
224
public DataLoaderOptions setMaxBatchSize (int maxBatchSize ) {
@@ -240,7 +239,6 @@ public StatisticsCollector getStatisticsCollector() {
240
239
* a common value
241
240
*
242
241
* @param statisticsCollector the statistics collector to use
243
- *
244
242
* @return the data loader options for fluent coding
245
243
*/
246
244
public DataLoaderOptions setStatisticsCollector (Supplier <StatisticsCollector > statisticsCollector ) {
@@ -259,7 +257,6 @@ public BatchLoaderContextProvider getBatchLoaderContextProvider() {
259
257
* Sets the batch loader environment provider that will be used to give context to batch load functions
260
258
*
261
259
* @param contextProvider the batch loader context provider
262
- *
263
260
* @return the data loader options for fluent coding
264
261
*/
265
262
public DataLoaderOptions setBatchLoaderContextProvider (BatchLoaderContextProvider contextProvider ) {
@@ -282,7 +279,6 @@ public DataLoaderOptions setBatchLoaderContextProvider(BatchLoaderContextProvide
282
279
* Sets the value cache implementation to use for caching values, if caching is enabled.
283
280
*
284
281
* @param valueCache the value cache instance
285
- *
286
282
* @return the data loader options for fluent coding
287
283
*/
288
284
public DataLoaderOptions setValueCache (ValueCache <?, ?> valueCache ) {
@@ -301,7 +297,6 @@ public ValueCacheOptions getValueCacheOptions() {
301
297
* Sets the {@link ValueCacheOptions} that control how the {@link ValueCache} will be used
302
298
*
303
299
* @param valueCacheOptions the value cache options
304
- *
305
300
* @return the data loader options for fluent coding
306
301
*/
307
302
public DataLoaderOptions setValueCacheOptions (ValueCacheOptions valueCacheOptions ) {
@@ -321,11 +316,28 @@ public BatchLoaderScheduler getBatchLoaderScheduler() {
321
316
* to some future time.
322
317
*
323
318
* @param batchLoaderScheduler the scheduler
324
- *
325
319
* @return the data loader options for fluent coding
326
320
*/
327
321
public DataLoaderOptions setBatchLoaderScheduler (BatchLoaderScheduler batchLoaderScheduler ) {
328
322
this .batchLoaderScheduler = batchLoaderScheduler ;
329
323
return this ;
330
324
}
325
+
326
+ /**
327
+ * @return the {@link DataLoaderInstrumentation} to use
328
+ */
329
+ public DataLoaderInstrumentation getInstrumentation () {
330
+ return instrumentation ;
331
+ }
332
+
333
+ /**
334
+ * Sets in a new {@link DataLoaderInstrumentation}
335
+ *
336
+ * @param instrumentation the new {@link DataLoaderInstrumentation}
337
+ * @return the data loader options for fluent coding
338
+ */
339
+ public DataLoaderOptions setInstrumentation (DataLoaderInstrumentation instrumentation ) {
340
+ this .instrumentation = nonNull (instrumentation );
341
+ return this ;
342
+ }
331
343
}
0 commit comments