Skip to content

Commit 7886b5d

Browse files
authored
refactor(metrics): simplify Prometheus counters usage (#475)
1 parent d061b48 commit 7886b5d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/server/s3_utils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
# Initialize logger for this module
2323
logger = get_logger(__name__)
2424

25-
_cache_lookup_counter = Counter("gitingest_cache_lookup", "Number of cache lookups", ["url"])
26-
_cache_hit_counter = Counter("gitingest_cache_hit", "Number of cache hits", ["url"])
27-
_cache_miss_counter = Counter("gitingest_cache_miss", "Number of cache misses", ["url"])
25+
_s3_ingest_lookup_counter = Counter("gitingest_s3_ingest_lookup", "Number of S3 ingest file lookups")
26+
_s3_ingest_hit_counter = Counter("gitingest_s3_ingest_hit", "Number of S3 ingest file cache hits")
27+
_s3_ingest_miss_counter = Counter("gitingest_s3_ingest_miss", "Number of S3 ingest file cache misses")
2828

2929

3030
class S3UploadError(Exception):
@@ -432,7 +432,7 @@ def check_s3_object_exists(s3_file_path: str) -> bool:
432432
return False
433433

434434
logger.info("Checking S3 object existence", extra={"s3_file_path": s3_file_path})
435-
_cache_lookup_counter.labels(url=s3_file_path).inc()
435+
_s3_ingest_lookup_counter.inc()
436436
try:
437437
s3_client = create_s3_client()
438438
bucket_name = get_s3_bucket_name()
@@ -451,7 +451,7 @@ def check_s3_object_exists(s3_file_path: str) -> bool:
451451
"error_code": error_code,
452452
},
453453
)
454-
_cache_miss_counter.labels(url=s3_file_path).inc()
454+
_s3_ingest_miss_counter.inc()
455455
return False
456456
# Re-raise other errors (permissions, etc.)
457457
raise
@@ -465,7 +465,7 @@ def check_s3_object_exists(s3_file_path: str) -> bool:
465465
"exception": str(exc),
466466
},
467467
)
468-
_cache_miss_counter.labels(url=s3_file_path).inc()
468+
_s3_ingest_miss_counter.inc()
469469
return False
470470
else:
471471
logger.info(
@@ -475,7 +475,7 @@ def check_s3_object_exists(s3_file_path: str) -> bool:
475475
"bucket_name": get_s3_bucket_name(),
476476
},
477477
)
478-
_cache_hit_counter.labels(url=s3_file_path).inc()
478+
_s3_ingest_hit_counter.inc()
479479
return True
480480

481481

0 commit comments

Comments
 (0)