Skip to content

Commit a42413b

Browse files
authored
Don't report null values in json payloads (#113)
1 parent 6f10592 commit a42413b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

instana/agent.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ def start(self, e):
5050
instana.singletons.tracer.recorder.run()
5151

5252
def to_json(self, o):
53+
def extractor(o):
54+
return {k: v for k, v in o.__dict__.items() if v is not None}
55+
5356
try:
54-
return json.dumps(o, default=lambda o: {k.lower(): v for k, v in o.__dict__.items()},
55-
sort_keys=False, separators=(',', ':')).encode()
57+
return json.dumps(o, default=extractor, sort_keys=False, separators=(',', ':')).encode()
5658
except Exception as e:
57-
logger.info("to_json: ", e, o)
59+
logger.debug("to_json", exc_info=True)
5860

5961
def is_timed_out(self):
6062
if self.last_seen and self.can_send:

0 commit comments

Comments
 (0)