Documentation ¶
Index ¶
- func CleanObjectName(o string) string
- func Float64(s string) (float64, bool)
- func FormatPercentile(f float64) string
- func INList(objs []string, quoteChar string) string
- func MySQLVersion(ctx context.Context, db *sql.DB) (int, int, int)
- func MySQLVersionGTE(version string, db *sql.DB, ctx context.Context) (bool, error)
- func ObjectList(csv string, quoteChar string) []string
- func ParsePercentileStr(percentileStr string) (float64, error)
- func ReadOnly(err error) bool
- func RowToMap(ctx context.Context, db *sql.DB, query string) (map[string]string, error)
- func SanitizeTable(table, db string) string
- type P
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanObjectName ¶
func Float64 ¶
Float64 converts string to float64. If successful, it returns the float64 value and true, else it returns 0, false.
func FormatPercentile ¶
FormatPercentile formats a percentile into the form pNNN where NNN is the percentile up to 1 decimal point. For example, 0.99 returns "p99".
func MySQLVersion ¶
MySQLVersion returns the MySQL version as integers: major, minor, patch.
func MySQLVersionGTE ¶
MySQLVersionGTE returns true if the current MySQL version is >= version. It returns false on any error.
func ObjectList ¶
func ParsePercentileStr ¶
ParsePercentileStr coverts a string of percentile in different form to the percentile as decimal. There are 3 kind of forms, like P99.9 has form 0.999, form 99.9 or form 999. All should be parsed as 0.999
func ReadOnly ¶
ReadOnly returns true if the err is a MySQL read-only error caused by writing to a read-only instance.
func RowToMap ¶
RowToMap converts a single row from query (or the last row) to a map of strings keyed on column name. All row values a converted to strings. This is used for one-row command outputs like SHOW SLAVE|REPLICA STATUS that have a mix of values and variaible columns (based on MySQL version) but the caller only needs specific cols/vals, so it uses this generic map rather than a specific struct.
func SanitizeTable ¶
Types ¶
type P ¶
func PercentileMetrics ¶
PercentileMetrics returns the list of percentile strings like "P95" in standard form (lowercase "p95") and decimal (0.95). It's used to process the metrics list for percentile collectors like query.response-time.