Skip to content
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

🌱 Monitoring: use opentelemetry for cron metrics #3503

Closed
wants to merge 2 commits into from

Conversation

raghavkaul
Copy link
Contributor

What kind of change does this PR introduce?

Use opentelemetry instead of opencensus

@raghavkaul raghavkaul temporarily deployed to gitlab September 25, 2023 21:21 — with GitHub Actions Inactive
@raghavkaul raghavkaul temporarily deployed to integration-test September 25, 2023 21:21 — with GitHub Actions Inactive
@codecov
Copy link

codecov bot commented Sep 25, 2023

Codecov Report

Merging #3503 (b79f9d7) into main (0ce62a8) will decrease coverage by 14.95%.
Report is 9 commits behind head on main.
The diff coverage is 13.79%.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #3503       +/-   ##
===========================================
- Coverage   74.30%   59.36%   -14.95%     
===========================================
  Files         187      175       -12     
  Lines       13378    12556      -822     
===========================================
- Hits         9941     7454     -2487     
- Misses       2878     4653     +1775     
+ Partials      559      449      -110     

Copy link
Member

@spencerschrock spencerschrock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some partial thoughts since this is still a draft. I'm unfamiliar with the migration, so trying to get some details there.

metric.WithDescription("Measures the retry delay when dealing with secondary rate limits"),
metric.WithUnit("s"))
if err != nil {
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's some unintentional shadowing here since you use c, err := above

Comment on lines +55 to +63
// // GithubTokens tracks the usage/remaining stats per token per resource-type.
//
// GithubTokens = view.View{
// Name: "GithubTokens",
// Description: "Token usage/remaining stats for Github API tokens",
// Measure: RemainingTokens,
// TagKeys: []tag.Key{TokenIndex, ResourceType},
// Aggregation: view.LastValue(),
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment should probably be removed?

if err != nil {
l.Warn(&LogMessage{Text: fmt.Sprintf("tag.New: %v", err)})
}

ctx, err = tag.New(ctx, tag.Upsert(stats.RepoHost, r.CheckRequest.Repo.Host()))
ctx = context.WithValue(ctx, stats.RepoHost, r.CheckRequest.Repo.Host())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it make a difference when you pass the value as an attribute, vs in the context? You do both in this PR.

Skimming one migration page, I thought otel didnt support context based attributes?

Comment on lines +297 to +301
defer func() {
if err := meterProvider.Shutdown(context.Background()); err != nil {
fmt.Printf("couldn't shutdown meterProvider: %v\n", err)
}
}()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't this close the meter provider as soon as the function returns?

I think the Go idiom you're looking forward is returning a cancel/close/cleanup function, and then the caller can call/defer that when appropriate.

"contrib.go.opencensus.io/exporter/stackdriver"
"contrib.go.opencensus.io/exporter/stackdriver/monitoredresource/gcp"
"go.opencensus.io/stats/view"
mexporter "github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would gcpexporter provide more context?

Comment on lines -76 to -78
ProjectID: projectID,
MetricPrefix: prefix,
MonitoredResource: gcp.Autodetect(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this information being lost in the new implementation?

exporter, err := config.GetMetricExporter()
if err != nil {
return nil, fmt.Errorf("error during GetMetricExporter: %w", err)
}

fmt.Printf("Using %s exporter for metrics\n", exporter)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover print statement?

ctx, err := tag.New(ctx, tag.Upsert(stats.CheckName, r.CheckName))
err := stats.InitMetrics()
if err != nil {
panic(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this something that should be setup in an init?

@github-actions
Copy link

github-actions bot commented Oct 7, 2023

Stale pull request message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants