MCPcopy Index your code
hub / github.com/coder/coder / newCacheMetrics

Function newCacheMetrics

coderd/files/cache.go:36–83  ·  view source on GitHub ↗
(registerer prometheus.Registerer)

Source from the content-addressed store, hash-verified

34}
35
36func newCacheMetrics(registerer prometheus.Registerer) cacheMetrics {
37 subsystem := "file_cache"
38 f := promauto.With(registerer)
39
40 return cacheMetrics{
41 currentCacheSize: f.NewGauge(prometheus.GaugeOpts{
42 Namespace: "coderd",
43 Subsystem: subsystem,
44 Name: "open_files_size_bytes_current",
45 Help: "The current amount of memory of all files currently open in the file cache.",
46 }),
47
48 totalCacheSize: f.NewCounter(prometheus.CounterOpts{
49 Namespace: "coderd",
50 Subsystem: subsystem,
51 Name: "open_files_size_bytes_total",
52 Help: "The total amount of memory ever opened in the file cache. This number never decrements.",
53 }),
54
55 currentOpenFiles: f.NewGauge(prometheus.GaugeOpts{
56 Namespace: "coderd",
57 Subsystem: subsystem,
58 Name: "open_files_current",
59 Help: "The count of unique files currently open in the file cache.",
60 }),
61
62 totalOpenedFiles: f.NewCounter(prometheus.CounterOpts{
63 Namespace: "coderd",
64 Subsystem: subsystem,
65 Name: "open_files_total",
66 Help: "The total count of unique files ever opened in the file cache.",
67 }),
68
69 currentOpenFileReferences: f.NewGauge(prometheus.GaugeOpts{
70 Namespace: "coderd",
71 Subsystem: subsystem,
72 Name: "open_file_refs_current",
73 Help: "The count of file references currently open in the file cache. Multiple references can be held for the same file.",
74 }),
75
76 totalOpenFileReferences: f.NewCounterVec(prometheus.CounterOpts{
77 Namespace: "coderd",
78 Subsystem: subsystem,
79 Name: "open_file_refs_total",
80 Help: "The total number of file references ever opened in the file cache. The 'hit' label indicates if the file was loaded from the cache.",
81 }, []string{"hit"}),
82 }
83}
84
85// Cache persists the files for template versions, and is used by dynamic
86// parameters to deduplicate the files in memory. When any number of users opens

Callers 1

NewFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected