Skip to main content

mz_metrics/
dyncfgs.rs

1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
9
10//! Dyncfgs used by mz-metrics.
11
12use std::time::Duration;
13
14use mz_dyncfg::{Config, ConfigSet, ParameterScope};
15
16/// How frequently to refresh lgalloc map stats.
17pub(crate) const MZ_METRICS_LGALLOC_MAP_REFRESH_INTERVAL: Config<Duration> = Config::new(
18    "mz_metrics_lgalloc_map_refresh_interval",
19    Duration::from_secs(0),
20    "How frequently to refresh lgalloc stats. A zero duration disables refreshing.",
21    ParameterScope::Replica,
22);
23
24/// How frequently to refresh lgalloc stats.
25pub(crate) const MZ_METRICS_LGALLOC_REFRESH_INTERVAL: Config<Duration> = Config::new(
26    "mz_metrics_lgalloc_refresh_interval",
27    Duration::from_secs(30),
28    "How frequently to refresh lgalloc stats. A zero duration disables refreshing.",
29    ParameterScope::Replica,
30);
31
32/// How frequently to refresh lgalloc stats.
33pub(crate) const MZ_METRICS_RUSAGE_REFRESH_INTERVAL: Config<Duration> = Config::new(
34    "mz_metrics_rusage_refresh_interval",
35    Duration::from_secs(30),
36    "How frequently to refresh rusage stats. A zero duration disables refreshing.",
37    ParameterScope::Replica,
38);
39
40/// How frequently to sample process resource usage.
41///
42/// This interval bounds how short a spike can be and still be observed, but only for the sources
43/// with no kernel-side high-water mark. A kernel-maintained peak such as `cgroup memory.peak` is
44/// exact no matter how rarely it is read. Deliberately separate from `memory_limiter_interval`,
45/// which governs OOM-kill behavior and must not be retuned for introspection's sake.
46pub(crate) const MZ_METRICS_USAGE_REFRESH_INTERVAL: Config<Duration> = Config::new(
47    "mz_metrics_usage_refresh_interval",
48    Duration::from_secs(5),
49    "How frequently to sample process resource usage. A zero duration disables sampling.",
50    ParameterScope::Replica,
51);
52
53/// Adds the full set of all storage `Config`s.
54pub fn all_dyncfgs(configs: ConfigSet) -> ConfigSet {
55    configs
56        .add(&MZ_METRICS_LGALLOC_MAP_REFRESH_INTERVAL)
57        .add(&MZ_METRICS_LGALLOC_REFRESH_INTERVAL)
58        .add(&MZ_METRICS_RUSAGE_REFRESH_INTERVAL)
59        .add(&MZ_METRICS_USAGE_REFRESH_INTERVAL)
60}