diff options
author | Marcelo Martins <marcelo.martins@rackspace.com> | 2013-03-25 11:27:36 -0500 |
---|---|---|
committer | Marcelo Martins <marcelo.martins@rackspace.com> | 2013-04-10 06:37:32 -0500 |
commit | 1126e59c1242a8ea01ead5fe4b05330e47559fa5 (patch) | |
tree | b85d3c33ddfae1cc529c2c3025c3d90b50349cf4 /swift/common/middleware/catch_errors.py | |
parent | b115356af652c66b591827f86dda4680b9a9b75e (diff) | |
download | swift-1126e59c1242a8ea01ead5fe4b05330e47559fa5.tar.gz |
Adding a new optional variable called trans_id_suffix
The trans_id_suffix (default is empty) would be appended to the swift transaction
id allowing one to easily figure out from which cluster that X-Trans-Id
belongs to. This is very useful when one is managing more than one swift
cluster. Also updated sample and manpage to reflect the changes.
Change-Id: Icdf63643e9c1bde36a9ef5e3f41ee9fb20e55f5d
Diffstat (limited to 'swift/common/middleware/catch_errors.py')
-rw-r--r-- | swift/common/middleware/catch_errors.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/swift/common/middleware/catch_errors.py b/swift/common/middleware/catch_errors.py index 405382537..8159c4704 100644 --- a/swift/common/middleware/catch_errors.py +++ b/swift/common/middleware/catch_errors.py @@ -23,12 +23,13 @@ from swift.common.wsgi import WSGIContext class CatchErrorsContext(WSGIContext): - def __init__(self, app, logger): + def __init__(self, app, logger, trans_id_suffix=''): super(CatchErrorsContext, self).__init__(app) self.logger = logger + self.trans_id_suffix = trans_id_suffix def handle_request(self, env, start_response): - trans_id = 'tx' + uuid.uuid4().hex + trans_id = 'tx' + uuid.uuid4().hex + self.trans_id_suffix env['swift.trans_id'] = trans_id self.logger.txn_id = trans_id try: @@ -60,12 +61,15 @@ class CatchErrorMiddleware(object): def __init__(self, app, conf): self.app = app self.logger = get_logger(conf, log_route='catch-errors') + self.trans_id_suffix = conf.get('trans_id_suffix', '') def __call__(self, env, start_response): """ If used, this should be the first middleware in pipeline. """ - context = CatchErrorsContext(self.app, self.logger) + context = CatchErrorsContext(self.app, + self.logger, + self.trans_id_suffix) return context.handle_request(env, start_response) |