<commit_before>// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "idealstatemetricsset.h"
namespace storage {

namespace distributor {

OperationMetricSet::OperationMetricSet(const std::string& name, metrics::Metric::Tags tags, const std::string& description, MetricSet* owner)
    : MetricSet(name, std::move(tags), description, owner),
      pending("pending",
              {{"logdefault"},{"yamasdefault"}},
              "The number of operations pending", this),
      ok("done_ok",
         {{"logdefault"},{"yamasdefault"}},
         "The number of operations successfully performed", this),
      failed("done_failed",
             {{"logdefault"},{"yamasdefault"}},
             "The number of operations that failed", this),
      blocked("blocked",
              {{"logdefault"},{"yamasdefault"}},
              "The number of operations blocked by blocking operation starter", this),
      throttled("throttled",
                {{"logdefault"},{"yamasdefault"}},
                "The number of operations throttled by throttling operation starter", this)
{}

OperationMetricSet::~OperationMetricSet() = default;

GcMetricSet::GcMetricSet(const std::string& name, metrics::Metric::Tags tags, const std::string& description, MetricSet* owner)
        : OperationMetricSet(name, std::move(tags), description, owner),
          documents_removed("documents_removed",
                           {{"logdefault"},{"yamasdefault"}},
                           "Number of documents removed by GC operations", this)
{}

GcMetricSet::~GcMetricSet() = default;

MergeBucketMetricSet::MergeBucketMetricSet(const std::string& name, metrics::Metric::Tags tags, const std::string& description, MetricSet* owner)
    : OperationMetricSet(name, std::move(tags), description, owner),
      source_only_copy_changed("source_only_copy_changed",
                               {{"logdefault"},{"yamasdefault"}},
                               "The number of merge operations where source-only copy changed"),
      source_only_copy_delete_blocked("source_only_copy_delete_blocked",
                                      {{"logdefault"},{"yamasdefault"}},
                                      "The number of merge operations where delete of unchanged source-only copies was blocked"),
      source_only_copy_delete_failed("source_only_copy_delete_failed",
                                      {{"logdefault"},{"yamasdefault"}},
                                      "The number of merge operations where delete of unchanged source-only copies failed")
{
}

MergeBucketMetricSet::~MergeBucketMetricSet() = default;

void
IdealStateMetricSet::createOperationMetrics() {
    typedef IdealStateOperation ISO;
    operations.resize(ISO::OPERATION_COUNT);
    // Note: naked new is used instead of make_shared due to the latter not being
    // able to properly transitively deduce the types for the tag initializer lists.
    operations[ISO::DELETE_BUCKET] = std::shared_ptr<OperationMetricSet>(
            new OperationMetricSet("delete_bucket",
                                   {{"logdefault"},{"yamasdefault"}},
                                   "Operations to delete excess buckets on storage nodes", this));
    operations[ISO::MERGE_BUCKET] = std::make_shared<MergeBucketMetricSet>
                                    ("merge_bucket",
                                     metrics::Metric::Tags{{"logdefault"},{"yamasdefault"}},<commit_msg>Connect the merge bucket metric to the parent metric set.<commit_after>// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "idealstatemetricsset.h"
namespace storage {

namespace distributor {

OperationMetricSet::OperationMetricSet(const std::string& name, metrics::Metric::Tags tags, const std::string& description, MetricSet* owner)
    : MetricSet(name, std::move(tags), description, owner),
      pending("pending",
              {{"logdefault"},{"yamasdefault"}},
              "The number of operations pending", this),
      ok("done_ok",
         {{"logdefault"},{"yamasdefault"}},
         "The number of operations successfully performed", this),
      failed("done_failed",
             {{"logdefault"},{"yamasdefault"}},
             "The number of operations that failed", this),
      blocked("blocked",
              {{"logdefault"},{"yamasdefault"}},
              "The number of operations blocked by blocking operation starter", this),
      throttled("throttled",
                {{"logdefault"},{"yamasdefault"}},
                "The number of operations throttled by throttling operation starter", this)
{}

OperationMetricSet::~OperationMetricSet() = default;

GcMetricSet::GcMetricSet(const std::string& name, metrics::Metric::Tags tags, const std::string& description, MetricSet* owner)
        : OperationMetricSet(name, std::move(tags), description, owner),
          documents_removed("documents_removed",
                           {{"logdefault"},{"yamasdefault"}},
                           "Number of documents removed by GC operations", this)
{}

GcMetricSet::~GcMetricSet() = default;

MergeBucketMetricSet::MergeBucketMetricSet(const std::string& name, metrics::Metric::Tags tags, const std::string& description, MetricSet* owner)
    : OperationMetricSet(name, std::move(tags), description, owner),
      source_only_copy_changed("source_only_copy_changed",
                               {{"logdefault"},{"yamasdefault"}},
                               "The number of merge operations where source-only copy changed", this),
      source_only_copy_delete_blocked("source_only_copy_delete_blocked",
                                      {{"logdefault"},{"yamasdefault"}},
                                      "The number of merge operations where delete of unchanged source-only copies was blocked", this),
      source_only_copy_delete_failed("source_only_copy_delete_failed",
                                      {{"logdefault"},{"yamasdefault"}},
                                      "The number of merge operations where delete of unchanged source-only copies failed", this)
{
}

MergeBucketMetricSet::~MergeBucketMetricSet() = default;

void
IdealStateMetricSet::createOperationMetrics() {
    typedef IdealStateOperation ISO;
    operations.resize(ISO::OPERATION_COUNT);
    // Note: naked new is used instead of make_shared due to the latter not being
    // able to properly transitively deduce the types for the tag initializer lists.
    operations[ISO::DELETE_BUCKET] = std::shared_ptr<OperationMetricSet>(
            new OperationMetricSet("delete_bucket",
                                   {{"logdefault"},{"yamasdefault"}},
                                   "Operations to delete excess buckets on storage nodes", this));
    operations[ISO::MERGE_BUCKET] = std::make_shared<MergeBucketMetricSet>
                                    ("merge_bucket",
                                     metrics::Metric::Tags{{"logdefault"},{"yamasdefault"}},
{'fraction_non_alphanumeric': 0.11208604585338239, 'fraction_numerical': 0.0005660911406736484, 'mean_word_length': 2.8282773564463706, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6015920', 'n_tokens_mistral': 1734, 'n_tokens_neox': 1703, 'n_words': 455}