Merge pull request #17 from tcivie/update-metrics

Update metrics + Fix bug with parsing of client roles and device information
This commit is contained in:
Gleb Tcivie 2024-07-03 11:22:37 +03:00 committed by GitHub
commit 05e6354260
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View file

@ -24,7 +24,7 @@ class ClientDetails:
def get_role_name_from_role(role):
descriptor = Config.DeviceConfig.Role.DESCRIPTOR
for enum_value in descriptor.values:
if enum_value.number == role:
if enum_value.number == role or enum_value.name == role:
return enum_value.name
return 'UNKNOWN_ROLE'
@ -32,6 +32,6 @@ class ClientDetails:
def get_hardware_model_name_from_code(hardware_model):
descriptor = HardwareModel.DESCRIPTOR
for enum_value in descriptor.values:
if enum_value.number == hardware_model:
if enum_value.number == hardware_model or enum_value.name == hardware_model:
return enum_value.name
return 'UNKNOWN_HARDWARE_MODEL'

View file

@ -20,7 +20,7 @@ class MessageProcessor:
self.hop_start_gauge = None
self.via_mqtt_counter = None
self.want_ack_counter = None
self.hop_limit_counter = None
self.hop_limit_gauge = None
self.rx_snr_gauge = None
self.rx_time_histogram = None
self.total_packets_counter = None
@ -73,7 +73,7 @@ class MessageProcessor:
registry=self.registry
)
# Counter for hop_limit
self.hop_limit_counter = Counter(
self.hop_limit_gauge = Gauge(
'mesh_packet_hop_limit',
'Hop limit of mesh packets',
common_labels,
@ -205,9 +205,9 @@ class MessageProcessor:
**common_labels
).set(mesh_packet.rx_snr)
self.hop_limit_counter.labels(
self.hop_limit_gauge.labels(
**common_labels
).inc(mesh_packet.hop_limit)
).set(mesh_packet.hop_limit)
if mesh_packet.want_ack:
self.want_ack_counter.labels(