Documentation ¶
Overview ¶
Package metriclint provides a serials functions to lint a metric. The implementation base on [promlint](github.com/prometheus/client_golang/prometheus/testutil/promlint).
metriclint provides a ability to lint a metric at the registry which is different with promlint. The lint rules also base on promlint but we may add more rules if necessary.
Index ¶
- Constants
- type LintResult
- func LintCounter(counterOpts prometheus.CounterOpts) *LintResult
- func LintCounterVector(counterOpts prometheus.CounterOpts, labelNames []string) *LintResult
- func LintGauge(gaugeOpts prometheus.GaugeOpts) *LintResult
- func LintGaugeVector(gaugeOpts prometheus.GaugeOpts, labelNames []string) *LintResult
- func LintHistogram(histogramOpts prometheus.HistogramOpts) *LintResult
- func LintHistogramVector(histogramOpts prometheus.HistogramOpts, labelNames []string) *LintResult
- func LintSummary(summaryOpts prometheus.SummaryOpts) *LintResult
- func LintSummaryVector(summaryOpts prometheus.SummaryOpts, labelNames []string) *LintResult
Constants ¶
View Source
const ( NameSuffixSum = "_sum" LabelLe = "le" LabelQuantile = "quantile" )
View Source
const ( LintErrMsgNoHelp = "no help text" LintErrMsgNonBaseUnit = `use base unit "%s" instead of "%s"` LintErrMsgCounterShouldHaveTotalSuffix = `counter metrics should have "_total" suffix` LintErrMsgNonCounterShouldNotHaveTotalSuffix = `non-counter metrics should not have "_total" suffix` LintErrMsgNonHistogramShouldNotHaveBucketSuffix = `non-histogram metrics should not have "_bucket" suffix` LintErrMsgNonHistogramSummaryShouldNotHaveCountSuffix = `non-histogram and non-summary metrics should not have "_count" suffix` LintErrMsgMonHistogramSummaryShouldNotHaveSumSuffix = `non-histogram and non-summary metrics should not have "_sum" suffix` LintErrMsgNonHistogramShouldNotHaveLeLabel = `non-histogram metrics should not have "le" label` LintErrMsgNonSummaryShouldNotHaveQuantileLabel = `non-summary metrics should not have "quantile" label` LintErrMsgNoMetricType = `metric name should not include type '%s'` LintErrMsgNoReservedChars = `metric names should not contain ':'` LintErrMsgNameShouldBeSnakeCase = `metric names should be written in 'snake_case' not 'camelCase'` LintErrMsgLabelShouldBeSnakeCase = `label names should be written in 'snake_case' not 'camelCase'` LintErrMsgNameShouldNotHaveAbbr = `metric names should not contain abbreviated units` )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LintResult ¶
type LintResult struct { // The FQName of a metric. MetricName string // one or more lint errors of the metric. Issues []string }
LintResult represents lint result of a specific metric.
func LintCounter ¶
func LintCounter(counterOpts prometheus.CounterOpts) *LintResult
func LintCounterVector ¶
func LintCounterVector(counterOpts prometheus.CounterOpts, labelNames []string) *LintResult
func LintGauge ¶
func LintGauge(gaugeOpts prometheus.GaugeOpts) *LintResult
func LintGaugeVector ¶
func LintGaugeVector(gaugeOpts prometheus.GaugeOpts, labelNames []string) *LintResult
func LintHistogram ¶
func LintHistogram(histogramOpts prometheus.HistogramOpts) *LintResult
func LintHistogramVector ¶
func LintHistogramVector(histogramOpts prometheus.HistogramOpts, labelNames []string) *LintResult
func LintSummary ¶
func LintSummary(summaryOpts prometheus.SummaryOpts) *LintResult
func LintSummaryVector ¶
func LintSummaryVector(summaryOpts prometheus.SummaryOpts, labelNames []string) *LintResult
func (*LintResult) String ¶
func (lr *LintResult) String() string
Click to show internal directories.
Click to hide internal directories.