Skip to content

michaelgantman/MgntUtilsUsage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MgntUtilsUsage

This repository contains several demos that demonstrate various features of Open Source MgntUtils library. At the moment this repo is work in progress. In particular, it is not well documented yet. However, if you are willing to dive into the code you will find some nice demos for several features.

I am working on the documentation though. So far, two features are better documented in this repo: Stacktrace Filtering and Extensible Multi-Stage Workflows for Multiple Data Types. The stacktrace-filtering integration is presented first because it is the easier, more immediately useful feature. The extensible-workflows infrastructure that follows is, however, the architecturally more significant of the two — built on top of MgntUtils's Self-populating Factory micro-framework — and is the one I would most want a serious architect to look at.

Stacktrace Filtering

This demo shows an infrastructure-level integration of the MgntUtils stacktrace filtering feature into a Spring Boot application. The integration:
  • Requires zero changes to application code — developers keep using their normal logger.error("...", e) calls.
  • Filters framework noise (Spring AOP, Hibernate, CGLIB proxies, reflection, Tomcat, Thread.run, etc.) out of every stacktrace logged by the application, leaving only application-level frames plus a single transition frame for context.
  • Works in both pattern-based logging (e.g. the default console output) and JSON-structured logging via LogstashEncoder. The second wiring is critical for any production system that ships logs to a structured-logging aggregator (ELK, Datadog, Splunk, OpenSearch, etc.) — and it's easy to miss, because LogstashEncoder bypasses the %ex conversion word entirely and would otherwise emit unfiltered stacktraces in production while the local dev console looks perfectly clean.
  • Includes a hot runtime toggle exposed via REST so an Admin or SRE user can turn the filtering on or off without a redeployment.

The full integration walkthrough is published as an article on dev.to, Medium, and LinkedIn: Zero-Code-Change Stacktrace Filtering for Spring Boot: An Infrastructure-Level Integration. For the algorithm itself (which is independent of any logging framework), see the earlier deep-dive Java Stacktrace Filtering Utility.

The relevant files in this repo are:

  • MgntStackTraceConverter.java — the custom Logback converter that runs every stacktrace through MgntUtils filtering. Includes a Throwable-catching guard around the filter call (because Logback's appender silently drops the entire log event if a converter throws) and a three-case fallback to standard Logback rendering so a stacktrace is never lost.
  • logback.xml — the configuration that wires the converter into both a pattern-based console appender and a JSON appender (LogstashEncoder via <throwableConverter>), plus all eight throwable conversion words (ex, exception, throwable, xEx, xException, xThrowable, wex, wEx) registered defensively so existing patterns Just Work without modification.
  • LoggerConfigController.java — the REST controller that exposes the hot runtime on/off toggle (/config/log/stacktrace and /config/log/stacktrace/filter/status).
  • StamBootApplication.java — calls TextUtils.setRelevantPackage("com.example.stamboot.") in main() before SpringApplication.run(...), so the filter is armed before any Spring lifecycle code (and therefore any startup-time crash) can run.
  • LogFilteringDemoController.java — the demo endpoint at /log that throws an exception with 50% probability so you can compare filtered vs unfiltered output by toggling the runtime flag and refreshing.

Extensible Multi-Stage Workflows for Multiple Data Types

A very in-depth article about how to use the Self-populating factory feature to build extensible Multi-Stage Workflows for multiple data types. The article covers:
  • How to design workflows that support new data types without modifying existing code
  • How to add and reorder processing stages independently
  • How to introduce conditional workflow logic without coupling stages or implementations
  • How self-populating factories eliminate switch statements, manual registries, and configuration overhead

The article at first explain in detail what is Self-populating factory pattern, including a walk-through a runnable example in the MgntUtils repo. After that it goes into detail how to build the workflow based on that pattern with a walk-through the runnable real world like example in this repo.
Here is the link to the article: Infrastructure for Extensible Multi-Stage Workflows Across Multiple Data Types Read it, and clone this repo and you will get good idea on how to build extensible, well designed (I hope) workflow, and run the example from this repo.

About

This repository contains a small SpringBoot app that is used to demonstrate some of the MgntUtils Open Source Library features

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages