-
Notifications
You must be signed in to change notification settings - Fork 1.8k
opencensus: add metrics quickstart #646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
rakyll
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
|
||
| func main() { | ||
| if projectID == "" { | ||
| log.Fatal("The GOOGLE_CLOUD_PROJECT environment variable must be set.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stackdriver.NewExporter resolves the project ID from the ADC, this env var is not required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| // for more details. | ||
| exporter, err := stackdriver.NewExporter(stackdriver.Options{ | ||
| ProjectID: projectID, | ||
| MetricPrefix: "my-metrics", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid this prefix, metric prefix is not something most users will need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| latencyMs = stats.Float64("demo/latency", "The latency in milliseconds", "ms") | ||
|
|
||
| latencyView = &view.View{ | ||
| Name: "demo/latency", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of the metric should represent what latency this is? Request latency, task latency, etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
tbpg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
|
|
||
| func main() { | ||
| if projectID == "" { | ||
| log.Fatal("The GOOGLE_CLOUD_PROJECT environment variable must be set.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
|
||
| // 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| // for more details. | ||
| exporter, err := stackdriver.NewExporter(stackdriver.Options{ | ||
| ProjectID: projectID, | ||
| MetricPrefix: "my-metrics", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| latencyMs = stats.Float64("demo/latency", "The latency in milliseconds", "ms") | ||
|
|
||
| latencyView = &view.View{ | ||
| Name: "demo/latency", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
No description provided.