/src/ztunnel/src/metrics/meta.rs
Line | Count | Source |
1 | | // Copyright Istio Authors |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | // you may not use this file except in compliance with the License. |
5 | | // You may obtain a copy of the License at |
6 | | // |
7 | | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | // See the License for the specific language governing permissions and |
13 | | // limitations under the License. |
14 | | |
15 | | use prometheus_client::encoding::EncodeLabelSet; |
16 | | use prometheus_client::metrics::family::Family; |
17 | | use prometheus_client::metrics::gauge::Gauge; |
18 | | use prometheus_client::registry::Registry; |
19 | | |
20 | | use crate::version; |
21 | | |
22 | | pub struct Metrics {} |
23 | | |
24 | | #[derive(Clone, Hash, Debug, PartialEq, Eq, EncodeLabelSet)] |
25 | | pub struct IstioBuildLabel { |
26 | | component: String, |
27 | | tag: String, |
28 | | } |
29 | | |
30 | | impl Metrics { |
31 | 0 | pub fn new(registry: &mut Registry) -> Self { |
32 | 0 | let build_gauge: Family<IstioBuildLabel, Gauge> = Default::default(); |
33 | 0 | registry.register("build", "Istio component build info", build_gauge.clone()); |
34 | | |
35 | 0 | let tag = version::BuildInfo::new().istio_version; |
36 | | // Note: tag refers to the "Istio version", not the ztunnels own tag (which is an implementation detail to Istio). |
37 | 0 | build_gauge |
38 | 0 | .get_or_create(&IstioBuildLabel { |
39 | 0 | component: "ztunnel".to_string(), |
40 | 0 | tag, |
41 | 0 | }) |
42 | 0 | .set(1); |
43 | | |
44 | 0 | Self {} |
45 | 0 | } |
46 | | } |