Skip to content

Instantly share code, notes, and snippets.

@kelapure
Created October 20, 2019 03:48
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kelapure/77954a9de988c2e511ec27675ee7e0a1 to your computer and use it in GitHub Desktop.
How to print the Topology of a KStream or a KTable when you have no access to the topology
private void print(Object stream) throws IllegalAccessException {
Field field = ReflectionUtils.findField(KStreamImpl.class, "builder");
ReflectionUtils.makeAccessible(field);
InternalStreamsBuilder builder = (InternalStreamsBuilder) field.get(stream);
field = ReflectionUtils.findField(InternalStreamsBuilder.class, "internalTopologyBuilder");
ReflectionUtils.makeAccessible(field);
InternalTopologyBuilder internalTopologyBuilder = (InternalTopologyBuilder)field.get(builder);
TopologyDescription topologyDescription = internalTopologyBuilder.describe();
logger.info("<TOPOLOGY> for "+ stream);
logger.info(topologyDescription.toString());
logger.info("</TOPOLOGY>");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment