Skip to content

Commit bf52777

Browse files
committed
Added logic to reset the Prometheus skipped files Gauge if a flush was triggered for that RSyncer
1 parent 1643137 commit bf52777

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/murfey/server/api/instrument.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from sqlmodel import select
1414
from werkzeug.utils import secure_filename
1515

16+
import murfey.server.prometheus as prom
1617
from murfey.server.api.auth import MurfeyInstrumentNameFrontend as MurfeyInstrumentName
1718
from murfey.server.api.auth import MurfeySessionIDFrontend as MurfeySessionID
1819
from murfey.server.api.auth import (
@@ -555,8 +556,8 @@ async def flush_skipped_rsyncer(
555556
db.commit()
556557

557558
# Send request to flush rsyncer
558-
data: dict = {}
559559
update_result: dict = {}
560+
flush_result: dict = {}
560561
machine_config = get_machine_config(instrument_name=instrument_name)[
561562
instrument_name
562563
]
@@ -583,8 +584,14 @@ async def flush_skipped_rsyncer(
583584
"Authorization": f"Bearer {instrument_server_tokens[session_id]['access_token']}"
584585
},
585586
) as resp:
586-
data = await resp.json()
587-
return data
587+
flush_result = await resp.json()
588+
if not flush_result.get("success", False):
589+
return {"success": False}
590+
# Reset the skipped file count for the specific Prometheus gauge to 0
591+
prom.skipped_files.labels(
592+
rsync_source=rsyncer_source.source, visit=session_entry.visit
593+
).set(0)
594+
return flush_result
588595

589596

590597
class RSyncerInfo(BaseModel):

0 commit comments

Comments
 (0)