Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve scannable name() when debug() mode is enabled #1115

Closed
smaldini opened this issue Mar 8, 2018 · 4 comments
Closed

Improve scannable name() when debug() mode is enabled #1115

smaldini opened this issue Mar 8, 2018 · 4 comments
Labels
type/enhancement A general enhancement warn/deprecation This issue/PR introduces deprecations
Milestone

Comments

@smaldini
Copy link
Contributor

smaldini commented Mar 8, 2018

If scanning parent publisher (Flux/Mono)

  • Use the immediate parent FluxAssembly toString()
    If scanning parent subscription :
  • Use the immediate parent FluxAssembly subscriber toString() which is not defined for now. Currently the toString is not implemented but it could be equivalent to FluxAssembly itself

For both scan, filter the assembly operators from the actuals()/parents()/inners()

@smaldini smaldini added the type/enhancement A general enhancement label Mar 8, 2018
@simonbasle
Copy link
Member

@smaldini can you detail a little bit, with a concrete example? I'm not sure I fully understand the requested enhancement.

@simonbasle simonbasle added the for/user-attention This issue needs user attention (feedback, rework, etc...) label Mar 8, 2018
@smaldini
Copy link
Contributor Author

smaldini commented Mar 11, 2018

So right now if you do

Hooks.onOperators.debug();
Mono<?> m=
 Flux.from(s -> Scannable.from(s).actuals().forEach(sc -> System.out.println(sc.name())))
   .map(a -> a)
   .filter(a -> true)
   .reduce((a, b) -> b);

System.out.println("Scan actual subscribers:");
m .subscribe();

System.out.println("\nScan parent publishers:");
Scannable.from(m).parents().forEach(sc -> System.out.println(sc.name()));

You should see something like:

Scan actual subscribers:
AssemblySubscriber
MapSubscriber
AssemblySubscriber
FilterSubscriber
AssemblySubscriber
ReduceSubscriber
AssemblySubscriber
LambdaSubscriber

Scan parent publishers:
FluxAssembly
FluxReduce
FluxAssembly
FluxFilter
FluxAssembly
FluxMap
FluxAssembly
FluxSource

I propose to filter assembly operators from such parents()/actuals() if possible and better, try to reuse the stacktrace first line as a name output like "FluxReduce(MyCode:123)"

@simonbasle
Copy link
Member

Scannable.name() is a bit confusing: it scans for NAME in the operator AND the parents hierarchy until it finds a Scannable that answers to NAME, but that's more of a "name of the sequence" thing. It reverts to outputing the operatorName() of the root Scannable if 0 operator in the hierarchy answers to NAME.

In your example I think you should have used operatorName(), which should be easy to implement as stacktrace.stackLine() for the assembly operators and subscribers.

I don't think that eliminating xxxOnAssembly operators from the more generic parents() and actuals() streams is necessarily a good idea.

Perhaps name() should also be deprecated and aliased sequenceName() or something like that for clarity?

simonbasle added a commit that referenced this issue Mar 12, 2018
This commit disambiguates the `Scannable#name()` by aliasing it to
`sequenceName()`. It also adds convenience stream variants to `parents`
and `actuals` that include the current `Scannable`.

`InnerConsumer` subscribers have an `operatorName()` implementation that
returns their simple class name.

Finally, this commit adds a special implementation of operatorName to
the various `xxxOnAssembly` operators and subscribers which returns the
assembly stack trace's first line (trimmed of whitespaces/tabs).
@simonbasle simonbasle removed the for/user-attention This issue needs user attention (feedback, rework, etc...) label Mar 12, 2018
@simonbasle simonbasle added this to the 3.2.0.RELEASE milestone Mar 12, 2018
simonbasle added a commit that referenced this issue Mar 22, 2018
This commit disambiguates the `Scannable#name()` by aliasing it to
`sequenceName()`. It also adds convenience stream variants to `parents`
and `actuals` that include the current `Scannable`.

`InnerConsumer` subscribers have an `operatorName()` implementation that
returns their simple class name.

Finally, this commit adds a special implementation of operatorName to
the various `xxxOnAssembly` operators and subscribers which returns the
assembly stack trace's first line (trimmed of whitespaces/tabs).
@simonbasle simonbasle added the warn/deprecation This issue/PR introduces deprecations label Apr 4, 2018
@simonbasle
Copy link
Member

See further discussion in #1140

@simonbasle simonbasle modified the milestones: 3.2.0.RELEASE, 3.2.0.M2 May 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement A general enhancement warn/deprecation This issue/PR introduces deprecations
Projects
None yet
Development

No branches or pull requests

2 participants