Configuration¶
jitterbug.models.config
¶
Configuration models using Pydantic for validation and serialization.
RTT_COLUMN_SYNONYMS = ('values', 'rtt_value', 'rtt', 'latency')
module-attribute
¶
RTT column names searched, in this order, when InputConfig.rtt_column is None.
SOURCE_KINDS = ('clickhouse', 'influxdb2', 'influxdb3', 'duckdb')
module-attribute
¶
Database back ends a SourceConfig can name.
SECRET_ENV_DEFAULTS = {'clickhouse': 'CLICKHOUSE_PASSWORD', 'influxdb2': 'INFLUXDB_V2_TOKEN', 'influxdb3': 'INFLUX_TOKEN'}
module-attribute
¶
Environment variable each back end reads its password or token from by default:
the names clickhouse-client, influxdb-client and influxdb3-python use.
SECRET_KEYS = frozenset({'password', 'passwd', 'pwd', 'token', 'access_token', 'api_key', 'apikey', 'api_token', 'secret', 'auth', 'authorization', 'credentials'})
module-attribute
¶
Setting names that would hold a secret; they are rejected in a source profile or URI.
ChangePointDetectionConfig
¶
Bases: BaseModel
Configuration for change point detection algorithms.
Attributes:
| Name | Type | Description |
|---|---|---|
algorithm |
Literal['bcp', 'ruptures']
|
Algorithm to use for change point detection. |
threshold |
float
|
Threshold for change point detection sensitivity. |
min_time_elapsed |
int
|
Minimum time in seconds between change points. |
max_change_points |
Optional[int]
|
Maximum number of change points to detect. |
JitterAnalysisConfig
¶
Bases: BaseModel
Configuration for jitter analysis methods.
Attributes:
| Name | Type | Description |
|---|---|---|
method |
Literal['jitter_dispersion', 'ks_test']
|
Method to use for jitter analysis. |
threshold |
float
|
Threshold for significance testing. |
moving_average_order |
int
|
Order of moving average filter (must be even). |
moving_iqr_order |
int
|
Order of moving IQR filter. |
significance_level |
float
|
Statistical significance level for tests. |
LatencyJumpConfig
¶
Bases: BaseModel
Configuration for latency jump detection.
Attributes:
| Name | Type | Description |
|---|---|---|
threshold |
float
|
Threshold for latency jump detection. |
DataProcessingConfig
¶
Bases: BaseModel
Configuration for data processing.
Attributes:
| Name | Type | Description |
|---|---|---|
minimum_interval_minutes |
int
|
Interval in minutes for computing minimum RTT values. |
min_samples_per_interval |
int
|
Deprecated, no effect: no minimum number of samples per interval has ever been enforced. Accepted until 3.0, where it is removed. |
outlier_detection |
bool
|
Deprecated, no effect: no outlier filtering has ever been applied. Accepted until 3.0, where it is removed. |
outlier_threshold |
float
|
Deprecated, no effect: no outlier filtering has ever been applied. Accepted until 3.0, where it is removed. |
Notes
Setting a deprecated option emits one :class:DeprecationWarning and one log
warning per option. Dumps (configuration files written by to_file, the
metadata.config of result files) leave the deprecated options out unless they
were set explicitly.
ClusteringConfig
¶
Bases: BaseModel
Configuration for the non-sequential (clustering) analysis mode.
Each minimum-RTT interval becomes one point with two features, its minimum RTT and
the interquartile range of the jitter samples inside it. The points are clustered
without regard to time; the cluster with the lowest median minimum RTT is the
baseline, and every other cluster is congested when its median minimum RTT exceeds
the baseline by more than the latency threshold and the jitter samples of the two
clusters differ: a Kolmogorov-Smirnov test is significant at
jitter_analysis.significance_level and its statistic is at least
min_ks_statistic.
Attributes:
| Name | Type | Description |
|---|---|---|
algorithm |
Literal['gmm', 'kmeans', 'kmeans_silhouette']
|
|
n_clusters |
int
|
Number of clusters for |
max_clusters |
int
|
Largest number of clusters tried by |
min_period_intervals |
int
|
Temporal smoothing, in intervals: gaps of at most this many non-congested
intervals inside congestion are filled, then congested runs of at most this
many intervals are dropped. |
random_state |
int
|
Seed for the clustering algorithms, so results are reproducible. |
latency_threshold |
float | None
|
Minimum excess of a cluster's median minimum RTT over the baseline's (ms).
|
min_ks_statistic |
float
|
Smallest Kolmogorov-Smirnov statistic (the largest gap between the two empirical
jitter distributions, 0-1) that counts as a jitter change. Clusters pool
thousands of samples, so the p-value alone is significant for negligible
differences; this bounds the effect size. |
StreamingConfig
¶
Bases: BaseModel
Settings of the online (streaming) mode, jitterbug.streaming.OnlineJitterbug.
The online mode reuses the sequential decision rule: minimum-RTT bins of
data_processing.minimum_interval_minutes, the latency jump threshold of
latency_jump.threshold, the significance level of
jitter_analysis.significance_level and the device of
change_point_detection.bcp_device. The fields below are specific to the
Bayesian online change point detector and to the two-stage verdicts.
Attributes:
| Name | Type | Description |
|---|---|---|
backend |
Literal['bocpd', 'window']
|
|
window_hours |
float
|
Length of the trailing window of the |
rerun_every_bins |
int
|
Closed bins between two reruns of the |
stable_runs |
int
|
Consecutive reruns in which a change point or a verdict must be identical before
the |
hazard_lambda |
float
|
Expected run length in bins (constant hazard |
decision |
Literal['map', 'lag', 'window']
|
Change point rule. |
lag |
int
|
Decision delay in bins for the |
threshold |
float
|
Posterior threshold for the |
max_run_length |
int or None
|
Run lengths kept by the detector (bounds memory and time per bin); |
min_time_elapsed |
int
|
Minimum seconds between change points. The MAP rule refines a boundary a few bins after first reporting it; one hour absorbs those refinements. |
revise_change_points |
bool
|
|
prior_alpha, prior_beta, prior_kappa |
float
|
Normal-Gamma prior of the Student-t predictive (see |
prior_mu |
float or None
|
Prior mean; |
min_ks_statistic |
float
|
Smallest Kolmogorov-Smirnov statistic that counts as a jitter change (effect-size
guard, 0-1); |
min_period_samples |
int
|
Jitter samples the open period must hold before a provisional verdict. About
three 15-minute bins on the paper dataset; 30 gives noisy p-values. With
|
state_change_bins |
int
|
Closed minimum-RTT bins of a new period the early state-change rule looks at
( |
InputConfig
¶
Bases: BaseModel
How raw input rows map to RTT samples: column names, units and row policies.
Every file reader and DataLoader.load_from_dataframe hand their rows to one
normalizer (jitterbug.io.normalize) that applies these settings. The defaults
are the historical contract: an epoch column in Unix seconds, an RTT column in
milliseconds named values, rtt_value, rtt or latency, duplicate
timestamps kept, out-of-range RTTs dropped and unsorted rows sorted. Jitterbug never
imputes or resamples.
Attributes:
| Name | Type | Description |
|---|---|---|
time_column |
str
|
Column holding the sample time. |
rtt_column |
str | None
|
Column holding the RTT. |
source_column, destination_column |
str
|
Optional columns kept as per-sample metadata; absent columns give |
time_unit |
Literal['s', 'ms', 'us', 'ns', 'iso', 'auto']
|
Unit of numeric times (Unix epoch in seconds, milliseconds, microseconds or
nanoseconds), or |
rtt_unit |
Literal['ms', 'us', 's', 'ns']
|
Unit of the RTT column; values are converted to milliseconds. |
delimiter |
str | None
|
Field separator of CSV-like files. |
duplicates |
Literal['keep', 'first', 'min', 'error']
|
Rows sharing a timestamp: keep them all, keep the first in file order, keep the one with the lowest RTT, or raise. |
out_of_range |
Literal['drop', 'error']
|
RTTs that are not positive or exceed |
unsorted |
Literal['sort', 'error']
|
Rows not in time order: sort them (stable) or raise. |
group_by |
list[str]
|
Columns whose values identify a series; each distinct combination is loaded and
analyzed on its own, with the row policies applied per series. |
series |
dict[str, str]
|
Keep only the rows whose column equals the value ( |
SourceConfig
¶
Bases: BaseModel
A database query to read RTT samples from, instead of a file.
The query result goes through the same column mapping, units, row policies,
series filters and group_by as a file (InputConfig). Credentials are never
part of this model: passwords and tokens are read from environment variables when
the query runs, and a setting that looks like a secret is rejected.
Attributes:
| Name | Type | Description |
|---|---|---|
kind |
Literal['clickhouse', 'influxdb2', 'influxdb3', 'duckdb']
|
Back end: ClickHouse (SQL, |
host |
str | None
|
Server host name or address (ClickHouse, InfluxDB); |
port |
int | None
|
Server port; |
secure |
bool
|
Connect over HTTPS (ClickHouse, InfluxDB). |
database |
str | None
|
ClickHouse database, or InfluxDB 3 database (required there). |
user |
str | None
|
ClickHouse user; |
org |
str | None
|
InfluxDB 2 organization. |
language |
Literal['sql', 'influxql']
|
Query language for InfluxDB 3. |
path |
str | None
|
DuckDB database file; |
read_only |
bool
|
Open the DuckDB database file read-only (the default); never applies to an in-memory database. |
password_env |
str | None
|
Environment variable holding the ClickHouse password; |
token_env |
str | None
|
Environment variable holding the InfluxDB token; |
query |
str | None
|
Query text. A |
query_file |
Path | None
|
File holding the query text, read when the query runs; exclusive with |
secret_env()
¶
The environment variable this source reads its password or token from.
Returns:
| Type | Description |
|---|---|
str | None
|
|
JitterbugConfig
¶
Bases: BaseSettings
Main configuration class for Jitterbug.
Attributes:
| Name | Type | Description |
|---|---|---|
analysis_mode |
Literal['sequential', 'clustering']
|
|
change_point_detection |
ChangePointDetectionConfig
|
Configuration for change point detection. |
jitter_analysis |
JitterAnalysisConfig
|
Configuration for jitter analysis. |
latency_jump |
LatencyJumpConfig
|
Configuration for latency jump detection. |
data_processing |
DataProcessingConfig
|
Configuration for data processing. |
clustering |
ClusteringConfig
|
Configuration for the clustering mode. |
streaming |
StreamingConfig
|
Configuration for the online (streaming) mode. |
input |
InputConfig
|
Column mapping, units and row policies for loading RTT data. |
sources |
dict[str, SourceConfig]
|
Named database sources (profiles), selected with |
output_format |
Literal['json', 'csv', 'parquet']
|
Output format for results. |
verbose |
bool
|
Whether to enable verbose logging. |
from_file(config_path)
classmethod
¶
Load configuration from file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
Path
|
Path to configuration file (YAML or JSON). |
required |
Returns:
| Type | Description |
|---|---|
JitterbugConfig
|
Loaded configuration. |
to_file(config_path)
¶
Save configuration to file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
Path
|
Path to save configuration file. |
required |
secret_rejection(key, kind)
¶
The error for a secret found under key: where the secret should come from instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The offending setting or URI part ( |
required |
kind
|
str | None
|
The back end, to name its environment variable; |
required |
Returns:
| Type | Description |
|---|---|
str
|
Message that never contains the secret itself. |