Function addDiagnosticsHandler