Skip to content

Commit

Permalink
Merge pull request #484 from Forest-Troll/master
Browse files Browse the repository at this point in the history
Prometheus metrics improve
  • Loading branch information
Donkie authored Dec 28, 2024
2 parents a14a520 + b37c19e commit 276fd1e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions spoolman/prometheus/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@
PREFIX = "spoolman"

SPOOL_PRICE = Gauge(f"{PREFIX}_spool_price", "Total Spool price", ["spool_id", "filament_id"])
SPOOL_USED_WEIGHT = Gauge(f"{PREFIX}_spool_weight_used", "Spool Used Weight", ["spool_id", "filament_id"])
SPOOL_USED_WEIGHT = Gauge(f"{PREFIX}_spool_weight_used", "Spool Used Weight in grams", ["spool_id", "filament_id"])
SPOOL_INITIAL_WEIGHT = Gauge(
f"{PREFIX}_spool_initial_weight",
"Spool Net weight in grams",
["spool_id", "filament_id"],
)
FILAMENT_INFO = Gauge(
f"{PREFIX}_filament_info",
"Filament information",
["filament_id", "vendor", "name", "material", "color"],
)
FILAMENT_DENSITY = Gauge(f"{PREFIX}_filament_density", "Density of filament", ["filament_id"])
FILAMENT_DENSITY = Gauge(f"{PREFIX}_filament_density", "Density of filament gram/cm3", ["filament_id"])
FILAMENT_DIAMETER = Gauge(f"{PREFIX}_filament_diameter", "Diameter of filament", ["filament_id"])
FILAMENT_WEIGHT = Gauge(f"{PREFIX}_filament_weight", "Net weight of filament", ["filament_id"])

Expand Down Expand Up @@ -55,6 +60,8 @@ async def spool_metrics(db: AsyncSession) -> None:
for row in result:
if row.price is not None:
SPOOL_PRICE.labels(str(row.id), str(row.filament_id)).set(row.price)
if row.initial_weight is not None:
SPOOL_INITIAL_WEIGHT.labels(str(row.id), str(row.filament_id)).set(row.initial_weight)
SPOOL_USED_WEIGHT.labels(str(row.id), str(row.filament_id)).set(row.used_weight)


Expand Down

0 comments on commit 276fd1e

Please sign in to comment.