File: daemon.go

package info (click to toggle)
golang-github-containerd-nydus-snapshotter 0.13.4-2.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,824 kB
  • sloc: sh: 470; makefile: 129
file content (43 lines) | stat: -rw-r--r-- 956 bytes parent folder | download
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
/*
 * Copyright (c) 2022. Nydus Developers. All rights reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

package collector

import (
	"github.com/containerd/containerd/log"
	"github.com/containerd/nydus-snapshotter/pkg/daemon/types"
	"github.com/containerd/nydus-snapshotter/pkg/metrics/data"
)

type DaemonEventCollector struct {
	event types.DaemonState
}

type DaemonInfoCollector struct {
	Version *types.BuildTimeInfo
	value   float64
}

type DaemonResourceCollector struct {
	DaemonID string
	Value    float64
}

func (d *DaemonEventCollector) Collect() {
	data.NydusdEventCount.WithLabelValues(string(d.event)).Inc()
}

func (d *DaemonInfoCollector) Collect() {
	if d.Version == nil {
		log.L.Warnf("failed to collect daemon count, version is invalid")
		return
	}
	data.NydusdCount.WithLabelValues(d.Version.PackageVer).Add(d.value)
}

func (d *DaemonResourceCollector) Collect() {
	data.NydusdRSS.WithLabelValues(d.DaemonID).Set(d.Value)
}