mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-04-28 03:20:11 +00:00
fix: add mutex to prevent concurrent map writes in Docker agent CPU tracking
The agent was crashing with 'fatal error: concurrent map writes' when handleCheckUpdatesCommand spawned a goroutine that called collectOnce concurrently with the main collection loop. Both code paths access a.prevContainerCPU without synchronization. Added a.cpuMu mutex to protect all accesses to prevContainerCPU in: - pruneStaleCPUSamples() - collectContainer() delete operation - calculateContainerCPUPercent() Related to #1063
This commit is contained in:
parent
a7de907c35
commit
035436ad6e
61 changed files with 7062 additions and 2625 deletions
56
analyze_coverage.py
Normal file
56
analyze_coverage.py
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
|
||||
import sys
|
||||
import os
|
||||
|
||||
def parse_coverage(filename):
|
||||
if not os.path.exists(filename):
|
||||
print(f"File {filename} not found")
|
||||
return
|
||||
|
||||
package_stmts = {}
|
||||
package_covered = {}
|
||||
|
||||
with open(filename, 'r') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
current_mode = ""
|
||||
for line in lines:
|
||||
if line.startswith("mode:"):
|
||||
current_mode = line.split()[1]
|
||||
continue
|
||||
|
||||
parts = line.strip().split(':')
|
||||
if len(parts) != 2:
|
||||
continue
|
||||
|
||||
file_path = parts[0]
|
||||
# Package is directory of file_path
|
||||
package_name = os.path.dirname(file_path)
|
||||
|
||||
metrics = parts[1].split()
|
||||
if len(metrics) != 3:
|
||||
continue
|
||||
|
||||
# start_end = metrics[0]
|
||||
num_stmts = int(metrics[1])
|
||||
count = int(metrics[2])
|
||||
|
||||
package_stmts[package_name] = package_stmts.get(package_name, 0) + num_stmts
|
||||
if count > 0:
|
||||
package_covered[package_name] = package_covered.get(package_name, 0) + num_stmts
|
||||
|
||||
results = []
|
||||
for pkg, total in package_stmts.items():
|
||||
covered = package_covered.get(pkg, 0)
|
||||
percent = (covered / total) * 100 if total > 0 else 0
|
||||
results.append((pkg, percent, covered, total))
|
||||
|
||||
# Sort by percentage (ascending)
|
||||
results.sort(key=lambda x: x[1])
|
||||
|
||||
print("Package Coverage Report (Bottom 20):")
|
||||
for pkg, pct, cov, tot in results[:20]:
|
||||
print(f"{pct:6.2f}% ({cov}/{tot}) {pkg}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
parse_coverage("coverage.out")
|
||||
Loading…
Add table
Add a link
Reference in a new issue