Skip to content

Commit

Permalink
improve decode error handling further
Browse files Browse the repository at this point in the history
Return empty result in case of decode error.
Also print the raw socket diag result.
  • Loading branch information
cherusk committed Nov 24, 2023
1 parent 784df81 commit 48ff746
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions prometheus_ss_exporter/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ def provide_tcp_stats(self):

self._reset_io()

sk_stats_parsed = dict()
sk_stats_parsed = dict(TCP=dict(flows=list()))
try:
sk_stats_parsed = json.loads(sk_stats_raw)
except json.decoder.JSONDecodeError as err:
logging.error("Failed parsing sample")
logging.error("-----")
logging.error(sk_stats_parsed)
logging.error(sk_stats_raw)
logging.error("-----")

return sk_stats_parsed
Expand Down

0 comments on commit 48ff746

Please sign in to comment.