(self, running_apps, addl_tags)
Get metrics for each Spark executor.
Get metrics for each Spark executor.
Get metrics for each Spark executor .
def _spark_executor_metrics(self, running_apps, addl_tags):
        """
        Get metrics for each Spark executor.
        """
        for app_id, (app_name, tracking_url) in iteritems(running_apps):

            base_url = self._get_request_url(tracking_url)
            response = self._rest_request_to_json(
                base_url, SPARK_APPS_PATH, SPARK_SERVICE_CHECK, addl_tags, app_id, 'executors'
            )

            tags = ['app_name:%s' % str(app_name)]
            tags.extend(addl_tags)

            for executor in response:
                if executor.get('id') == 'driver':
                    self._set_metrics_from_json(tags, executor, SPARK_DRIVER_METRICS)
                else:
                    self._set_metrics_from_json(tags, executor, SPARK_EXECUTOR_METRICS)

                    if is_affirmative(self.instance.get('executor_level_metrics', False)):
                        self._set_metrics_from_json(
                            tags + ['executor_id:{}'.format(executor.get('id', 'unknown'))],
                            executor,
                            SPARK_EXECUTOR_LEVEL_METRICS,
                        )

            if len(response):
                self._set_metric('spark.executor.count', COUNT, len(response), tags)
def _spark_executor_metrics ( self , running_apps , addl_tags ) : for app_id , ( app_name , tracking_url ) in iteritems ( running_apps ) : base_url = self . _get_request_url ( tracking_url ) response = self . _rest_request_to_json ( base_url , SPARK_APPS_PATH , SPARK_SERVICE_CHECK , addl_tags , app_id , 'executors' ) tags = [ 'app_name:%s' % str ( app_name ) ] tags . extend ( addl_tags ) for executor in response : if executor . get ( 'id' ) == 'driver' : self . _set_metrics_from_json ( tags , executor , SPARK_DRIVER_METRICS ) else : self . _set_metrics_from_json ( tags , executor , SPARK_EXECUTOR_METRICS ) if is_affirmative ( self . instance . get ( 'executor_level_metrics' , False ) ) : self . _set_metrics_from_json ( tags + [ 'executor_id:{}' . format ( executor . get ( 'id' , 'unknown' ) ) ] , executor , SPARK_EXECUTOR_LEVEL_METRICS , ) if len ( response ) : self . _set_metric ( 'spark.executor.count' , COUNT , len ( response ) , tags )