diff options
author | Sean Dague <sean@dague.net> | 2017-05-24 07:01:33 -0400 |
---|---|---|
committer | Sean Dague <sean@dague.net> | 2017-05-24 07:01:33 -0400 |
commit | cce83ad5e12baf2edc0e12c2944c587224e71148 (patch) | |
tree | 0dcf0a0312f5a2ae458f0d51033ab93688596e95 | |
parent | ec7cdc4cc560150673f14c84a326f6a72d43d3e1 (diff) | |
download | oslo-context-cce83ad5e12baf2edc0e12c2944c587224e71148.tar.gz |
Provide unified calling interface for global_id
Once we get to > 2 services chained, it's important that the caller
pass the global_request_id, not the local one. This provides a unified
property so that it's easy for callers to do the right thing.
Change-Id: I6c56187f776602e0af88a368e41a4239901bde3e
-rw-r--r-- | oslo_context/context.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/oslo_context/context.py b/oslo_context/context.py index c253b32..cc88ff6 100644 --- a/oslo_context/context.py +++ b/oslo_context/context.py @@ -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.""" |