aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/metrics/name_repo.cpp
blob: 2f31c90da2916d1b937cea45da886c56b849c449 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "name_repo.h"

#include <vespa/log/log.h>
LOG_SETUP(".vespalib.metrics.name_repo");

namespace vespalib {
namespace metrics {

MetricId
NameRepo::metric(const vespalib::string &name)
{
    size_t id = _metricNames.resolve(name);
    LOG(debug, "metric name %s -> %zu", name.c_str(), id);
    return MetricId(id);
}

Dimension
NameRepo::dimension(const vespalib::string &name)
{
    size_t id = _dimensionNames.resolve(name);
    LOG(debug, "dimension name %s -> %zu", name.c_str(), id);
    return Dimension(id);
}

Label
NameRepo::label(const vespalib::string &value)
{
    size_t id = _labelValues.resolve(value);
    LOG(debug, "label value %s -> %zu", value.c_str(), id);
    return Label(id);
}

const vespalib::string&
NameRepo::metricName(MetricId metric) const
{
    return _metricNames.lookup(metric.id());
}

const vespalib::string&
NameRepo::dimensionName(Dimension dim) const
{
    return _dimensionNames.lookup(dim.id());
}

const vespalib::string&
NameRepo::labelValue(Label l) const
{
    return _labelValues.lookup(l.id());
}


const PointMap&
NameRepo::pointMap(Point from) const
{
    return _pointMaps.lookup(from.id());
}

Point
NameRepo::pointFrom(PointMap map)
{
    size_t id = _pointMaps.resolve(std::move(map));
    return Point(id);
}


NameRepo NameRepo::instance;


} // namespace vespalib::metrics
} // namespace vespalib