Last active
March 18, 2018 14:14
-
-
Save avivl/32ed40cbbfb8bbc07e3b3ae07a161251 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"go.opencensus.io/stats" | |
"go.opencensus.io/tag" | |
"go.opencensus.io/stats/view" | |
) | |
var ( | |
requestCounter *stats.Float64Measure | |
requestlatency *stats.Float64Measure | |
codeKey tag.Key | |
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} | |
) | |
codeKey, _ = tag.NewKey("banias/keys/code") | |
requestCounter, _ = stats.Float64("banias/measures/request_count", "Count of HTTP requests processed", stats.UnitNone) | |
requestlatency, _ = stats.Float64("banias/measures/request_latency", "Latency distribution of HTTP requests", stats.UnitMilliseconds) | |
view.Subscribe( | |
&view.View{ | |
Name: "request_count", | |
Description: "Count of HTTP requests processed", | |
TagKeys: []tag.Key{codeKey}, | |
Measure: requestCounter, | |
Aggregation: view.CountAggregation{}, | |
}) | |
view.Subscribe( | |
&view.View{ | |
Name: "request_latency", | |
Description: "Latency distribution of HTTP requests", | |
TagKeys: []tag.Key{codeKey}, | |
Measure: requestlatency, | |
Aggregation: DefaultLatencyDistribution, | |
}) | |
view.SetReportingPeriod(1 * time.Second) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment