Conversation
rakyll
left a comment
There was a problem hiding this comment.
Left some comments, otherwise LGTM.
|
|
||
| // Register the view. It is imperative that this step exists, | ||
| // otherwise recorded metrics will be dropped and never exported. | ||
| if err := view.Register(latencyView); err != nil { |
There was a problem hiding this comment.
Create this view inline. You don't need this view elsewhere.
if err := view.Register(&view.View{
Name: "demo/latency",
Measure: latencyMs,
Description: "The distribution of the latencies",
// Latency in buckets:
// [>=0ms, >=100ms, >=200ms, >=400ms, >=1s, >=2s, >=4s]
Aggregation: view.Distribution(0, 100, 200, 400, 1000, 2000, 4000),
}); err != nil {
|
|
||
| func main() { | ||
| if projectID == "" { | ||
| log.Fatal("The GOOGLE_CLOUD_PROJECT environment variable must be set.") |
There was a problem hiding this comment.
stackdriver.NewExporter resolves the project ID from the ADC, this env var is not required.
| // for more details. | ||
| exporter, err := stackdriver.NewExporter(stackdriver.Options{ | ||
| ProjectID: projectID, | ||
| MetricPrefix: "my-metrics", |
There was a problem hiding this comment.
Please avoid this prefix, metric prefix is not something most users will need.
| latencyMs = stats.Float64("demo/latency", "The latency in milliseconds", "ms") | ||
|
|
||
| latencyView = &view.View{ | ||
| Name: "demo/latency", |
There was a problem hiding this comment.
The name of the metric should represent what latency this is? Request latency, task latency, etc?
|
|
||
| func main() { | ||
| if projectID == "" { | ||
| log.Fatal("The GOOGLE_CLOUD_PROJECT environment variable must be set.") |
|
|
||
| // Register the view. It is imperative that this step exists, | ||
| // otherwise recorded metrics will be dropped and never exported. | ||
| if err := view.Register(latencyView); err != nil { |
| // for more details. | ||
| exporter, err := stackdriver.NewExporter(stackdriver.Options{ | ||
| ProjectID: projectID, | ||
| MetricPrefix: "my-metrics", |
| latencyMs = stats.Float64("demo/latency", "The latency in milliseconds", "ms") | ||
|
|
||
| latencyView = &view.View{ | ||
| Name: "demo/latency", |
No description provided.