Skip to content

Commit 7bd7f34

Browse files
committed
fix: add logging
1 parent 90da750 commit 7bd7f34

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

backend/src/main/java/ch/xxx/trader/usecase/services/CoinbaseService.java

+12-5
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,20 @@ private void processTimeFrame(MyTimeFrame timeFrame1, boolean isDay) {
206206
// Coinbase
207207
final var logFailed = String.format("Coinbase prepare %s data failed", isDay ? "day" : "hour");
208208
Mono<Collection<QuoteCb>> collectCb = this.myMongoRepository.find(query, QuoteCb.class)
209-
.timeout(this.slowIo ? Duration.ofSeconds(30L) : Duration.ofSeconds(10L)).doOnError(ex -> LOG.warn(logFailed, ex))
210-
.onErrorResume(ex -> Mono.empty()).subscribeOn(this.mongoScheduler).collectList()
209+
.timeout(this.slowIo ? Duration.ofSeconds(30L) : Duration.ofSeconds(10L))
210+
.doOnError(ex -> LOG.warn(logFailed, ex)).onErrorResume(ex -> {
211+
LOG.warn(logFailed, ex);
212+
return Mono.empty();
213+
}).subscribeOn(this.mongoScheduler).collectList()
211214
.map(quotes -> this.createCbQuoteTimeFrame(timeFrame1, isDay, quotes));
212215
collectCb.filter(Predicate.not(Collection::isEmpty))
213216
.map(myColl -> this.countRelevantProperties(nonZeroProperties, myColl))
214217
.flatMap(myColl -> this.myMongoRepository.insertAll(Mono.just(myColl), isDay ? CB_DAY_COL : CB_HOUR_COL)
215-
.timeout(this.slowIo ? Duration.ofSeconds(30L) : Duration.ofSeconds(10L)).doOnError(ex -> LOG.warn(logFailed, ex))
216-
.onErrorResume(ex -> Mono.empty()).subscribeOn(this.mongoScheduler).collectList())
218+
.timeout(this.slowIo ? Duration.ofSeconds(30L) : Duration.ofSeconds(10L))
219+
.doOnError(ex -> LOG.warn(logFailed, ex)).onErrorResume(ex -> {
220+
LOG.warn(logFailed, ex);
221+
return Mono.empty();
222+
}).subscribeOn(this.mongoScheduler).collectList())
217223
.subscribeOn(this.mongoScheduler).block();
218224
LOG.info(String.format("Prepared Coinbase %s Data for: ", isDay ? "Day" : "Hour")
219225
+ sdf.format(timeFrame1.begin().getTime()) + " Time: " + (new Date().getTime() - start.getTime()) + "ms"
@@ -227,7 +233,8 @@ private Collection<QuoteCb> createCbQuoteTimeFrame(final MyTimeFrame timeFrame1,
227233
var result = isDay ? this.makeCbQuoteDay(quotes, timeFrame1.begin(), timeFrame1.end())
228234
: this.makeCbQuoteHour(quotes, timeFrame1.begin(), timeFrame1.end());
229235
LOG.info(String.format("Calculate Coinbase %s Data for: ", isDay ? "Day" : "Hour")
230-
+ sdf.format(timeFrame1.begin().getTime()) + " Time: " + (new Date().getTime() - start.getTime()) + "ms");
236+
+ sdf.format(timeFrame1.begin().getTime()) + " Time: " + (new Date().getTime() - start.getTime())
237+
+ "ms");
231238
return result;
232239
}
233240

0 commit comments

Comments
 (0)