High-level:
Given what I'm trying to do, my question are:
Already Tried:
Here's the instrumentation and placement into tuple:
multicast_sequence_problem_total = Counter(
"multicast_sequence_problem_total",
"Total of Sequence Errors (Multicast)",
['source_dc', 'destination_dc', 'vlan']
),
unicast_sequence_problem_total = Counter(
"unicast_sequence_problem_total",
"Total of Sequence Errors (Unicast)",
['source_dc', 'destination_dc', 'vlan']
),
multicast_duplicate_total = Counter(
"multicast_duplicate_total",
"Total of Duplicate Sequences (Multicast)",
['source_dc', 'destination_dc', 'vlan']
),
unicast_duplicate_total = Counter(
"unicast_duplicate_total",
"Total of Duplicate Sequences (Unicast)",
['source_dc', 'destination_dc', 'vlan']
)
latency_gauge = Gauge(
"latency_average_gauge",
"Latency Average",
['protocol', 'source_dc', 'destination_dc', 'vlan']
)
metrics = (
multicast_sequence_problem_total,
multicast_duplicate_total,
unicast_sequence_problem_total,
unicast_duplicate_total,
latency_gauge
)
Skip to my other function where I actually increment / set the metric values -- here's the unpack:
mcast_seq, mcast_dup, uni_seq, uni_dup, avg_latency = metrics_tuple
Went in with pdb in order to debug, and found that 3 of the 5 metrics are actually type: tuple:
(Pdb) type(metrics_tuple)
<class 'tuple'>
(Pdb) type(avg_latency)
<class 'prometheus_client.metrics.Gauge'>
(Pdb) type(mcast_seq)
<class 'tuple'>
(Pdb) type(mcast_dup)
<class 'tuple'>
(Pdb) type(uni_seq)
<class 'tuple'>
(Pdb) type(uni_dup)
<class 'prometheus_client.metrics.Counter'>
(Pdb)
So this is causing some errors when I get farther along in my code. Python thinks I'm trying to unpack in other places (where I'm not expecting a tuple!)
Discovered the answer after using a dictionary rather than tuple. My metrics objects were tuples, and the reason is that I forgot to remove some commas between the metrics where they're instrumented.
That only would have made sense if I instrumented while instantiating the dictionary or tuple all at the same time (which I didn't).
(facepalm) -- Took a while to figure out, but the pdb output saved me. Showed me that only some of the metrics were tuples, not all of them. Seeking out the difference between them led me to the answer.