Skip to content

Commit

Permalink
fix(COGS): Fix cluster name in COGS accounting for Snuba API (#5570)
Browse files Browse the repository at this point in the history
* fix resource_id handling for cogs

* add condiition for counters
  • Loading branch information
ayirr7 authored Feb 22, 2024
1 parent ab239e8 commit 9a800b5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions snuba/querylog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def _record_cogs(

cluster_name = query_metadata.query_list[0].stats.get("cluster_name", "")

if not cluster_name.startswith("snuba_gen_metrics"):
if not cluster_name.startswith("snuba-gen-metrics"):
return # Only track shared clusters

# Sanitize the cluster name to line up with the resource_id naming convention
Expand All @@ -130,9 +130,10 @@ def _record_cogs(
.replace("snuba_gen_metrics", "generic_metrics_clickhouse")
.replace("_0", "")
)

if random() < (state.get_config("snuba_api_cogs_probability") or 0):
record_cogs(
resource_id=f"{cluster_name}_snuba_api_bytes_scanned",
resource_id=f"{cluster_name}",
app_feature=app_feature,
amount=bytes_scanned,
usage_type=UsageUnit.BYTES,
Expand Down

0 comments on commit 9a800b5

Please sign in to comment.