Merge "Provide unified calling interface for global_id"

This commit is contained in:
Jenkins 2017-05-24 14:27:07 +00:00 committed by Gerrit Code Review
commit 79d81f62e7
1 changed files with 10 additions and 0 deletions

View File

@ -345,6 +345,16 @@ class RequestContext(object):
values.update(self.to_dict())
return values
@property
def global_id(self):
"""Return a sensible value for global_id to pass on.
When we want to make a call with to another service, it's
important that we try to use global_request_id if available,
and fall back to the locally generated request_id if not.
"""
return self.global_request_id or self.request_id
@classmethod
def from_dict(cls, values, **kwargs):
"""Construct a context object from a provided dictionary."""