Skip to content

Commit

Permalink
spid as int
Browse files Browse the repository at this point in the history
  • Loading branch information
nenadnoveljic committed Sep 19, 2024
1 parent c75fdc1 commit 6abe1f3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions sqlserver/datadog_checks/sqlserver/deadlocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ def _obfuscate_xml(self, root):
inputbuf.text = self.obfuscate_no_except_wrapper(inputbuf.text)
spid = process.get('spid')
if spid is not None:
try:
spid = int(spid)
except ValueError:
self._log.error("spid not an integer. Skipping query signature computation.")
continue
if spid in query_signatures:
continue
query_signatures.append({"spid": spid, "signature": compute_sql_signature(inputbuf.text)})
Expand Down
4 changes: 3 additions & 1 deletion sqlserver/tests/test_deadlocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,6 @@ def test__create_deadlock_rows():
row = rows[0]
query_signatures = row["query_signatures"]
assert len(query_signatures) == 2, "Should have two query signatures"
assert "spid" in query_signatures[0], "Should have spid in query signatures"
first_mapping = query_signatures[0]
assert "spid" in first_mapping, "Should have spid in query signatures"
assert isinstance(first_mapping["spid"], int), "spid should be an int"

0 comments on commit 6abe1f3

Please sign in to comment.