diff --git a/searchcore/src/vespa/searchcore/proton/metrics/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/metrics/CMakeLists.txt index d7ac8de2420..dae64398293 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/CMakeLists.txt +++ b/searchcore/src/vespa/searchcore/proton/metrics/CMakeLists.txt @@ -5,7 +5,6 @@ vespa_add_library(searchcore_proton_metrics STATIC attribute_metrics_entry.cpp cache_metrics.cpp content_proton_metrics.cpp - disk_usage_metrics.cpp documentdb_job_trackers.cpp documentdb_tagged_metrics.cpp document_db_commit_metrics.cpp diff --git a/searchcore/src/vespa/searchcore/proton/metrics/disk_usage_metrics.cpp b/searchcore/src/vespa/searchcore/proton/metrics/disk_usage_metrics.cpp deleted file mode 100644 index 5c96d7d2c4c..00000000000 --- a/searchcore/src/vespa/searchcore/proton/metrics/disk_usage_metrics.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "disk_usage_metrics.h" -#include -#include - -using search::DiskIoStats; - -namespace proton { - -DiskUsageMetrics::DiskUsageMetrics(metrics::MetricSet* parent) - : MetricSet("disk_usage", {}, "The disk usage for a given component", parent), - _size_on_disk("size_on_disk", {}, "Size on disk (bytes)", this), - _search_read_bytes("search_read_bytes", {}, "Bytes read in posting list files as part of search", this) -{ -} - -DiskUsageMetrics::~DiskUsageMetrics() = default; - -void -DiskUsageMetrics::update(uint64_t size_on_disk, const DiskIoStats& disk_io_stats) -{ - _size_on_disk.set(size_on_disk); - _search_read_bytes.addTotalValueBatch(disk_io_stats.read_bytes_total(), - disk_io_stats.read_operations(), - disk_io_stats.read_bytes_min(), - disk_io_stats.read_bytes_max()); -} - -} diff --git a/searchcore/src/vespa/searchcore/proton/metrics/disk_usage_metrics.h b/searchcore/src/vespa/searchcore/proton/metrics/disk_usage_metrics.h deleted file mode 100644 index 583640bde21..00000000000 --- a/searchcore/src/vespa/searchcore/proton/metrics/disk_usage_metrics.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#pragma once - -#include -#include - -namespace search { class DiskIoStats; } - -namespace proton { - -/** - * Metric set for disk usage metrics. - */ -class DiskUsageMetrics : public metrics::MetricSet { - metrics::LongValueMetric _size_on_disk; - metrics::LongValueMetric _search_read_bytes; - -public: - explicit DiskUsageMetrics(metrics::MetricSet* parent); - ~DiskUsageMetrics() override; - void update(uint64_t size_on_disk, const search::DiskIoStats& disk_io_stats); -}; - -} diff --git a/searchcore/src/vespa/searchcore/proton/metrics/field_metrics_entry.cpp b/searchcore/src/vespa/searchcore/proton/metrics/field_metrics_entry.cpp index bf45b3490e0..700b43e356a 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/field_metrics_entry.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/field_metrics_entry.cpp @@ -6,7 +6,8 @@ namespace proton { FieldMetricsEntry::FieldMetricsEntry(const std::string& name, const std::string& field_name, const std::string& description) : metrics::MetricSet(name, {{"field", field_name}}, description, nullptr), - memoryUsage(this) + memoryUsage(this), + size_on_disk("size_on_disk", {}, "Size on disk (bytes)", this) { } diff --git a/searchcore/src/vespa/searchcore/proton/metrics/field_metrics_entry.h b/searchcore/src/vespa/searchcore/proton/metrics/field_metrics_entry.h index 12e06ed7652..62d15d478e1 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/field_metrics_entry.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/field_metrics_entry.h @@ -10,7 +10,8 @@ namespace proton { * Class containing metrics for an aspect (attribute or index) of a field. */ struct FieldMetricsEntry : public metrics::MetricSet { - MemoryUsageMetrics memoryUsage; + MemoryUsageMetrics memoryUsage; + metrics::LongValueMetric size_on_disk; FieldMetricsEntry(const std::string& name, const std::string& field_name, const std::string& description); ~FieldMetricsEntry() override; }; diff --git a/searchcore/src/vespa/searchcore/proton/metrics/index_metrics_entry.cpp b/searchcore/src/vespa/searchcore/proton/metrics/index_metrics_entry.cpp index e0930f70de3..77016c8c9b3 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/index_metrics_entry.cpp +++ b/searchcore/src/vespa/searchcore/proton/metrics/index_metrics_entry.cpp @@ -1,19 +1,47 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "index_metrics_entry.h" +#include + +using search::DiskIoStats; namespace proton { namespace { -const std::string entry_name("index_field"); +const std::string entry_name("index"); const std::string entry_description("Metrics for indexes for a given field"); } +IndexMetricsEntry::DiskIoMetrics::SearchMetrics::SearchMetrics(metrics::MetricSet* parent) + : MetricSet("search", {}, "The search io for a given component", parent), + _read_bytes("read_bytes", {}, "Bytes read in posting list files as part of search", this) +{ +} + +IndexMetricsEntry::DiskIoMetrics::SearchMetrics::~SearchMetrics() = default; + +void +IndexMetricsEntry::DiskIoMetrics::SearchMetrics::update(const DiskIoStats& disk_io_stats) +{ + _read_bytes.addTotalValueBatch(disk_io_stats.read_bytes_total(), + disk_io_stats.read_operations(), + disk_io_stats.read_bytes_min(), + disk_io_stats.read_bytes_max()); +} + +IndexMetricsEntry::DiskIoMetrics::DiskIoMetrics(metrics::MetricSet* parent) + : MetricSet("io", {}, "The disk usage for a given component", parent), + _search(this) +{ +} + +IndexMetricsEntry::DiskIoMetrics::~DiskIoMetrics() = default; + IndexMetricsEntry::IndexMetricsEntry(const std::string& field_name) : FieldMetricsEntry(entry_name, field_name, entry_description), - _disk_usage(this) + _disk_io(this) { } diff --git a/searchcore/src/vespa/searchcore/proton/metrics/index_metrics_entry.h b/searchcore/src/vespa/searchcore/proton/metrics/index_metrics_entry.h index 04a34ad38fa..6442485735c 100644 --- a/searchcore/src/vespa/searchcore/proton/metrics/index_metrics_entry.h +++ b/searchcore/src/vespa/searchcore/proton/metrics/index_metrics_entry.h @@ -2,20 +2,40 @@ #pragma once -#include "disk_usage_metrics.h" #include "field_metrics_entry.h" +namespace search { class DiskIoStats; } + namespace proton { /* * Class containing metrics for the index aspect of a field, i.e. * disk indexes and memory indexes. */ -struct IndexMetricsEntry : public FieldMetricsEntry { - DiskUsageMetrics _disk_usage; +class IndexMetricsEntry : public FieldMetricsEntry { + class DiskIoMetrics : public metrics::MetricSet { + class SearchMetrics : public metrics::MetricSet { + metrics::LongValueMetric _read_bytes; + public: + explicit SearchMetrics(metrics::MetricSet* parent); + ~SearchMetrics() override; + void update(const search::DiskIoStats& disk_io_stats); + }; + + SearchMetrics _search; + + public: + explicit DiskIoMetrics(metrics::MetricSet* parent); + ~DiskIoMetrics() override; + void update(const search::DiskIoStats& disk_io_stats) { _search.update(disk_io_stats); } + }; + + DiskIoMetrics _disk_io; - IndexMetricsEntry(const std::string& field_name); +public: + explicit IndexMetricsEntry(const std::string& field_name); ~IndexMetricsEntry() override; + void update_disk_io(const search::DiskIoStats& disk_io_stats) { _disk_io.update(disk_io_stats); } }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb_metrics_updater.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb_metrics_updater.cpp index 1114041a013..3fb631b4a8c 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb_metrics_updater.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb_metrics_updater.cpp @@ -84,7 +84,8 @@ updateIndexMetrics(DocumentDBTaggedMetrics &metrics, const search::SearchableSta auto entry = field_metrics.get_field_metrics_entry(field.first); if (entry) { entry->memoryUsage.update(field.second.memory_usage()); - entry->_disk_usage.update(field.second.size_on_disk(), field.second.disk_io_stats()); + entry->size_on_disk.set(field.second.size_on_disk()); + entry->update_disk_io(field.second.disk_io_stats()); } } }