blob: 59de4a6fe4dfa18f3165ee4399fb41ef05f5e7e6 (
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
38
39
40
41
42
43
44
45
46
47
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <memory>
#include "metric_id.h"
#include "point.h"
namespace vespalib {
namespace metrics {
class MetricsManager;
struct GaugeAggregator;
/**
* Represents a gauge metric that can be measured.
**/
class Gauge {
private:
std::shared_ptr<MetricsManager> _manager;
MetricId _id;
public:
Gauge(std::shared_ptr<MetricsManager> m, MetricId id)
: _manager(std::move(m)), _id(id)
{}
/**
* Provide a sample for the gauge.
* @param value the measurement for this sample
* @param p the point representing labels for this sample (default empty)
**/
void sample(double value, Point p = Point::empty) const;
// internal
struct Measurement {
using Key = std::pair<MetricId, Point>;
Key idx;
double value;
Measurement() = delete;
Measurement(Key k, double v) : idx(k), value(v) {}
};
typedef GaugeAggregator aggregator_type;
typedef Measurement sample_type;
};
} // namespace vespalib::metrics
} // namespace vespalib
|