c4f5d0aa15
Summary: This PR adds public `GetStatsHistory` API to retrieve stats history in the form of an std map. The key of the map is the timestamp in microseconds when the stats snapshot is taken, the value is another std map from stats name to stats value (stored in std string). Two DBOptions are introduced: `stats_persist_period_sec` (default 10 minutes) controls the intervals between two snapshots are taken; `max_stats_history_count` (default 10) controls the max number of history snapshots to keep in memory. RocksDB will stop collecting stats snapshots if `stats_persist_period_sec` is set to 0. (This PR is the in-memory part of https://github.com/facebook/rocksdb/pull/4535) Pull Request resolved: https://github.com/facebook/rocksdb/pull/4748 Differential Revision: D13961471 Pulled By: miasantreble fbshipit-source-id: ac836d401ecb84ea92216bf9966f969dedf4ad04
50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
#pragma once
|
|
|
|
#include <map>
|
|
#include <string>
|
|
|
|
// #include "db/db_impl.h"
|
|
#include "rocksdb/statistics.h"
|
|
#include "rocksdb/status.h"
|
|
|
|
namespace rocksdb {
|
|
|
|
class DBImpl;
|
|
|
|
class StatsHistoryIterator {
|
|
public:
|
|
StatsHistoryIterator() {}
|
|
virtual ~StatsHistoryIterator() {}
|
|
|
|
virtual bool Valid() const = 0;
|
|
|
|
// Moves to the next stats history record. After this call, Valid() is
|
|
// true iff the iterator was not positioned at the last entry in the source.
|
|
// REQUIRES: Valid()
|
|
virtual void Next() = 0;
|
|
|
|
// Return the time stamp (in microseconds) when stats history is recorded.
|
|
// REQUIRES: Valid()
|
|
virtual uint64_t GetStatsTime() const = 0;
|
|
|
|
// Return the current stats history as an std::map which specifies the
|
|
// mapping from stats name to stats value . The underlying storage
|
|
// for the returned map is valid only until the next modification of
|
|
// the iterator.
|
|
// REQUIRES: Valid()
|
|
virtual const std::map<std::string, uint64_t>& GetStatsMap() const = 0;
|
|
|
|
// If an error has occurred, return it. Else return an ok status.
|
|
virtual Status status() const = 0;
|
|
};
|
|
|
|
} // namespace rocksdb
|