Return a dictionary of {app_id: (app_name, tracking_url)} for running Spark applications.

def _mesos_init(self, instance, master_address, requests_config, tags):
        """
        Return a dictionary of {app_id: (app_name, tracking_url)} for running Spark applications.
        """
        running_apps = {}

        metrics_json = self._rest_request_to_json(
            master_address, MESOS_MASTER_APP_PATH, MESOS_SERVICE_CHECK, requests_config, tags
        )

        if metrics_json.get('frameworks'):
            for app_json in metrics_json.get('frameworks'):
                app_id = app_json.get('id')
                tracking_url = app_json.get('webui_url')
                app_name = app_json.get('name')

                if app_id and tracking_url and app_name:
                    spark_ports = instance.get('spark_ui_ports')
                    if spark_ports is None:
                        # No filtering by port, just return all the frameworks
                        running_apps[app_id] = (app_name, tracking_url)
                    else:
                        # Only return the frameworks running on the correct port
                        tracking_url_port = urlparse(tracking_url).port
                        if tracking_url_port in spark_ports:
                            running_apps[app_id] = (app_name, tracking_url)

        # Report success after gathering all metrics from ResourceManager
        self.service_check(
            MESOS_SERVICE_CHECK,
            AgentCheck.OK,
            tags=['url:%s' % master_address] + tags,
            message='Connection to ResourceManager "%s" was successful' % master_address,
        )

        return running_apps