Permalink
Browse files

Fix KeyError when checking kwargs for optional values

  • Loading branch information...
1 parent 458fda0 commit 0c6c6317092f8370462d5f8416558c59638e8cbf @yurishkuro yurishkuro committed Oct 3, 2016
Showing with 5 additions and 3 deletions.
  1. +2 −0 opentracing/harness/api_check.py
  2. +3 −3 opentracing/span.py
@@ -126,6 +126,8 @@ def test_span_logs(self):
log_event('defrosted', {'year': 2999}). \
log_event('became his own grandfather', 1947)
span.\
+ log(event='frozen'). \
+ log(payload={'year': 1999}). \
log(timestamp=time.time(),
event='frozen',
payload={'year': 1999}). \
View
@@ -218,11 +218,11 @@ def log_event(self, event, payload=None):
def log(self, **kwargs):
"""DEPRECATED"""
key_values = {}
- if kwargs['event'] is not None:
+ if 'event' in kwargs:
key_values['event'] = kwargs['event']
- if kwargs['payload'] is not None:
+ if 'payload' in kwargs:
key_values['payload'] = kwargs['payload']
timestamp = None
- if kwargs['timestamp'] is not None:
+ if 'timestamp' in kwargs:
timestamp = kwargs['timestamp']
return self.log_kv(key_values, timestamp)

0 comments on commit 0c6c631

Please sign in to comment.