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

Introducing Kafka Streams DevUI #20663

Merged

Conversation

danielpetisme
Copy link
Contributor

This PR aims at providing a Dev UI for Kafka Streams.
The first element is a topology visualizer similar to https://zz85.github.io/kafka-streams-viz/.
I choose to use mermaid.js rather than a graphviz JS implementation.

The topology is fetched from the Arc container to supply a TopologyDescription object.
Then it's up to the frontend part to parse it, build a mermaid description and render the final graph.
Here you have an example
Screenshot 2021-10-11 at 11 40 40

UI remarks

  • The textarea is reaonly, the topology visualizer aimed at rendering the current application topology not to be a general purpose Kafka Streams topology visualizer tool.
  • I used Mermaid default styling. Is there a Quarkus color palette? Is it worth it?
  • The textarea font could be reduce a bit... What do you think?

The main concern I have is regarding mermaid.js files, I had to update the vertx-http extension to bundle the JS files.
I didn't found a way to package static assets as part of the extension itself. I think for isolation/decoupling purposes it would be better to not have to update the vertx-http extension...
https://quarkusio.zulipchat.com/#narrow/stream/187038-dev/topic/DevUI.20custom.20static.20resources/near/256872499

I may add a "statics row on top of the current content displaying the numbers of sub-topologies, input/output topics as well as state stores.

This is the first draft so, feedbacks are more than welcome!

@quarkus-bot quarkus-bot bot added area/dependencies Pull requests that update a dependency file area/kafka-streams area/vertx labels Oct 11, 2021
@gsmet
Copy link
Member

gsmet commented Oct 11, 2021

Woot, this is very nice!

How complex can a topology be? I wonder if it's going to work well to have both on the same line? But maybe you can tweak things depending on the number of columns?

As for pushing the JS dependency to vertx-http, I think it has also some advantages as it would be good to reuse the same JS libraries across all Dev UI components. So I would lean towards keeping it that way.

@gsmet
Copy link
Member

gsmet commented Oct 11, 2021

/cc @phillip-kruger for his opinion on the color palette. I personally think it looks pretty much OK as it is.

@phillip-kruger
Copy link
Member

This looks awesome ! I think we can merge as is and tweek later if needed. You should be able to include the webjar in the runtime module of the extension and still access it from the js, but as @gsmet said, having it in vert-x module makes it easier to reuse, and also only include it when dev mode.

Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

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

I added a few comments.

@@ -53,7 +54,7 @@ void build(BuildProducer<FeatureBuildItem> feature,

registerClassesThatAreLoadedThroughReflection(reflectiveClasses, launchMode);
registerClassesThatAreAccessedViaJni(jniRuntimeAccessibleClasses);
addSupportForRocksDbLib(nativeLibs, config);
// addSupportForRocksDbLib(nativeLibs, config);
Copy link
Member

Choose a reason for hiding this comment

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

Hmmm?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad... I was having issue to use the 999-SNAPSHOT version and commenting this line was a workaroung.

@@ -0,0 +1,178 @@
{#include main fluid=true}
{#style}
textarea {
Copy link
Member

Choose a reason for hiding this comment

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

Better specify a specific style. You never know what we will add later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done I use the #topology-description CSS id to apply the style.


@Override
public TopologyDescription get() {
Topology topology = Arc.container().instance(Topology.class).get();
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure the topology is always produced? What if we just added the extension and haven't configured anything yet? This is a case we need to handle.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. Now I return the Topology object and test its presence (initially I thought of returning the String version of the topology but was not convenient for upcoming features).
Actually returning the Topology object makes much more sense.

<label for="topology-description" class="col-form-label h1">Kafka Streams Topology</label>
<textarea id="topology-description" readonly
class="form-control-plaintext p-3 mb-5 bg-white r border rounded"
rows='{info:topology.toString().split("\r\n|\r|\n").length} + 1'>
Copy link
Member

Choose a reason for hiding this comment

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

What if the topology is not yet defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.
an error Message is displayed

</form>
</div>
<div class="col-5">
<div id="graph">
Copy link
Member

Choose a reason for hiding this comment

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

I would use a more specific id (topology-graph?).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@danielpetisme danielpetisme force-pushed the devservices-kafkastreams-toplogy-viewer branch from 912d14a to 9eea828 Compare October 11, 2021 13:08

@Override
public Topology get() {
return Arc.container().instance(Topology.class).get();
Copy link
Member

Choose a reason for hiding this comment

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

So you're always producing a topology even if nothing is configured? Because if not, there's a good chance this will fail.

Copy link
Contributor Author

@danielpetisme danielpetisme Oct 11, 2021

Choose a reason for hiding this comment

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

Can you confirm that Arc.container().instance(Topology.class) will return null I nothing is configured?
I tested by disabling @Produces on an application.
Do you think it's enough?
Do you see any edge cases?

Copy link
Member

Choose a reason for hiding this comment

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

No it's OK, I thought this method was throwing an exception if not present but it simply returns null. So as long as you have taken into account the null case, we're good.

@danielpetisme
Copy link
Contributor Author

Thanks for the review. I introduced an error message when the Topology is absent.
Screenshot 2021-10-11 at 15 11 31
Feel free to proposed other wordings. I wanted to be explicit on the 2 main steps required to build a topology:

  1. Having an application scoped bean
  2. Having a producer method returning the topology.

What do you think?

@danielpetisme
Copy link
Contributor Author

@gsmet @phillip-kruger I'm thinking of an alternative way to display the absence of the topology.
Rather than displaying an error message, I could simply not present the Topology link in the Kafka Streams tile.
In terms of DevX, it sounds maybe more pragmatic but it would prevent developers to have the hints I display in the error message (ie ApplicationScoped + Produce).
Which solution do you prefer?

@phillip-kruger
Copy link
Member

@danielpetisme - I like what you have now, I don't think that is an error message, but rather an info message. Nice and clear.

@danielpetisme
Copy link
Contributor Author

@gsmet I will let you hit the"Resolve conversation" button wherever it makes sense.

@quarkus-bot
Copy link

quarkus-bot bot commented Oct 11, 2021

This workflow status is outdated as a new workflow run has been triggered.

Failing Jobs - Building 9eea828

Status Name Step Failures Logs Raw logs
JVM Tests - JDK 11 Build Failures Logs Raw logs
JVM Tests - JDK 11 Windows Upload gc.log ⚠️ Check → Logs Raw logs
✔️ JVM Tests - JDK 17

Full information is available in the Build summary check run.

Failures

⚙️ JVM Tests - JDK 11 #

- Failing: integration-tests/vault-agroal 

📦 integration-tests/vault-agroal

io.quarkus.vault.AgroalVaultITCase. - More details - Source on GitHub

java.lang.RuntimeException: Error waiting for test resource future to finish.
	at io.quarkus.test.common.TestResourceManager.waitForAllFutures(TestResourceManager.java:151)
	at io.quarkus.test.common.TestResourceManager.start(TestResourceManager.java:136)

io.quarkus.vault.AgroalVaultKv1ITCase. - More details - Source on GitHub

java.lang.RuntimeException: Error waiting for test resource future to finish.
	at io.quarkus.test.common.TestResourceManager.waitForAllFutures(TestResourceManager.java:151)
	at io.quarkus.test.common.TestResourceManager.start(TestResourceManager.java:136)

io.quarkus.vault.VaultKv1ITCase. - More details - Source on GitHub

java.lang.RuntimeException: Error waiting for test resource future to finish.
	at io.quarkus.test.common.TestResourceManager.waitForAllFutures(TestResourceManager.java:151)
	at io.quarkus.test.common.TestResourceManager.start(TestResourceManager.java:136)

@geoand
Copy link
Contributor

geoand commented Oct 12, 2021

Awesome stuff!

Can we backport it to 2.4?

gsmet
gsmet previously requested changes Oct 12, 2021
Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

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

I spotted a small remaining issue. Once fixed, I think we should merge it.

@@ -32,6 +32,7 @@
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.RuntimeReinitializedClassBuildItem;
import io.quarkus.deployment.pkg.NativeConfig;
import io.quarkus.kafka.streams.runtime.*;
Copy link
Member

Choose a reason for hiding this comment

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

This needs to go away. All the changes in this file are useless.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@danielpetisme
Copy link
Contributor Author

danielpetisme commented Oct 12, 2021

@gsmet @geoand @phillip-kruger
I made a small variant, what do you think?
(for now it's only a mockup is not part of the current PR)
I'm not sure about it.
Screenshot 2021-10-12 at 15 45 44

@danielpetisme danielpetisme force-pushed the devservices-kafkastreams-toplogy-viewer branch from 9eea828 to bdf8e26 Compare October 12, 2021 13:53
@phillip-kruger
Copy link
Member

I like it

@geoand
Copy link
Contributor

geoand commented Oct 12, 2021

👍🏼

@danielpetisme
Copy link
Contributor Author

danielpetisme commented Oct 12, 2021

Ok so now I have to dev it 😄
if there is any time constraints, feel free to merge the PR as is and I'll open a new one with the UI upgrade.

@geoand
Copy link
Contributor

geoand commented Oct 12, 2021

I think it's something we will want in 2.4, which means we would need it in in the next few days

@gsmet
Copy link
Member

gsmet commented Oct 12, 2021

That looks cool! Please squash everything once done. Thanks!

@quarkus-bot
Copy link

quarkus-bot bot commented Oct 12, 2021

This workflow status is outdated as a new workflow run has been triggered.

Failing Jobs - Building bdf8e26

Status Name Step Failures Logs Raw logs
✔️ JVM Tests - JDK 11
JVM Tests - JDK 11 Windows Upload gc.log ⚠️ Check → Logs Raw logs
✔️ JVM Tests - JDK 17

@danielpetisme danielpetisme force-pushed the devservices-kafkastreams-toplogy-viewer branch from bdf8e26 to 76cf3b4 Compare October 13, 2021 07:16
@danielpetisme
Copy link
Contributor Author

danielpetisme commented Oct 13, 2021

Hello dream team,
Here is the final version of the PR.
@geoand I saw you have the "noteworthy" label. I attached clean screenshots if you want to add them in release notes

Screenshot 2021-10-13 at 09 26 32
Screenshot 2021-10-13 at 09 18 15

I have other ideas in mind regarding Kafka Streams Dev UI, stay tuned ;-)

@geoand
Copy link
Contributor

geoand commented Oct 13, 2021

Looks great! I marked it for inclusion into 2.4.

Thanks a lot for this!

@danielpetisme danielpetisme force-pushed the devservices-kafkastreams-toplogy-viewer branch from 76cf3b4 to ccedcec Compare October 13, 2021 07:28
@phillip-kruger phillip-kruger added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Oct 13, 2021
@phillip-kruger
Copy link
Member

very nice !

@geoand geoand dismissed gsmet’s stale review October 13, 2021 09:36

Comments addressed

@geoand geoand removed area/vertx area/dependencies Pull requests that update a dependency file labels Oct 13, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Oct 13, 2021

This workflow status is outdated as a new workflow run has been triggered.

Failing Jobs - Building ccedcec

Status Name Step Failures Logs Raw logs
Devtools Tests - JDK 11 Windows ⚠️ Check → Logs Raw logs
Gradle Tests - JDK 11 Windows ⚠️ Check → Logs Raw logs
✔️ JVM Tests - JDK 11
JVM Tests - JDK 11 Windows ⚠️ Check → Logs Raw logs
✔️ JVM Tests - JDK 17
Maven Tests - JDK 11 Windows ⚠️ Check → Logs Raw logs
Native Tests - Windows - hibernate-validator ⚠️ Check → Logs Raw logs

@danielpetisme
Copy link
Contributor Author

The CI is failing I'm not sure it's due to the code I introduced...
Is it "normal"? Should I do something else?

@geoand
Copy link
Contributor

geoand commented Oct 13, 2021

Seems like some of of glitch... Mind rebasing on main please?

@danielpetisme danielpetisme force-pushed the devservices-kafkastreams-toplogy-viewer branch from ccedcec to f8b89c5 Compare October 13, 2021 18:49
@quarkus-bot quarkus-bot bot added area/dependencies Pull requests that update a dependency file area/vertx labels Oct 13, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Oct 13, 2021

Failing Jobs - Building f8b89c5

Status Name Step Failures Logs Raw logs
✔️ JVM Tests - JDK 11
JVM Tests - JDK 11 Windows Upload gc.log ⚠️ Check → Logs Raw logs
✔️ JVM Tests - JDK 17
MicroProfile TCKs Tests Verify ⚠️ Check → Logs Raw logs

@geoand geoand merged commit d1f6536 into quarkusio:main Oct 14, 2021
@quarkus-bot quarkus-bot bot added this to the 2.5 - main milestone Oct 14, 2021
@quarkus-bot quarkus-bot bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Oct 14, 2021
@danielpetisme danielpetisme deleted the devservices-kafkastreams-toplogy-viewer branch October 14, 2021 08:18
@aloubyansky aloubyansky modified the milestones: 2.5 - main, 2.4.0.Final Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants