Log all transport actions

This patch adds debug LOG calls to the transport layer.

Implements blueprint production-logging

Change-Id: I43137ef4cff77ead9d5db931907952dc78a67157
This commit is contained in:
Flaper Fesp 2013-07-15 18:54:54 +02:00
parent 0b2af6828a
commit 423af0931c
5 changed files with 54 additions and 2 deletions

View File

@ -50,7 +50,8 @@ class Bootstrap(object):
invoke_on_load=True)
return mgr.driver
except RuntimeError as exc:
raise exceptions.InvalidDriver(exc)
LOG.exception(exc)
raise exceptions.InvalidDriver(exc)
@decorators.lazy_property(write=False)
def transport(self):
@ -62,7 +63,8 @@ class Bootstrap(object):
invoke_args=[self.storage])
return mgr.driver
except RuntimeError as exc:
raise exceptions.InvalidDriver(exc)
LOG.exception(exc)
raise exceptions.InvalidDriver(exc)
def run(self):
self.transport.listen()

View File

@ -17,8 +17,12 @@
from keystoneclient.middleware import auth_token
from marconi.openstack.common import log
STRATEGIES = {}
LOG = log.getLogger(__name__)
class KeystoneAuth(object):
@ -35,6 +39,7 @@ class KeystoneAuth(object):
@classmethod
def install(cls, app, conf):
"""Install Auth check on application."""
LOG.debug(_("Installing Keystone's auth protocol"))
cls._register_opts(conf)
conf = dict(conf.get(cls.OPT_GROUP_NAME))
return auth_token.AuthProtocol(app, conf=conf)

View File

@ -35,6 +35,9 @@ class CollectionResource(object):
self.claim_controller = claim_controller
def on_post(self, req, resp, project_id, queue_name):
LOG.debug(_("Claims collection POST - queue: %(queue)s, "
"project: %(project)s") %
{"queue": queue_name, "project": project_id})
# Check for an explicit limit on the # of messages to claim
limit = req.get_param_as_int('limit')
claim_options = {} if limit is None else {'limit': limit}
@ -87,6 +90,11 @@ class ItemResource(object):
self.claim_controller = claim_controller
def on_get(self, req, resp, project_id, queue_name, claim_id):
LOG.debug(_("Claim item GET - claim: %(claim_id)s, "
"queue: %(queue_name)s, project: %(project_id)s") %
{"queue_name": queue_name,
"project_id": project_id,
"claim_id": claim_id})
try:
meta, msgs = self.claim_controller.get(
queue_name,
@ -119,6 +127,11 @@ class ItemResource(object):
resp.status = falcon.HTTP_200
def on_patch(self, req, resp, project_id, queue_name, claim_id):
LOG.debug(_("Claim Item PATCH - claim: %(claim_id)s, "
"queue: %(queue_name)s, project:%(project_id)s") %
{"queue_name": queue_name,
"project_id": project_id,
"claim_id": claim_id})
# Read claim metadata (e.g., TTL) and raise appropriate
# HTTP errors as needed.
metadata, = wsgi_helpers.filter_stream(req.stream, req.content_length,
@ -140,6 +153,11 @@ class ItemResource(object):
raise wsgi_exceptions.HTTPServiceUnavailable(description)
def on_delete(self, req, resp, project_id, queue_name, claim_id):
LOG.debug(_("Claim item DELETE - claim: %(claim_id)s, "
"queue: %(queue_name)s, project: %(project_id)s") %
{"queue_name": queue_name,
"project_id": project_id,
"claim_id": claim_id})
try:
self.claim_controller.delete(queue_name,
claim_id=claim_id,

View File

@ -128,6 +128,10 @@ class CollectionResource(object):
#-----------------------------------------------------------------------
def on_post(self, req, resp, project_id, queue_name):
LOG.debug(_("Messages collection POST - queue: %(queue)s, "
"project: %(project)s") %
{"queue": queue_name, "project": project_id})
uuid = req.get_header('Client-ID', required=True)
# Pull out just the fields we care about
@ -187,6 +191,10 @@ class CollectionResource(object):
resp.body = helpers.to_json(body)
def on_get(self, req, resp, project_id, queue_name):
LOG.debug(_("Messages collection GET - queue: %(queue)s, "
"project: %(project)s") %
{"queue": queue_name, "project": project_id})
resp.content_location = req.relative_uri
ids = req.get_param_as_list('ids')
@ -211,6 +219,11 @@ class ItemResource(object):
self.message_controller = message_controller
def on_get(self, req, resp, project_id, queue_name, message_id):
LOG.debug(_("Messages item GET - message: %(message)s, "
"queue: %(queue)s, project: %(project)s") %
{"message": message_id,
"queue": queue_name,
"project": project_id})
try:
messages = self.message_controller.get(
queue_name,
@ -239,6 +252,11 @@ class ItemResource(object):
resp.status = falcon.HTTP_200
def on_delete(self, req, resp, project_id, queue_name, message_id):
LOG.debug(_("Messages item DELETE - message: %(message)s, "
"queue: %(queue)s, project: %(project)s") %
{"message": message_id,
"queue": queue_name,
"project": project_id})
try:
self.message_controller.delete(
queue_name,

View File

@ -53,6 +53,9 @@ class ItemResource(object):
#-----------------------------------------------------------------------
def on_put(self, req, resp, project_id, queue_name):
LOG.debug(_("Queue item PUT - queue: %(queue)s, "
"project: %(project)s") %
{"queue": queue_name, "project": project_id})
# TODO(kgriffs): Migrate this check to input validator middleware
if req.content_length > transport.MAX_QUEUE_METADATA_SIZE:
description = _('Queue metadata size is too large.')
@ -90,6 +93,9 @@ class ItemResource(object):
resp.location = req.path
def on_get(self, req, resp, project_id, queue_name):
LOG.debug(_("Queue item GET - queue: %(queue)s, "
"project: %(project)s") %
{"queue": queue_name, "project": project_id})
message_ids = req.get_param_as_list('ids')
if message_ids is None:
doc = self._get_metadata(project_id, queue_name)
@ -102,6 +108,9 @@ class ItemResource(object):
resp.body = helpers.to_json(doc)
def on_delete(self, req, resp, project_id, queue_name):
LOG.debug(_("Queue item DELETE - queue: %(queue)s, "
"project: %(project)s") %
{"queue": queue_name, "project": project_id})
try:
self.queue_controller.delete(queue_name, project=project_id)