Skip to content

Commit

Permalink
[minfs][blobfs] Use Lapis for oldest_version
Browse files Browse the repository at this point in the history
Replace "version_migrated" metric in Cobalt with new Inspect/Lapis
equivalent.

Remove now-unused functions from the VFS Metrics library.

Bug: 94726
Test: Manually tested Lapis/Cobalt configuration by logging locally.

Change-Id: Ic50afa875456ebf8343b57d134c007926c90f14e
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/677743
Reviewed-by: Miguel Flores <[email protected]>
Reviewed-by: James Sullivan <[email protected]>
Commit-Queue: Brandon Castellano <[email protected]>
  • Loading branch information
Breakthrough authored and Commit Bot committed May 12, 2022
1 parent 7a11e81 commit 3e7f195
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 41 deletions.
24 changes: 1 addition & 23 deletions src/lib/storage/vfs/cpp/metrics/cobalt_metrics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ void CompressionFormatMetrics::IncrementCounter(fs_metrics::CompressionFormat fo

Metrics::Metrics(std::unique_ptr<cobalt_client::Collector> collector, Source source,
CompressionSource compression_source)
: source_(source),
collector_(std::move(collector)),
: collector_(std::move(collector)),
fs_common_metrics_(collector_.get(), source),
compression_format_metrics_(collector_.get(), compression_source) {}

Expand All @@ -164,27 +163,6 @@ void Metrics::EnableMetrics(bool should_enable) {

bool Metrics::IsEnabled() const { return is_enabled_; }

void Metrics::RecordOldestVersionMounted(std::string_view version) {
std::scoped_lock lock(mutex_);
// We hack the version into the component field (which is the only dimension that supports a
// string value), whilst we store the real storage sub-component in a dimension. There is
// precedent for this kind of hack; SWD do something similar.
cobalt_client::MetricOptions options{
.component = std::string(version),
.metric_id = static_cast<uint32_t>(Event::kVersion),
.metric_dimensions = 1,
.event_codes = {static_cast<uint32_t>(source_)},
};
auto iter = temporary_counters_.find(options);
if (iter == temporary_counters_.end()) {
iter =
temporary_counters_
.insert(std::make_unique<cobalt_client::Counter>(std::move(options), collector_.get()))
.first;
}
(*iter)->Increment();
}

bool Metrics::Flush() {
std::scoped_lock lock(mutex_);
if (collector_->Flush()) {
Expand Down
3 changes: 0 additions & 3 deletions src/lib/storage/vfs/cpp/metrics/cobalt_metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ class Metrics {
const CompressionFormatMetrics& compression_format_metrics() const;
CompressionFormatMetrics* mutable_compression_format_metrics();

void RecordOldestVersionMounted(std::string_view version);

FsCommonMetrics::FragmentationMetrics& FragmentationMetrics() {
return fs_common_metrics_.fragmentation_metrics;
}
Expand All @@ -178,7 +176,6 @@ class Metrics {
};

std::mutex mutex_;
Source source_;
std::unique_ptr<cobalt_client::Collector> collector_ FXL_GUARDED_BY(mutex_);

FsCommonMetrics fs_common_metrics_;
Expand Down
15 changes: 0 additions & 15 deletions src/lib/storage/vfs/cpp/metrics/cobalt_metrics_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,20 +211,5 @@ TEST(CobaltMetricsTest, IncrementCompressionFormatMetrics) {
}
}

TEST(CobaltMetricsTest, RecordOldestVersionMountedReportsCorrectly) {
cobalt_client::InMemoryLogger* logger;
fs_metrics::Metrics metrics(MakeCollector(&logger), Source::kBlobfs, CompressionSource::kBlobfs);
metrics.RecordOldestVersionMounted("5/5");
EXPECT_TRUE(metrics.Flush());
cobalt_client::MetricOptions expected_options = {
.component = "5/5",
.metric_id = static_cast<uint32_t>(Event::kVersion),
.metric_dimensions = 1,
.event_codes = {static_cast<uint32_t>(Source::kBlobfs)}};
auto iter = logger->counters().find(expected_options);
ASSERT_NE(iter, logger->counters().end());
EXPECT_EQ(iter->second, 1);
}

} // namespace
} // namespace fs_metrics

0 comments on commit 3e7f195

Please sign in to comment.