Merge "statistics renamed to request_statistics"
This commit is contained in:
commit
976b6813e9
@ -14,7 +14,7 @@
|
||||
from sqlalchemy import desc
|
||||
from webob import exc
|
||||
|
||||
from muranoapi.api.v1 import statistics
|
||||
from muranoapi.api.v1 import request_statistics
|
||||
from muranoapi.common import utils
|
||||
from muranoapi.db import models
|
||||
from muranoapi.db import session as db_session
|
||||
@ -29,7 +29,7 @@ API_NAME = 'Deployments'
|
||||
|
||||
|
||||
class Controller(object):
|
||||
@statistics.stats_count(API_NAME, 'Index')
|
||||
@request_statistics.stats_count(API_NAME, 'Index')
|
||||
def index(self, request, environment_id):
|
||||
unit = db_session.get_session()
|
||||
verify_and_get_env(unit, environment_id, request)
|
||||
@ -41,7 +41,7 @@ class Controller(object):
|
||||
in result]
|
||||
return {'deployments': deployments}
|
||||
|
||||
@statistics.stats_count(API_NAME, 'Statuses')
|
||||
@request_statistics.stats_count(API_NAME, 'Statuses')
|
||||
def statuses(self, request, environment_id, deployment_id):
|
||||
unit = db_session.get_session()
|
||||
query = unit.query(models.Status) \
|
||||
|
@ -15,7 +15,7 @@
|
||||
from sqlalchemy import desc
|
||||
from webob import exc
|
||||
|
||||
from muranoapi.api.v1 import statistics
|
||||
from muranoapi.api.v1 import request_statistics
|
||||
from muranoapi.common import utils
|
||||
from muranoapi.db import models
|
||||
from muranoapi.db.services import core_services
|
||||
@ -33,7 +33,7 @@ API_NAME = 'Environments'
|
||||
|
||||
class Controller(object):
|
||||
|
||||
@statistics.stats_count(API_NAME, 'Index')
|
||||
@request_statistics.stats_count(API_NAME, 'Index')
|
||||
def index(self, request):
|
||||
LOG.debug(_('Environments:List'))
|
||||
|
||||
@ -44,7 +44,7 @@ class Controller(object):
|
||||
|
||||
return {"environments": environments}
|
||||
|
||||
@statistics.stats_count(API_NAME, 'Create')
|
||||
@request_statistics.stats_count(API_NAME, 'Create')
|
||||
def create(self, request, body):
|
||||
LOG.debug(_('Environments:Create <Body {0}>'.format(body)))
|
||||
|
||||
@ -53,7 +53,7 @@ class Controller(object):
|
||||
|
||||
return environment.to_dict()
|
||||
|
||||
@statistics.stats_count(API_NAME, 'Show')
|
||||
@request_statistics.stats_count(API_NAME, 'Show')
|
||||
def show(self, request, environment_id):
|
||||
LOG.debug(_('Environments:Show <Id: {0}>'.format(environment_id)))
|
||||
|
||||
@ -83,7 +83,7 @@ class Controller(object):
|
||||
|
||||
return env
|
||||
|
||||
@statistics.stats_count(API_NAME, 'Update')
|
||||
@request_statistics.stats_count(API_NAME, 'Update')
|
||||
def update(self, request, environment_id, body):
|
||||
LOG.debug(_('Environments:Update <Id: {0}, '
|
||||
'Body: {1}>'.format(environment_id, body)))
|
||||
@ -106,7 +106,7 @@ class Controller(object):
|
||||
|
||||
return environment.to_dict()
|
||||
|
||||
@statistics.stats_count(API_NAME, 'Delete')
|
||||
@request_statistics.stats_count(API_NAME, 'Delete')
|
||||
def delete(self, request, environment_id):
|
||||
LOG.debug(_('Environments:Delete <Id: {0}>'.format(environment_id)))
|
||||
|
||||
@ -126,7 +126,7 @@ class Controller(object):
|
||||
envs.EnvironmentServices.delete(environment_id,
|
||||
request.context.auth_token)
|
||||
|
||||
@statistics.stats_count(API_NAME, 'LastStatus')
|
||||
@request_statistics.stats_count(API_NAME, 'LastStatus')
|
||||
def last(self, request, environment_id):
|
||||
session_id = None
|
||||
if hasattr(request, 'context') and request.context.session:
|
||||
|
@ -20,7 +20,7 @@ from muranoapi.openstack.common import log as logging
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class StatisticsCollection(object):
|
||||
class RequestStatisticsCollection(object):
|
||||
request_count = 0
|
||||
error_count = 0
|
||||
average_time = 0.0
|
||||
@ -85,4 +85,4 @@ def update_error_count(api, method, ex_time, tenant=None):
|
||||
|
||||
def init_stats():
|
||||
if not v1.stats:
|
||||
v1.stats = StatisticsCollection()
|
||||
v1.stats = RequestStatisticsCollection()
|
@ -16,7 +16,7 @@ import functools as func
|
||||
from webob import exc
|
||||
|
||||
|
||||
from muranoapi.api.v1 import statistics
|
||||
from muranoapi.api.v1 import request_statistics
|
||||
from muranoapi.common.helpers import token_sanitizer
|
||||
from muranoapi.db.services import core_services
|
||||
from muranoapi.openstack.common.gettextutils import _ # noqa
|
||||
@ -44,7 +44,7 @@ def normalize_path(f):
|
||||
|
||||
|
||||
class Controller(object):
|
||||
@statistics.stats_count(API_NAME, 'Index')
|
||||
@request_statistics.stats_count(API_NAME, 'Index')
|
||||
@utils.verify_env
|
||||
@normalize_path
|
||||
def get(self, request, environment_id, path):
|
||||
@ -63,7 +63,7 @@ class Controller(object):
|
||||
raise exc.HTTPNotFound
|
||||
return result
|
||||
|
||||
@statistics.stats_count(API_NAME, 'Create')
|
||||
@request_statistics.stats_count(API_NAME, 'Create')
|
||||
@utils.verify_session
|
||||
@utils.verify_env
|
||||
@normalize_path
|
||||
@ -80,7 +80,7 @@ class Controller(object):
|
||||
raise exc.HTTPNotFound
|
||||
return result
|
||||
|
||||
@statistics.stats_count(API_NAME, 'Update')
|
||||
@request_statistics.stats_count(API_NAME, 'Update')
|
||||
@utils.verify_session
|
||||
@utils.verify_env
|
||||
@normalize_path
|
||||
@ -97,7 +97,7 @@ class Controller(object):
|
||||
raise exc.HTTPNotFound
|
||||
return result
|
||||
|
||||
@statistics.stats_count(API_NAME, 'Delete')
|
||||
@request_statistics.stats_count(API_NAME, 'Delete')
|
||||
@utils.verify_session
|
||||
@utils.verify_env
|
||||
@normalize_path
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
from webob import exc
|
||||
|
||||
from muranoapi.api.v1 import statistics
|
||||
from muranoapi.api.v1 import request_statistics
|
||||
from muranoapi.db import models
|
||||
from muranoapi.db.services import environments as envs
|
||||
from muranoapi.db.services import sessions
|
||||
@ -30,7 +30,7 @@ API_NAME = 'Sessions'
|
||||
|
||||
|
||||
class Controller(object):
|
||||
@statistics.stats_count(API_NAME, 'Create')
|
||||
@request_statistics.stats_count(API_NAME, 'Create')
|
||||
def configure(self, request, environment_id):
|
||||
LOG.debug(_('Session:Configure <EnvId: {0}>'.format(environment_id)))
|
||||
|
||||
@ -60,7 +60,7 @@ class Controller(object):
|
||||
|
||||
return session.to_dict()
|
||||
|
||||
@statistics.stats_count(API_NAME, 'Index')
|
||||
@request_statistics.stats_count(API_NAME, 'Index')
|
||||
def show(self, request, environment_id, session_id):
|
||||
LOG.debug(_('Session:Show <SessionId: {0}>'.format(session_id)))
|
||||
|
||||
@ -90,7 +90,7 @@ class Controller(object):
|
||||
|
||||
return session.to_dict()
|
||||
|
||||
@statistics.stats_count(API_NAME, 'Delete')
|
||||
@request_statistics.stats_count(API_NAME, 'Delete')
|
||||
def delete(self, request, environment_id, session_id):
|
||||
LOG.debug(_('Session:Delete <SessionId: {0}>'.format(session_id)))
|
||||
|
||||
@ -123,7 +123,7 @@ class Controller(object):
|
||||
|
||||
return None
|
||||
|
||||
@statistics.stats_count(API_NAME, 'Deploy')
|
||||
@request_statistics.stats_count(API_NAME, 'Deploy')
|
||||
def deploy(self, request, environment_id, session_id):
|
||||
LOG.debug(_('Session:Deploy <SessionId: {0}>'.format(session_id)))
|
||||
|
||||
|
@ -26,7 +26,7 @@ root = os.path.join(os.path.abspath(__file__), os.pardir, os.pardir, os.pardir)
|
||||
if os.path.exists(os.path.join(root, 'muranoapi', '__init__.py')):
|
||||
sys.path.insert(0, root)
|
||||
|
||||
from muranoapi.api.v1 import statistics
|
||||
from muranoapi.api.v1 import request_statistics
|
||||
from muranoapi.common import config
|
||||
from muranoapi.common import server
|
||||
from muranoapi.common import statservice as stats
|
||||
@ -39,7 +39,7 @@ def main():
|
||||
try:
|
||||
config.parse_args()
|
||||
log.setup('muranoapi')
|
||||
statistics.init_stats()
|
||||
request_statistics.init_stats()
|
||||
|
||||
launcher = service.ServiceLauncher()
|
||||
|
||||
|
@ -18,7 +18,7 @@ import socket
|
||||
import time
|
||||
|
||||
from muranoapi.api import v1
|
||||
from muranoapi.api.v1 import statistics
|
||||
from muranoapi.api.v1 import request_statistics
|
||||
from muranoapi.common import config
|
||||
|
||||
from muranoapi.db.services import stats as db_stats
|
||||
@ -34,7 +34,7 @@ LOG = logging.getLogger(__name__)
|
||||
class StatsCollectingService(service.Service):
|
||||
def __init__(self):
|
||||
super(StatsCollectingService, self).__init__()
|
||||
statistics.init_stats()
|
||||
request_statistics.init_stats()
|
||||
self._hostname = socket.gethostname()
|
||||
self._stats_db = db_stats.Statistics()
|
||||
self._prev_time = time.time()
|
||||
|
Loading…
Reference in New Issue
Block a user