Skip to content

Diagnostic tools

Guicey provide many bundled console reports to help with problems diagnostic (or to simply clarify how application works) during development. All reports may be enabled on main guice bundle:

.printExtensionsHelp()
Extensions recognition help
.printDiagnosticInfo()
Detailed guicey configuration information
.printAvailableInstallers()
Prints available installers (helps understanding supported extensions)
.printCustomConfigurationBindings()
.printConfigurationBindings()
Show yaml config introspection result (shows available yaml value bindings)
.printGuiceBindings()
.printAllGuiceBindings()
Guice bindings from registered modules
.printGuiceAopMap()
.printGuiceAopMap(GuiceAopConfig config)
AOP appliance map
.printWebMappings()
Prints all registered servlets and filters (including guice ServletModule declarations)
.printJerseyConfig()
Prints all registered jersey extensions (exception mappers, filters etc.): including everything registered by dropwizard itself and all direct manual registrations.
.printLifecyclePhases()
.printLifecyclePhasesDetailed()
Guicey lifecycle stages (separates logs to clearly see what messages relates to what phase)
.strictScopeControl()
In case of doubts about extension owner (guice or HK2) and suspicious for duplicate instantiation, you can enable strict control which will throw exception in case of wrong owner.

Diagnostic hook

It is obviously impossible to enable diagnostic reports without application re-compilation. But, sometimes, it is required to validate installed application. To work around this situation, guicey provides special diagnostic hook, which can be enabled with a system property:

-Dguicey.hooks=diagnostic

Hook activates the most commonly used reports:

public class DiagnosticHook implements GuiceyConfigurationHook {
    public void configure(final GuiceBundle.Builder builder) {
        builder.printDiagnosticInfo()
                .printLifecyclePhasesDetailed()
                .printCustomConfigurationBindings()
                .printGuiceBindings()
                .printWebMappings()
                .printJerseyConfig();
    }
}

Tip

If provided hook doesn't cover all required reports, you can always make your own hook and register it's shortcut for simplified usage

Reports implementation

Report is implemented as guicey event listener. All sub-reports provide additional configuration options, so if default configuration (from shortcut methods above) does not fit your needs you can register listener directly with required configuration.

For example, available installers report is re-configured configuration report:

public Builder<T> printAvailableInstallers() {
    return listen(ConfigurationDiagnostic.builder("Available installers report")
            .printConfiguration(new DiagnosticConfig()
                    .printInstallers()
                    .printNotUsedInstallers()
                    .printInstallerInterfaceMarkers())
            .printContextTree(new ContextTreeConfig()
                    .hideCommands()
                    .hideDuplicateRegistrations()
                    .hideEmptyBundles()
                    .hideExtensions()
                    .hideModules())
            .build());
}

Report rendering logic may also be used directly as all reports (except lifecycle) provide separate renderer object implementing ReportRenderer. Renderers not bound to guice context and assume direct instantiation.

For examples of direct renderers usage see events implementation:

  • RunPhaseEvent.renderConfigurationBindings()
  • InjectorPhaseEvent.ReportRenderer

Note

These shortcut methods allow easy render of report into string using received event object (in listener).