(self, instance, init_config)
return gitlab_runner_instance
Set up the gitlab_runner instance so it can be used in OpenMetricsBaseCheck
Set up the gitlab_runner instance so it can be used in OpenMetricsBaseCheck
Set up the gitlab_runner instance so it can be used in OpenMetricsBaseCheck
def _create_gitlab_runner_prometheus_instance(self, instance, init_config):
        """
        Set up the gitlab_runner instance so it can be used in OpenMetricsBaseCheck
        """
        # Mapping from Prometheus metrics names to Datadog ones
        # For now it's a 1:1 mapping
        allowed_metrics = init_config.get('allowed_metrics')
        if allowed_metrics is None:
            raise CheckException("At least one metric must be whitelisted in `allowed_metrics`.")

        # Users may want to only report the version
        # OpenMetricsCheck doesn't allow the metadata_metric_name to be one of the metrics
        if 'ci_runner_version_info' in allowed_metrics:
            allowed_metrics.remove('ci_runner_version_info')

        gitlab_runner_instance = deepcopy(instance)

        # gitlab_runner uses 'prometheus_endpoint' and not 'prometheus_url', so we have to rename the key
        gitlab_runner_instance['prometheus_url'] = instance.get('prometheus_endpoint', None)

        gitlab_runner_instance.update(
            {
                'namespace': 'gitlab_runner',
                'metrics': allowed_metrics,
                # Defaults that were set when gitlab_runner was based on PrometheusCheck
                'send_monotonic_counter': instance.get('send_monotonic_counter', False),
                'health_service_check': instance.get('health_service_check', False),
                'metadata_metric_name': 'ci_runner_version_info',
                'metadata_label_map': {'version': 'version'},
            }
        )

        return gitlab_runner_instance
def _create_gitlab_runner_prometheus_instance ( self , instance , init_config ) : # Mapping from Prometheus metrics names to Datadog ones # For now it's a 1:1 mapping allowed_metrics = init_config . get ( 'allowed_metrics' ) if allowed_metrics is None : raise CheckException ( "At least one metric must be whitelisted in `allowed_metrics`." ) # Users may want to only report the version # OpenMetricsCheck doesn't allow the metadata_metric_name to be one of the metrics if 'ci_runner_version_info' in allowed_metrics : allowed_metrics . remove ( 'ci_runner_version_info' ) gitlab_runner_instance = deepcopy ( instance ) # gitlab_runner uses 'prometheus_endpoint' and not 'prometheus_url', so we have to rename the key gitlab_runner_instance [ 'prometheus_url' ] = instance . get ( 'prometheus_endpoint' , None ) gitlab_runner_instance . update ( { 'namespace' : 'gitlab_runner' , 'metrics' : allowed_metrics , # Defaults that were set when gitlab_runner was based on PrometheusCheck 'send_monotonic_counter' : instance . get ( 'send_monotonic_counter' , False ) , 'health_service_check' : instance . get ( 'health_service_check' , False ) , 'metadata_metric_name' : 'ci_runner_version_info' , 'metadata_label_map' : { 'version' : 'version' } , } ) return gitlab_runner_instance