forked from mirror/client_golang
Remove deprecated DefObjectives from Summary
Signed-off-by: beorn7 <beorn@soundcloud.com>
This commit is contained in:
parent
0cb0b3eaf6
commit
1cb875e111
|
@ -231,13 +231,6 @@ func TestHistogramVecConcurrency(t *testing.T) {
|
|||
|
||||
rand.Seed(42)
|
||||
|
||||
objectives := make([]float64, 0, len(DefObjectives))
|
||||
for qu := range DefObjectives {
|
||||
|
||||
objectives = append(objectives, qu)
|
||||
}
|
||||
sort.Float64s(objectives)
|
||||
|
||||
it := func(n uint32) bool {
|
||||
mutations := int(n%1e4 + 1e4)
|
||||
concLevel := int(n%7 + 1)
|
||||
|
|
|
@ -256,8 +256,9 @@ collected metric "name" { label:<name:"constname" value:"\377" > label:<name:"la
|
|||
`)
|
||||
|
||||
summary := prometheus.NewSummary(prometheus.SummaryOpts{
|
||||
Name: "complex",
|
||||
Help: "A metric to check collisions with _sum and _count.",
|
||||
Name: "complex",
|
||||
Help: "A metric to check collisions with _sum and _count.",
|
||||
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
|
||||
})
|
||||
summaryAsText := []byte(`# HELP complex A metric to check collisions with _sum and _count.
|
||||
# TYPE complex summary
|
||||
|
|
|
@ -56,16 +56,8 @@ type Summary interface {
|
|||
Observe(float64)
|
||||
}
|
||||
|
||||
// DefObjectives are the default Summary quantile values.
|
||||
//
|
||||
// Deprecated: DefObjectives will not be used as the default objectives in
|
||||
// v0.10 of the library. The default Summary will have no quantiles then.
|
||||
var (
|
||||
DefObjectives = map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}
|
||||
|
||||
errQuantileLabelNotAllowed = fmt.Errorf(
|
||||
"%q is not allowed as label name in summaries", quantileLabel,
|
||||
)
|
||||
var errQuantileLabelNotAllowed = fmt.Errorf(
|
||||
"%q is not allowed as label name in summaries", quantileLabel,
|
||||
)
|
||||
|
||||
// Default values for SummaryOpts.
|
||||
|
@ -121,13 +113,8 @@ type SummaryOpts struct {
|
|||
// Objectives defines the quantile rank estimates with their respective
|
||||
// absolute error. If Objectives[q] = e, then the value reported for q
|
||||
// will be the φ-quantile value for some φ between q-e and q+e. The
|
||||
// default value is DefObjectives. It is used if Objectives is left at
|
||||
// its zero value (i.e. nil). To create a Summary without Objectives,
|
||||
// set it to an empty map (i.e. map[float64]float64{}).
|
||||
//
|
||||
// Deprecated: Note that the current value of DefObjectives is
|
||||
// deprecated. It will be replaced by an empty map in v0.10 of the
|
||||
// library. Please explicitly set Objectives to the desired value.
|
||||
// default value is an empty map, resulting in a summary without
|
||||
// quantiles.
|
||||
Objectives map[float64]float64
|
||||
|
||||
// MaxAge defines the duration for which an observation stays relevant
|
||||
|
@ -196,7 +183,7 @@ func newSummary(desc *Desc, opts SummaryOpts, labelValues ...string) Summary {
|
|||
}
|
||||
|
||||
if opts.Objectives == nil {
|
||||
opts.Objectives = DefObjectives
|
||||
opts.Objectives = map[float64]float64{}
|
||||
}
|
||||
|
||||
if opts.MaxAge < 0 {
|
||||
|
|
|
@ -39,8 +39,8 @@ func TestSummaryWithDefaultObjectives(t *testing.T) {
|
|||
if err := summaryWithDefaultObjectives.Write(m); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if len(m.GetSummary().Quantile) != len(DefObjectives) {
|
||||
t.Error("expected default objectives in summary")
|
||||
if len(m.GetSummary().Quantile) != 0 {
|
||||
t.Error("expected no objectives in summary")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,6 +189,7 @@ func TestSummaryConcurrency(t *testing.T) {
|
|||
}
|
||||
|
||||
rand.Seed(42)
|
||||
objMap := map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}
|
||||
|
||||
it := func(n uint32) bool {
|
||||
mutations := int(n%1e4 + 1e4)
|
||||
|
@ -202,7 +203,7 @@ func TestSummaryConcurrency(t *testing.T) {
|
|||
sum := NewSummary(SummaryOpts{
|
||||
Name: "test_summary",
|
||||
Help: "helpless",
|
||||
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
|
||||
Objectives: objMap,
|
||||
})
|
||||
|
||||
allVars := make([]float64, total)
|
||||
|
@ -237,14 +238,14 @@ func TestSummaryConcurrency(t *testing.T) {
|
|||
t.Errorf("got sample sum %f, want %f", got, want)
|
||||
}
|
||||
|
||||
objectives := make([]float64, 0, len(DefObjectives))
|
||||
for qu := range DefObjectives {
|
||||
objectives = append(objectives, qu)
|
||||
objSlice := make([]float64, 0, len(objMap))
|
||||
for qu := range objMap {
|
||||
objSlice = append(objSlice, qu)
|
||||
}
|
||||
sort.Float64s(objectives)
|
||||
sort.Float64s(objSlice)
|
||||
|
||||
for i, wantQ := range objectives {
|
||||
ε := DefObjectives[wantQ]
|
||||
for i, wantQ := range objSlice {
|
||||
ε := objMap[wantQ]
|
||||
gotQ := *m.Summary.Quantile[i].Quantile
|
||||
gotV := *m.Summary.Quantile[i].Value
|
||||
min, max := getBounds(allVars, wantQ, ε)
|
||||
|
@ -269,13 +270,14 @@ func TestSummaryVecConcurrency(t *testing.T) {
|
|||
}
|
||||
|
||||
rand.Seed(42)
|
||||
objMap := map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}
|
||||
|
||||
objectives := make([]float64, 0, len(DefObjectives))
|
||||
for qu := range DefObjectives {
|
||||
objSlice := make([]float64, 0, len(objMap))
|
||||
for qu := range objMap {
|
||||
|
||||
objectives = append(objectives, qu)
|
||||
objSlice = append(objSlice, qu)
|
||||
}
|
||||
sort.Float64s(objectives)
|
||||
sort.Float64s(objSlice)
|
||||
|
||||
it := func(n uint32) bool {
|
||||
mutations := int(n%1e4 + 1e4)
|
||||
|
@ -290,7 +292,7 @@ func TestSummaryVecConcurrency(t *testing.T) {
|
|||
SummaryOpts{
|
||||
Name: "test_summary",
|
||||
Help: "helpless",
|
||||
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
|
||||
Objectives: objMap,
|
||||
},
|
||||
[]string{"label"},
|
||||
)
|
||||
|
@ -333,8 +335,8 @@ func TestSummaryVecConcurrency(t *testing.T) {
|
|||
if got, want := *m.Summary.SampleSum, sampleSums[i]; math.Abs((got-want)/want) > 0.001 {
|
||||
t.Errorf("got sample sum %f for label %c, want %f", got, 'A'+i, want)
|
||||
}
|
||||
for j, wantQ := range objectives {
|
||||
ε := DefObjectives[wantQ]
|
||||
for j, wantQ := range objSlice {
|
||||
ε := objMap[wantQ]
|
||||
gotQ := *m.Summary.Quantile[j].Quantile
|
||||
gotV := *m.Summary.Quantile[j].Value
|
||||
min, max := getBounds(allVars[i], wantQ, ε)
|
||||
|
|
Loading…
Reference in New Issue