Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Commit

Permalink
Remove ToAggregation
Browse files Browse the repository at this point in the history
Instead of having the temporary bridge, fix the user's code.

Also contains some godoc improvements.
  • Loading branch information
rakyll committed Mar 21, 2018
1 parent b34c686 commit fd47890
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 37 deletions.
24 changes: 6 additions & 18 deletions stats/view/aggregation.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,18 @@ package view
type AggType int

const (
// AggTypeNone represents no aggregation. Reserved for future use.
AggTypeNone AggType = iota
// AggTypeCount represents the count aggregation, See Count().
AggTypeCount
// AggTypeSum represents the sum aggregation, See Sum().
AggTypeSum
// AggTypeMean represents the mean aggregation, see Mean()
AggTypeMean
// AggTypeDistribution represents a distribution aggregation, see Distribution().
AggTypeDistribution
AggTypeNone AggType = iota // no aggregation; reserved for future use.
AggTypeCount // the count aggregation, see Count.
AggTypeSum // the sum aggregation, see Sum.
AggTypeMean // the mean aggregation, see Mean.
AggTypeDistribution // the distribution aggregation, see Distribution.
)

// Aggregation represents a data aggregation method. Use one of the functions:
// Count, Sum, Mean, or Distribution to construct an Aggregation.
type Aggregation struct {
Type AggType // Type is the AggType of this Aggregation.
Buckets []float64 // Buckets are the bucket endpoints if this Aggregation represents a distribution, see: Distribution().
Buckets []float64 // Buckets are the bucket endpoints if this Aggregation represents a distribution, see Distribution.

newData func() AggregationData
}
Expand Down Expand Up @@ -71,13 +66,6 @@ func Count() *Aggregation {
return aggCount
}

// SumAggregation indicates that data collected and aggregated
// with this method will be summed up.
// For example, accumulated request bytes can be aggregated by using
// SumAggregation.
// Deprecated: Use the Sum function to construct.
type SumAggregation struct{}

// Sum indicates that data collected and aggregated
// with this method will be summed up.
// For example, accumulated request bytes can be aggregated by using
Expand Down
21 changes: 2 additions & 19 deletions stats/view/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type View struct {
}

// Deprecated: Use &View{}.
func New(name, description string, keys []tag.Key, measure stats.Measure, agg ToAggregation) (*View, error) {
func New(name, description string, keys []tag.Key, measure stats.Measure, agg *Aggregation) (*View, error) {
if measure == nil {
panic("measure may not be nil")
}
Expand All @@ -56,27 +56,10 @@ func New(name, description string, keys []tag.Key, measure stats.Measure, agg To
Description: description,
TagKeys: keys,
Measure: measure,
Aggregation: agg.ToAggregation(),
Aggregation: agg,
}, nil
}

// ToAggregation is a temporary bridge for SumAggregation to Aggregation. It is
// needed to support existing external uses of SumAggregation in cloud.google.com/go
// and should be removed once those are removed.
type ToAggregation interface {
ToAggregation() *Aggregation
}

// ToAggregation returns Sum.
func (s SumAggregation) ToAggregation() *Aggregation {
return Sum()
}

// ToAggregation returns the receiver.
func (a *Aggregation) ToAggregation() *Aggregation {
return a
}

// WithName returns a copy of the View with a new name. This is useful for
// renaming views to cope with limitations placed on metric names by various
// backends.
Expand Down

0 comments on commit fd47890

Please sign in to comment.