Update go dependencies
This commit is contained in:
parent
14a9e9f3fa
commit
14f4a7b8e8
1349 changed files with 128369 additions and 32627 deletions
45
vendor/go.opencensus.io/stats/view/view.go
generated
vendored
45
vendor/go.opencensus.io/stats/view/view.go
generated
vendored
|
|
@ -17,6 +17,7 @@ package view
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sort"
|
||||
|
|
@ -26,7 +27,6 @@ import (
|
|||
"go.opencensus.io/exemplar"
|
||||
|
||||
"go.opencensus.io/stats"
|
||||
"go.opencensus.io/stats/internal"
|
||||
"go.opencensus.io/tag"
|
||||
)
|
||||
|
||||
|
|
@ -69,6 +69,11 @@ func (v *View) same(other *View) bool {
|
|||
v.Measure.Name() == other.Measure.Name()
|
||||
}
|
||||
|
||||
// ErrNegativeBucketBounds error returned if histogram contains negative bounds.
|
||||
//
|
||||
// Deprecated: this should not be public.
|
||||
var ErrNegativeBucketBounds = errors.New("negative bucket bounds not supported")
|
||||
|
||||
// canonicalize canonicalizes v by setting explicit
|
||||
// defaults for Name and Description and sorting the TagKeys
|
||||
func (v *View) canonicalize() error {
|
||||
|
|
@ -90,9 +95,27 @@ func (v *View) canonicalize() error {
|
|||
sort.Slice(v.TagKeys, func(i, j int) bool {
|
||||
return v.TagKeys[i].Name() < v.TagKeys[j].Name()
|
||||
})
|
||||
sort.Float64s(v.Aggregation.Buckets)
|
||||
for _, b := range v.Aggregation.Buckets {
|
||||
if b < 0 {
|
||||
return ErrNegativeBucketBounds
|
||||
}
|
||||
}
|
||||
// drop 0 bucket silently.
|
||||
v.Aggregation.Buckets = dropZeroBounds(v.Aggregation.Buckets...)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dropZeroBounds(bounds ...float64) []float64 {
|
||||
for i, bound := range bounds {
|
||||
if bound > 0 {
|
||||
return bounds[i:]
|
||||
}
|
||||
}
|
||||
return []float64{}
|
||||
}
|
||||
|
||||
// viewInternal is the internal representation of a View.
|
||||
type viewInternal struct {
|
||||
view *View // view is the canonicalized View definition associated with this view.
|
||||
|
|
@ -174,11 +197,23 @@ func (r *Row) Equal(other *Row) bool {
|
|||
return reflect.DeepEqual(r.Tags, other.Tags) && r.Data.equal(other.Data)
|
||||
}
|
||||
|
||||
func checkViewName(name string) error {
|
||||
if len(name) > internal.MaxNameLength {
|
||||
return fmt.Errorf("view name cannot be larger than %v", internal.MaxNameLength)
|
||||
const maxNameLength = 255
|
||||
|
||||
// Returns true if the given string contains only printable characters.
|
||||
func isPrintable(str string) bool {
|
||||
for _, r := range str {
|
||||
if !(r >= ' ' && r <= '~') {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if !internal.IsPrintable(name) {
|
||||
return true
|
||||
}
|
||||
|
||||
func checkViewName(name string) error {
|
||||
if len(name) > maxNameLength {
|
||||
return fmt.Errorf("view name cannot be larger than %v", maxNameLength)
|
||||
}
|
||||
if !isPrintable(name) {
|
||||
return fmt.Errorf("view name needs to be an ASCII string")
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue