Sloth uses a plugin system to modify the SLO generation process. You can define a chain of SLOPlugin objects.
Plugin Priority
Priority determines the execution order in the chain.
- Lower numbers have higher priority (executed earlier).
- Default plugins use priority
0. - To execute plugins before the defaults, use negative priority (e.g.,
-100). - To execute plugins after the defaults, use positive priority (e.g.,
100). - It is recommended to use large gaps between priority numbers (e.g.,
10, 100, 1000, -200, -1000) to allow for future insertions.
Overriding Plugins
Using SLOPlugins, you can control how plugins are inherited:
- If
OverridePrevious is set to true, it overrides the plugins declared at higher levels. - The declaration order is:
default plugins -> SLO Group plugins -> SLO plugins.
type SLOPlugin struct {
// ID is the ID of the plugin to load .
ID string `json:"id"`
// Config is the configuration used on the plugin instance creation.
Config json.RawMessage `json:"config,omitempty"`
// Priority is the priority of the plugin in the chain. The lower the number
// the higher the priority. The first plugin will be the one with the lowest
// priority. The default plugins loaded by Sloth use `0` priority. If you want to
// execute plugins before the default ones, you can use negative priority.
// It is recommended to use round gaps of numbers like 10, 100, 1000, -200, -1000...
Priority int `json:"priority,omitempty"`
}
type SLOPlugins struct {
// OverridePrevious will override the previous SLO plugins declared.
// Depending on where this SLO plugins block declared will override:
// - If declared at SLO group level: Overrides the default plugins.
// - If declared at SLO level: Overrides the default + SLO group plugins.
// The declaration order is default plugins -> SLO Group plugins -> SLO plugins.
OverridePrevious bool `json:"overridePrevious,omitempty"`
// Chain is the list of plugin chain to add to the SLO generation.
Chain []SLOPlugin `json:"chain"`
}