# Path: performanceplatform/utils/requests_with_backoff.py
# _MAX_RETRIES = 5
# def get(url, *args, **kwargs):
# def post(url, *args, **kwargs):
# def __request_with_backoff(method, url, *args, **kwargs):
# 
# Path: performanceplatform/collector/logging_setup.py
# def extra_fields_from_exception(exception):
#     """Exception into a dict to be passed to logger
# 
#     Standardise the way we send exception messages so they can be filtered in
#     kibana, also make it easy to add extra information in future.
#     """
#     return {
#         'exception_class': type(exception).__name__,
#         'exception_message': exception.message
#     }


from datetime import datetime
from performanceplatform.utils import requests_with_backoff
from performanceplatform.collector.logging_setup import (
    extra_fields_from_exception )
import pytz
import time
import logging
        response.raise_for_status()

        return response.json()

    def _build_response(self, data):
        hours = data['summary']['hours']
        new_hours = []
        for hour in hours:
            hour.update({'starttime': datetime.fromtimestamp(
                hour['starttime'],
                tz=pytz.UTC
            )})
            new_hours.append(hour)
        return new_hours

    def stats(self, check_name, start, end):
        app_code = self.check_id(check_name)
        params = {
            "includeuptime": "true",
            "from": time.mktime(start.timetuple()),
            "to": time.mktime(end.timetuple()),
            "resolution": "hour"
        }
        path = "summary.performance/" + str(app_code)

        try:
            return self._build_response(self._make_request(
                path=path,
                url_params=params
            ))

# Path: performanceplatform/utils/requests_with_backoff.py
# _MAX_RETRIES = 5
# def get(url, *args, **kwargs):
# def post(url, *args, **kwargs):
# def __request_with_backoff(method, url, *args, **kwargs):
# 
# Path: performanceplatform/collector/logging_setup.py
# def extra_fields_from_exception(exception):
#     """Exception into a dict to be passed to logger
# 
#     Standardise the way we send exception messages so they can be filtered in
#     kibana, also make it easy to add extra information in future.
#     """
#     return {
#         'exception_class': type(exception).__name__,
#         'exception_message': exception.message
#     }


# Path: performanceplatform/collector/pingdom/core.py
from datetime import datetime
from performanceplatform.utils import requests_with_backoff
from performanceplatform.collector.logging_setup import (
    extra_fields_from_exception )
import pytz
import time
import logging

        response.raise_for_status()

        return response.json()

    def _build_response(self, data):
        hours = data['summary']['hours']
        new_hours = []
        for hour in hours:
            hour.update({'starttime': datetime.fromtimestamp(
                hour['starttime'],
                tz=pytz.UTC
            )})
            new_hours.append(hour)
        return new_hours

    def stats(self, check_name, start, end):
        app_code = self.check_id(check_name)
        params = {
            "includeuptime": "true",
            "from": time.mktime(start.timetuple()),
            "to": time.mktime(end.timetuple()),
            "resolution": "hour"
        }
        path = "summary.performance/" + str(app_code)

        try:
            return self._build_response(self._make_request(
                path=path,
                url_params=params
            ))

        except requests_with_backoff.exceptions.HTTPError as e: