@@ -61,6 +61,30 @@ var _ = Describe("FactoryBuildingCollector", func() {
6161 PowerConsumed : 23 ,
6262 MaxPowerConsumed : 4 ,
6363 },
64+ InputInventory : []exporter.InventoryItem {
65+ {
66+ Name : "Iron Ore" ,
67+ Amount : 64 ,
68+ MaxAmount : 100 ,
69+ },
70+ {
71+ Name : "Second input" ,
72+ Amount : 32 ,
73+ MaxAmount : 1000 ,
74+ },
75+ },
76+ OutputInventory : []exporter.InventoryItem {
77+ {
78+ Name : "Iron Ingot" ,
79+ Amount : 33 ,
80+ MaxAmount : 200 ,
81+ },
82+ {
83+ Name : "Second output" ,
84+ Amount : 44 ,
85+ MaxAmount : 2000 ,
86+ },
87+ },
6488 },
6589 })
6690 })
@@ -112,6 +136,161 @@ var _ = Describe("FactoryBuildingCollector", func() {
112136 })
113137 })
114138
139+ Describe ("Machine item max production metrics" , func () {
140+ It ("records a metric with labels for the produced item name, machine type, and x, y, z coordinates" , func () {
141+ collector .Collect (url , sessionName )
142+ metric , err := getMetric (exporter .MachineItemsProducedMax , "Iron Ingot" , "Smelter" , "100" , "200" , "-300" , url , sessionName )
143+ Expect (err ).ToNot (HaveOccurred ())
144+ Expect (metric ).ToNot (BeNil ())
145+ })
146+
147+ It ("records the current max production as the metric value" , func () {
148+ collector .Collect (url , sessionName )
149+
150+ val , err := gaugeValue (exporter .MachineItemsProducedMax , "Iron Ingot" , "Smelter" , "100" , "200" , "-300" , url , sessionName )
151+ Expect (err ).ToNot (HaveOccurred ())
152+ Expect (val ).To (Equal (float64 (10 )))
153+ })
154+
155+ Describe ("when a machine has multiple outputs" , func () {
156+ It ("records a metric per item" , func () {
157+ collector .Collect (url , sessionName )
158+
159+ ironIngots , err := gaugeValue (exporter .MachineItemsProducedMax , "Iron Ingot" , "Smelter" , "100" , "200" , "-300" , url , sessionName )
160+ Expect (err ).ToNot (HaveOccurred ())
161+ Expect (ironIngots ).To (Equal (float64 (10.0 )))
162+
163+ ironNothing , err := gaugeValue (exporter .MachineItemsProducedMax , "Iron Nothing" , "Smelter" , "100" , "200" , "-300" , url , sessionName )
164+ Expect (err ).ToNot (HaveOccurred ())
165+ Expect (ironNothing ).To (Equal (float64 (4000.0 )))
166+ })
167+ })
168+ })
169+
170+ Describe ("Machine input inventory metrics" , func () {
171+ It ("records a metric with labels for the stored item name, machine type, and x, y, z coordinates" , func () {
172+ collector .Collect (url , sessionName )
173+ metric , err := getMetric (exporter .MachineInputInventory , "Iron Ore" , "Smelter" , "100" , "200" , "-300" , url , sessionName )
174+ Expect (err ).ToNot (HaveOccurred ())
175+ Expect (metric ).ToNot (BeNil ())
176+ })
177+
178+ It ("records the current input invetory as the metric value" , func () {
179+ collector .Collect (url , sessionName )
180+
181+ val , err := gaugeValue (exporter .MachineInputInventory , "Iron Ore" , "Smelter" , "100" , "200" , "-300" , url , sessionName )
182+ Expect (err ).ToNot (HaveOccurred ())
183+ Expect (val ).To (Equal (float64 (64.0 )))
184+ })
185+
186+ Describe ("when a machine has multiple inputs" , func () {
187+ It ("records a metric per item" , func () {
188+ collector .Collect (url , sessionName )
189+
190+ ironIngots , err := gaugeValue (exporter .MachineInputInventory , "Iron Ore" , "Smelter" , "100" , "200" , "-300" , url , sessionName )
191+ Expect (err ).ToNot (HaveOccurred ())
192+ Expect (ironIngots ).To (Equal (float64 (64.0 )))
193+
194+ ironNothing , err := gaugeValue (exporter .MachineInputInventory , "Second input" , "Smelter" , "100" , "200" , "-300" , url , sessionName )
195+ Expect (err ).ToNot (HaveOccurred ())
196+ Expect (ironNothing ).To (Equal (float64 (32.0 )))
197+ })
198+ })
199+ })
200+
201+ Describe ("Machine input inventory max metrics" , func () {
202+ It ("records a metric with labels for the stored item name, machine type, and x, y, z coordinates" , func () {
203+ collector .Collect (url , sessionName )
204+ metric , err := getMetric (exporter .MachineInputInventoryMax , "Iron Ore" , "Smelter" , "100" , "200" , "-300" , url , sessionName )
205+ Expect (err ).ToNot (HaveOccurred ())
206+ Expect (metric ).ToNot (BeNil ())
207+ })
208+
209+ It ("records the current input invetory max as the metric value" , func () {
210+ collector .Collect (url , sessionName )
211+
212+ val , err := gaugeValue (exporter .MachineInputInventoryMax , "Iron Ore" , "Smelter" , "100" , "200" , "-300" , url , sessionName )
213+ Expect (err ).ToNot (HaveOccurred ())
214+ Expect (val ).To (Equal (float64 (100.0 )))
215+ })
216+
217+ Describe ("when a machine has multiple inputs" , func () {
218+ It ("records a metric per item" , func () {
219+ collector .Collect (url , sessionName )
220+
221+ ironIngots , err := gaugeValue (exporter .MachineInputInventoryMax , "Iron Ore" , "Smelter" , "100" , "200" , "-300" , url , sessionName )
222+ Expect (err ).ToNot (HaveOccurred ())
223+ Expect (ironIngots ).To (Equal (float64 (100.0 )))
224+
225+ ironNothing , err := gaugeValue (exporter .MachineInputInventoryMax , "Second input" , "Smelter" , "100" , "200" , "-300" , url , sessionName )
226+ Expect (err ).ToNot (HaveOccurred ())
227+ Expect (ironNothing ).To (Equal (float64 (1000.0 )))
228+ })
229+ })
230+ })
231+
232+ Describe ("Machine input inventory metrics" , func () {
233+ It ("records a metric with labels for the stored item name, machine type, and x, y, z coordinates" , func () {
234+ collector .Collect (url , sessionName )
235+ metric , err := getMetric (exporter .MachineInputInventory , "Iron Ingot" , "Smelter" , "100" , "200" , "-300" , url , sessionName )
236+ Expect (err ).ToNot (HaveOccurred ())
237+ Expect (metric ).ToNot (BeNil ())
238+ })
239+
240+ It ("records the current output invetory as the metric value" , func () {
241+ collector .Collect (url , sessionName )
242+
243+ val , err := gaugeValue (exporter .MachineOutputInventory , "Iron Ingot" , "Smelter" , "100" , "200" , "-300" , url , sessionName )
244+ Expect (err ).ToNot (HaveOccurred ())
245+ Expect (val ).To (Equal (float64 (33.0 )))
246+ })
247+
248+ Describe ("when a machine has multiple outputs" , func () {
249+ It ("records a metric per item" , func () {
250+ collector .Collect (url , sessionName )
251+
252+ ironIngots , err := gaugeValue (exporter .MachineOutputInventory , "Iron Ingot" , "Smelter" , "100" , "200" , "-300" , url , sessionName )
253+ Expect (err ).ToNot (HaveOccurred ())
254+ Expect (ironIngots ).To (Equal (float64 (33.0 )))
255+
256+ ironNothing , err := gaugeValue (exporter .MachineOutputInventory , "Second output" , "Smelter" , "100" , "200" , "-300" , url , sessionName )
257+ Expect (err ).ToNot (HaveOccurred ())
258+ Expect (ironNothing ).To (Equal (float64 (44.0 )))
259+ })
260+ })
261+ })
262+
263+ Describe ("Machine output inventory max metrics" , func () {
264+ It ("records a metric with labels for the stored item name, machine type, and x, y, z coordinates" , func () {
265+ collector .Collect (url , sessionName )
266+ metric , err := getMetric (exporter .MachineOutputInventoryMax , "Iron Ingot" , "Smelter" , "100" , "200" , "-300" , url , sessionName )
267+ Expect (err ).ToNot (HaveOccurred ())
268+ Expect (metric ).ToNot (BeNil ())
269+ })
270+
271+ It ("records the current output invetory max as the metric value" , func () {
272+ collector .Collect (url , sessionName )
273+
274+ val , err := gaugeValue (exporter .MachineOutputInventoryMax , "Iron Ingot" , "Smelter" , "100" , "200" , "-300" , url , sessionName )
275+ Expect (err ).ToNot (HaveOccurred ())
276+ Expect (val ).To (Equal (float64 (200.0 )))
277+ })
278+
279+ Describe ("when a machine has multiple outputs" , func () {
280+ It ("records a metric per item" , func () {
281+ collector .Collect (url , sessionName )
282+
283+ ironIngots , err := gaugeValue (exporter .MachineOutputInventoryMax , "Iron Ingot" , "Smelter" , "100" , "200" , "-300" , url , sessionName )
284+ Expect (err ).ToNot (HaveOccurred ())
285+ Expect (ironIngots ).To (Equal (float64 (200.0 )))
286+
287+ ironNothing , err := gaugeValue (exporter .MachineOutputInventoryMax , "Second output" , "Smelter" , "100" , "200" , "-300" , url , sessionName )
288+ Expect (err ).ToNot (HaveOccurred ())
289+ Expect (ironNothing ).To (Equal (float64 (2000.0 )))
290+ })
291+ })
292+ })
293+
115294 Describe ("Machine item production efficiency metrics" , func () {
116295 It ("records a metric with labels for the produced item name, machine type, and x, y, z coordinates" , func () {
117296 collector .Collect (url , sessionName )
0 commit comments