perforce / p4prometheus

[Community Supported] Perforce (Helix Core) interface for writing Prometheus metrics from real-time analysis of p4d log files.
MIT License
45 stars 24 forks source link

monitor_metrics.py | UnboundLocalError: local variable 'belapsed' referenced before assignment #63

Open D0cR3d opened 1 week ago

D0cR3d commented 1 week ago

In the script monitor_metrics.py there is a bug where belapsed can be referenced before a value has been assigned.

Stacktrace ( Link to current LOC )

Traceback (most recent call last):
  File "/p4/common/site/bin/monitor_metrics.py", line 473, in <module>
    obj.run()
  File "/p4/common/site/bin/monitor_metrics.py", line 462, in run
    metrics = self.findLocks(lockdata, mondata)
  File "/p4/common/site/bin/monitor_metrics.py", line 290, in findLocks
    metrics.blockingCommands[bpid] = Blocker(bpid, buser, bcmd, belapsed)
UnboundLocalError: local variable 'belapsed' referenced before assignment

I believe all that needs to be done is on line 285 is just change it to the following defining it as unknown:

buser, bcmd, bargs, belapsed = "unknown", "unknown", "unknown", "unknown"