blob: c2b53e7634608c922596bf561276c0776dcbd8aa (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "attribute_usage_stats.h"
#include <mutex>
#include <memory>
namespace proton {
class AttributeUsageFilter;
class AttributeConfigInspector;
class TransientResourceUsageProvider;
/*
* Context for sampling attribute usage stats.
* When instance is destroyed, the aggregated stats is passed on to attribute usage filter.
*/
class AttributeUsageSamplerContext
{
using Mutex = std::mutex;
using Guard = std::lock_guard<Mutex>;
AttributeUsageStats _usage;
Mutex _lock;
AttributeUsageFilter &_filter;
public:
AttributeUsageSamplerContext(AttributeUsageFilter& filter);
~AttributeUsageSamplerContext();
void merge(const search::AddressSpaceUsage &usage,
const vespalib::string &attributeName,
const vespalib::string &subDbName);
const AttributeUsageStats& getUsage() const { return _usage; }
};
} // namespace proton
|