KEMBAR78
Add 'tap', a generic side-effect/observability operator by simonbasle · Pull Request #3013 · reactor/reactor-core · GitHub
Skip to content

Conversation

@simonbasle
Copy link
Contributor

@simonbasle simonbasle commented Apr 12, 2022

Add SignalListener and the FluxTap operator

  • SignalListener and SignalListenerFactory user-facing abstraction
  • Flux#tap and Mono#tap operators
  • includes Fuseable and Conditional implementations

Follow-up: full fusion test coverage, consider support of onErrorContinue

@simonbasle simonbasle force-pushed the observabilityOperator branch from 8ee6533 to 003dc5a Compare April 13, 2022 09:50
@simonbasle simonbasle added the warn/deprecation This issue/PR introduces deprecations label Apr 13, 2022
* @param <STATE> the type of the publisher-level state that will be shared between all {@link SequenceListener} created by this factory
* @author Simon Baslé
*/
public interface SequenceListenerFactory<T, STATE> {
Copy link
Contributor Author

@simonbasle simonbasle Apr 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the public API can and does have a simplified version Flux.listen(Supplier), but I do strongly believe the STATE is an important feature. Passing a Scannable is too likely to run into Scannable.SCAN_UNAVAILABLE instances.

This approach enables calls like flux.listen(Micrometer.metrics()) with powerful configurability (the metrics can use a app-wide configuration for the MeterRegistry + discover name and tags on the source flux or its parents, once per publisher)

 - SignalListener and SignalListenerFactory user-facing abstraction
 - Flux#listen and Mono#listen operators
 - includes Fuseable and Conditional implementations

TODO: tests of FluxListen
@simonbasle simonbasle force-pushed the observabilityOperator branch from e9ddad3 to 39a7eed Compare April 14, 2022 16:59
@simonbasle simonbasle changed the title WIP generic side-effect/observability operator Add a generic side-effect/observability operator Apr 14, 2022
@simonbasle simonbasle added type/enhancement A general enhancement and removed warn/deprecation This issue/PR introduces deprecations labels Apr 14, 2022
@simonbasle simonbasle added this to the 3.5.0-M2 milestone Apr 14, 2022
@simonbasle
Copy link
Contributor Author

Split the PR into this one dedicated to the operator and #3015 dedicated to metrics (deprecation, new module)

@simonbasle simonbasle marked this pull request as ready for review April 14, 2022 17:03
@simonbasle simonbasle requested a review from a team as a code owner April 14, 2022 17:03
 - Flux#listen and Mono#listen didn't actually use the fuseable versions
 - doFirst listener error in all 4 classes was triggering doFinally and
 didn't pass to handleListenerError
 - onSubscribe didn't pass the operator as downstream Subscription
 - Mono variants have scan(PREFETCH) == -1 like Flux variants
@OlegDokuka
Copy link
Contributor

OlegDokuka commented Apr 16, 2022

I'm wondering why we invent a new operator name like listen while all rx libraries have a convenient tap/do operator. (https://www.learnrxjs.io/learn-rxjs/operators/utility/do).

I'm personally against "own" naming and for convenient naming e.g. tap.

P.S. in our reality convenience means better user experience thus better adoption

*
* @param listenerError the exception thrown from a handler method
*/
protected void handleListenerErrorAndTerminate(Throwable listenerError) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still support continuation? Probably we have to check if we wanna continue here before cancelling subscription

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might want to add onErrorContinue support to the operator in some cases, but that's not an absolute priority for M2

Copy link
Contributor

@OlegDokuka OlegDokuka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it was mentioned my main suggestion is to name the operator in a more convenient way which is either to stick to the old peek or to use instead do or tap from the rx world convenience. Also few minor suggestions

@simonbasle
Copy link
Contributor Author

let's go with tap then

@simonbasle
Copy link
Contributor Author

@OlegDokuka I will open a follow-up issue around the support of errorContinue + increase test coverage.
the renaming made me realize that the operator methods were not final btw, fixing that while I renamed listen to tap.

@simonbasle simonbasle requested a review from OlegDokuka April 19, 2022 07:36
@simonbasle simonbasle changed the title Add a generic side-effect/observability operator Add a generic side-effect/observability tap operator Apr 19, 2022
@simonbasle simonbasle changed the title Add a generic side-effect/observability tap operator Add 'tap', a generic side-effect/observability operator Apr 19, 2022
@simonbasle simonbasle merged commit df6ea67 into main Apr 19, 2022
@simonbasle simonbasle deleted the observabilityOperator branch April 19, 2022 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants