...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package readme
17
18 import (
19 "context"
20 "log"
21
22 "go.opencensus.io/stats"
23 "go.opencensus.io/stats/view"
24 )
25
26
27
28
29 func statsExamples() {
30 ctx := context.Background()
31
32 videoSize := stats.Int64("example.com/video_size", "processed video size", "MB")
33
34
35 distAgg := view.Distribution(1<<32, 2<<32, 3<<32)
36 countAgg := view.Count()
37 sumAgg := view.Sum()
38
39
40 _, _, _ = distAgg, countAgg, sumAgg
41
42
43 if err := view.Register(&view.View{
44 Name: "example.com/video_size_distribution",
45 Description: "distribution of processed video size over time",
46 Measure: videoSize,
47 Aggregation: view.Distribution(1<<32, 2<<32, 3<<32),
48 }); err != nil {
49 log.Fatalf("Failed to register view: %v", err)
50 }
51
52
53
54 stats.Record(ctx, videoSize.M(102478))
55
56 }
57
View as plain text