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

Commit

Permalink
DistributionAggregation([]float64{...}) to DistributionAggregation{} (#…
Browse files Browse the repository at this point in the history
…538)

DistributionAggregation's type declaration is
type DistributionAggregation []float64
therefore float64 values can be added to it directly
e.g:
  DistributionAggregation{0, 10, 25.3}
  • Loading branch information
Emmanuel T Odeke authored and Ramon Nogueira committed Mar 8, 2018
1 parent 09d3108 commit bbc3874
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rapidly, vendoring is recommended.
## Installation

```
$ go get -u go.opencensus.io/...
$ go get -u go.opencensus.io
```

## Prerequisites
Expand Down Expand Up @@ -147,7 +147,7 @@ Currently four types of aggregations are supported:

[embedmd]:# (stats.go aggs)
```go
distAgg := view.DistributionAggregation([]float64{0, 1 << 32, 2 << 32, 3 << 32})
distAgg := view.DistributionAggregation{0, 1 << 32, 2 << 32, 3 << 32}
countAgg := view.CountAggregation{}
sumAgg := view.SumAggregation{}
meanAgg := view.MeanAggregation{}
Expand All @@ -163,10 +163,10 @@ err = view.Subscribe(&view.View{
Name: "my.org/video_size_distribution",
Description: "distribution of processed video size over time",
Measure: videoSize,
Aggregation: view.DistributionAggregation([]float64{0, 1 << 32, 2 << 32, 3 << 32}),
Aggregation: view.DistributionAggregation{0, 1 << 32, 2 << 32, 3 << 32},
})
if err != nil {
log.Fatal(err)
log.Fatalf("Failed to subscribe to view: %v", err)
}
```

Expand Down
2 changes: 1 addition & 1 deletion examples/helloworld/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func main() {
Description: "processed video size over time",
TagKeys: []tag.Key{frontendKey},
Measure: videoSize,
Aggregation: view.DistributionAggregation([]float64{0, 1 << 16, 1 << 32}),
Aggregation: view.DistributionAggregation{0, 1 << 16, 1 << 32},
})
if err != nil {
log.Fatalf("Cannot subscribe to the view: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion examples/stats/prometheus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func main() {
Name: "video_size",
Description: "processed video size over time",
Measure: videoSize,
Aggregation: view.DistributionAggregation([]float64{0, 1 << 16, 1 << 32}),
Aggregation: view.DistributionAggregation{0, 1 << 16, 1 << 32},
},
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion examples/stats/stackdriver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func main() {
Name: "my.org/views/video_size_cum",
Description: "processed video size over time",
Measure: videoSize,
Aggregation: view.DistributionAggregation([]float64{0, 1 << 16, 1 << 32}),
Aggregation: view.DistributionAggregation{0, 1 << 16, 1 << 32},
})
if err != nil {
log.Fatalf("Cannot subscribe to the view: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion exporter/stackdriver/stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestExporter_makeReq(t *testing.T) {
Name: "distview",
Description: "desc",
Measure: m,
Aggregation: view.DistributionAggregation([]float64{2, 4, 7}),
Aggregation: view.DistributionAggregation{2, 4, 7},
}

start := time.Now()
Expand Down
4 changes: 2 additions & 2 deletions internal/readme/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func statsExamples() {
_ = m

// START aggs
distAgg := view.DistributionAggregation([]float64{0, 1 << 32, 2 << 32, 3 << 32})
distAgg := view.DistributionAggregation{0, 1 << 32, 2 << 32, 3 << 32}
countAgg := view.CountAggregation{}
sumAgg := view.SumAggregation{}
meanAgg := view.MeanAggregation{}
Expand All @@ -61,7 +61,7 @@ func statsExamples() {
Name: "my.org/video_size_distribution",
Description: "distribution of processed video size over time",
Measure: videoSize,
Aggregation: view.DistributionAggregation([]float64{0, 1 << 32, 2 << 32, 3 << 32}),
Aggregation: view.DistributionAggregation{0, 1 << 32, 2 << 32, 3 << 32},
})
if err != nil {
log.Fatalf("Failed to subscribe to view: %v", err)
Expand Down
6 changes: 3 additions & 3 deletions plugin/ocgrpc/stats_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ type rpcData struct {
// The following variables define the default hard-coded auxiliary data used by
// both the default GRPC client and GRPC server metrics.
var (
DefaultBytesDistribution = view.DistributionAggregation([]float64{0, 1024, 2048, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864, 268435456, 1073741824, 4294967296})
DefaultMillisecondsDistribution = view.DistributionAggregation([]float64{0, 1, 2, 3, 4, 5, 6, 8, 10, 13, 16, 20, 25, 30, 40, 50, 65, 80, 100, 130, 160, 200, 250, 300, 400, 500, 650, 800, 1000, 2000, 5000, 10000, 20000, 50000, 100000})
DefaultMessageCountDistribution = view.DistributionAggregation([]float64{0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536})
DefaultBytesDistribution = view.DistributionAggregation{0, 1024, 2048, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864, 268435456, 1073741824, 4294967296}
DefaultMillisecondsDistribution = view.DistributionAggregation{0, 1, 2, 3, 4, 5, 6, 8, 10, 13, 16, 20, 25, 30, 40, 50, 65, 80, 100, 130, 160, 200, 250, 300, 400, 500, 650, 800, 1000, 2000, 5000, 10000, 20000, 50000, 100000}
DefaultMessageCountDistribution = view.DistributionAggregation{0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536}
)

var (
Expand Down
4 changes: 2 additions & 2 deletions plugin/ochttp/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ var (
)

var (
DefaultSizeDistribution = view.DistributionAggregation([]float64{0, 1024, 2048, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864, 268435456, 1073741824, 4294967296})
DefaultLatencyDistribution = view.DistributionAggregation([]float64{0, 1, 2, 3, 4, 5, 6, 8, 10, 13, 16, 20, 25, 30, 40, 50, 65, 80, 100, 130, 160, 200, 250, 300, 400, 500, 650, 800, 1000, 2000, 5000, 10000, 20000, 50000, 100000})
DefaultSizeDistribution = view.DistributionAggregation{0, 1024, 2048, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864, 268435456, 1073741824, 4294967296}
DefaultLatencyDistribution = view.DistributionAggregation{0, 1, 2, 3, 4, 5, 6, 8, 10, 13, 16, 20, 25, 30, 40, 50, 65, 80, 100, 130, 160, 200, 250, 300, 400, 500, 650, 800, 1000, 2000, 5000, 10000, 20000, 50000, 100000}
)

// Package ochttp provides some convenience views.
Expand Down
2 changes: 1 addition & 1 deletion stats/view/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func Example() {
Name: "my.org/views/openconns",
Description: "open connections",
Measure: m,
Aggregation: view.DistributionAggregation([]float64{0, 1000, 2000}),
Aggregation: view.DistributionAggregation{0, 1000, 2000},
})
if err != nil {
log.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion stats/view/view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func Test_View_MeasureFloat64_AggregationDistribution(t *testing.T) {
k1, _ := tag.NewKey("k1")
k2, _ := tag.NewKey("k2")
k3, _ := tag.NewKey("k3")
agg1 := DistributionAggregation([]float64{2})
agg1 := DistributionAggregation{2}
m, _ := stats.Int64("Test_View_MeasureFloat64_AggregationDistribution/m1", "", stats.UnitNone)
view1 := &View{
TagKeys: []tag.Key{k1, k2},
Expand Down

0 comments on commit bbc3874

Please sign in to comment.