mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fn: stats view/distribution improvements (#1154)
* fn: stats view/distribution improvements *) View latency distribution is now an argument in view creation functions. This allows easier override to set custom buckets. It is simplistic and assumes all latency views would use the same set, but in practice this is already the case. *) Removed API view creation to main, this should not be enabled for all node types. This is consistent with the rest of the system. * fn: Docker samples of cpu/mem/disk with specific buckets
This commit is contained in:
34
api/common/stats_utils.go
Normal file
34
api/common/stats_utils.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"go.opencensus.io/stats"
|
||||
"go.opencensus.io/stats/view"
|
||||
"go.opencensus.io/tag"
|
||||
)
|
||||
|
||||
func CreateView(measure stats.Measure, agg *view.Aggregation, tagKeys []string) *view.View {
|
||||
return &view.View{
|
||||
Name: measure.Name(),
|
||||
Description: measure.Description(),
|
||||
Measure: measure,
|
||||
TagKeys: makeKeys(tagKeys),
|
||||
Aggregation: agg,
|
||||
}
|
||||
}
|
||||
|
||||
func MakeMeasure(name string, desc string, unit string) *stats.Int64Measure {
|
||||
return stats.Int64(name, desc, unit)
|
||||
}
|
||||
|
||||
func makeKeys(names []string) []tag.Key {
|
||||
tagKeys := make([]tag.Key, len(names))
|
||||
for i, name := range names {
|
||||
key, err := tag.NewKey(name)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
tagKeys[i] = key
|
||||
}
|
||||
return tagKeys
|
||||
}
|
||||
Reference in New Issue
Block a user