|
@@ -42,9 +42,6 @@ class FlatFileMeta:
|
|
|
id: int
|
|
|
date: datetime
|
|
|
|
|
|
- def to_string(self) -> str:
|
|
|
- return f"bundle_index/{self.id}/{int(self.date.timestamp() * 1000)}"
|
|
|
-
|
|
|
@staticmethod
|
|
|
def from_str(bundle_meta: str) -> "FlatFileMeta":
|
|
|
parsed = bundle_meta.split("/")
|
|
@@ -53,6 +50,16 @@ class FlatFileMeta:
|
|
|
|
|
|
return FlatFileMeta(id=int(parsed[1]), date=datetime.fromtimestamp(int(parsed[2]) / 1000))
|
|
|
|
|
|
+ @staticmethod
|
|
|
+ def build_none():
|
|
|
+ return FlatFileMeta(id=-1, date=datetime.min)
|
|
|
+
|
|
|
+ def to_string(self) -> str:
|
|
|
+ return f"bundle_index/{self.id}/{int(self.date.timestamp() * 1000)}"
|
|
|
+
|
|
|
+ def is_none(self):
|
|
|
+ return self.id == -1 and self.date == datetime.min
|
|
|
+
|
|
|
|
|
|
@sentry_sdk.tracing.trace
|
|
|
def mark_bundle_for_flat_file_indexing(
|
|
@@ -181,13 +188,39 @@ class FlatFileIdentifier(NamedTuple):
|
|
|
return FlatFileMeta(id=result.id, date=result.date_added)
|
|
|
|
|
|
def get_flat_file_meta(self) -> Optional[FlatFileMeta]:
|
|
|
+ meta_type = "release" if self.is_indexing_by_release() else "debug_id"
|
|
|
+
|
|
|
meta = self.get_flat_file_meta_from_cache()
|
|
|
if meta is None:
|
|
|
+ metrics.incr(
|
|
|
+ "artifact_bundle_flat_file_indexing.flat_file_meta.cache_miss",
|
|
|
+ tags={"meta_type": meta_type},
|
|
|
+ )
|
|
|
+
|
|
|
meta = self.get_flat_file_meta_from_db()
|
|
|
if meta is None:
|
|
|
- return None
|
|
|
+ metrics.incr(
|
|
|
+ "artifact_bundle_flat_file_indexing.flat_file_meta.db_miss",
|
|
|
+ tags={"meta_type": meta_type},
|
|
|
+ )
|
|
|
+ meta = FlatFileMeta.build_none()
|
|
|
+ else:
|
|
|
+ metrics.incr(
|
|
|
+ "artifact_bundle_flat_file_indexing.flat_file_meta.db_hit",
|
|
|
+ tags={"meta_type": meta_type},
|
|
|
+ )
|
|
|
|
|
|
+ # We want to cache in both cases, either a value is found or a value was not found.
|
|
|
self.set_flat_file_meta_in_cache(meta)
|
|
|
+ else:
|
|
|
+ metrics.incr(
|
|
|
+ "artifact_bundle_flat_file_indexing.flat_file_meta.cache_hit",
|
|
|
+ tags={"meta_type": meta_type},
|
|
|
+ )
|
|
|
+
|
|
|
+ # In case the meta that we found was none, we want to return None.
|
|
|
+ if meta.is_none():
|
|
|
+ return None
|
|
|
|
|
|
return meta
|
|
|
|