'Initialize a new check.
:param name: The name of the check
:param init_config: The config for initializing the check
:param agentConfig: The global configuration for the agent
:param instances: A list of configuration objects for each instance.'

def __init__(self, name, init_config, agentConfig, instances=None):

    from aggregator import MetricsAggregator
    self._enabled_checks.append(name)
    self._enabled_checks = list(set(self._enabled_checks))
    self.name = name
    self.init_config = (init_config or {})
    self.agentConfig = agentConfig
    self.in_developer_mode = (agentConfig.get('developer_mode') and psutil)
    self._internal_profiling_stats = None
    self.allow_profiling = self.agentConfig.get('allow_profiling', True)
    self.default_integration_http_timeout = float(agentConfig.get('default_integration_http_timeout', 9))
    self.hostname = (agentConfig.get('checksd_hostname') or get_hostname(agentConfig))
    self.log = logging.getLogger(('%s.%s' % (__name__, name)))
    self.min_collection_interval = self.init_config.get('min_collection_interval', self.DEFAULT_MIN_COLLECTION_INTERVAL)
    self.aggregator = MetricsAggregator(self.hostname, expiry_seconds=(self.min_collection_interval + self.DEFAULT_EXPIRY_SECONDS), formatter=agent_formatter, recent_point_threshold=agentConfig.get('recent_point_threshold', None), histogram_aggregates=agentConfig.get('histogram_aggregates'), histogram_percentiles=agentConfig.get('histogram_percentiles'))
    self.events = []
    self.service_checks = []
    self.instances = (instances or [])
    self.warnings = []
    self.check_version = None
    self.library_versions = None
    self.last_collection_time = defaultdict(int)
    self._instance_metadata = []
    self.svc_metadata = []
    self.historate_dict = {}
    self.manifest_path = None
    self.proxy_settings = get_proxy(self.agentConfig)
    self._use_proxy = (False if (init_config is None) else init_config.get('use_agent_proxy', True))
    self.proxies = {'http': None, 'https': None}
    if (self.proxy_settings and self._use_proxy):
        uri = '{host}:{port}'.format(host=self.proxy_settings['host'], port=self.proxy_settings['port'])
        if (self.proxy_settings['user'] and self.proxy_settings['password']):
            uri = '{user}:{password}@{uri}'.format(user=self.proxy_settings['user'], password=self.proxy_settings['password'], uri=uri)
        self.proxies['http'] = 'http://{uri}'.format(uri=uri)
        self.proxies['https'] = 'https://{uri}'.format(uri=uri)
