Skip to content

Commit

Permalink
Remove old usage protos (#30061)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 899c47abce9eb7aa861d6bc8bbd4b2c43dc30271
  • Loading branch information
emmaling27 authored and Convex, Inc. committed Sep 23, 2024
1 parent a6e3b72 commit df0b3d1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 38 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions crates/pb/protos/usage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ package usage;

message FunctionUsageStats {
repeated CounterWithTag storage_calls = 1;
// TODO(ENG-7342): Remove after services are pushed with by_component version
optional uint64 storage_ingress_size = 2;
reserved 2;
repeated CounterWithComponent storage_ingress_size_by_component = 8;
// TODO(ENG-7342): Remove after services are pushed with by_component version
optional uint64 storage_egress_size = 3;
reserved 3;
repeated CounterWithComponent storage_egress_size_by_component = 9;
repeated CounterWithTag database_ingress_size = 4;
repeated CounterWithTag database_egress_size = 5;
Expand Down
1 change: 0 additions & 1 deletion crates/usage_tracking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ anyhow = { workspace = true }
common = { path = "../common" }
events = { path = "../events" }
headers = { workspace = true }
maplit = { workspace = true }
metrics = { path = "../metrics" }
parking_lot = { workspace = true, features = ["hardware-lock-elision"] }
pb = { path = "../pb" }
Expand Down
36 changes: 4 additions & 32 deletions crates/usage_tracking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use events::usage::{
UsageEventLogger,
};
use headers::ContentType;
use maplit::btreemap;
use parking_lot::Mutex;
use pb::usage::{
CounterWithComponent as CounterWithComponentProto,
Expand Down Expand Up @@ -729,11 +728,9 @@ impl From<FunctionUsageStats> for FunctionUsageStatsProto {
fn from(stats: FunctionUsageStats) -> Self {
FunctionUsageStatsProto {
storage_calls: to_by_tag_count(stats.storage_calls.into_iter()),
storage_ingress_size: Some(stats.storage_ingress_size.values().sum()),
storage_ingress_size_by_component: to_by_component_count(
stats.storage_ingress_size.into_iter(),
),
storage_egress_size: Some(stats.storage_egress_size.values().sum()),
storage_egress_size_by_component: to_by_component_count(
stats.storage_egress_size.into_iter(),
),
Expand All @@ -750,35 +747,10 @@ impl TryFrom<FunctionUsageStatsProto> for FunctionUsageStats {

fn try_from(stats: FunctionUsageStatsProto) -> anyhow::Result<Self> {
let storage_calls = from_by_tag_count(stats.storage_calls)?.collect();
// TODO(ENG-7342) Remove support for old protos
let storage_ingress_size = if let Some(storage_ingress_size) = stats.storage_ingress_size
&& stats.storage_ingress_size_by_component.is_empty()
{
if storage_ingress_size > 0 {
btreemap! {
ComponentPath::root() => storage_ingress_size,
}
.into_iter()
.collect()
} else {
btreemap! {}.into_iter().collect()
}
} else {
from_by_component_tag_count(stats.storage_ingress_size_by_component)?.collect()
};
// TODO(ENG-7342) Remove support for old protos
let storage_egress_size = if let Some(storage_egress_size) = stats.storage_egress_size
&& stats.storage_egress_size_by_component.is_empty()
&& storage_egress_size > 0
{
btreemap! {
ComponentPath::root() => storage_egress_size,
}
.into_iter()
.collect()
} else {
from_by_component_tag_count(stats.storage_egress_size_by_component)?.collect()
};
let storage_ingress_size =
from_by_component_tag_count(stats.storage_ingress_size_by_component)?.collect();
let storage_egress_size =
from_by_component_tag_count(stats.storage_egress_size_by_component)?.collect();
let database_ingress_size = from_by_tag_count(stats.database_ingress_size)?.collect();
let database_egress_size = from_by_tag_count(stats.database_egress_size)?.collect();
let vector_ingress_size = from_by_tag_count(stats.vector_ingress_size)?.collect();
Expand Down

0 comments on commit df0b3d1

Please sign in to comment.