mirror of
https://github.com/ossf/scorecard.git
synced 2024-11-04 03:52:31 +03:00
Reduce cardinality of OpenCensus stats (#556)
Co-authored-by: Azeem Shaikh <azeems@google.com>
This commit is contained in:
parent
09e86518e5
commit
95362cceba
@ -47,8 +47,7 @@ func (l *logger) Logf(s string, f ...interface{}) {
|
||||
}
|
||||
|
||||
func (r *Runner) Run(ctx context.Context, f CheckFn) CheckResult {
|
||||
ctx, err := tag.New(ctx,
|
||||
tag.Upsert(stats.Repo, r.Repo), tag.Upsert(stats.CheckName, r.CheckName))
|
||||
ctx, err := tag.New(ctx, tag.Upsert(stats.CheckName, r.CheckName))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ type exporterType string
|
||||
|
||||
const (
|
||||
stackdriverTimeSeriesQuota = 200
|
||||
timeoutMinutes = 10
|
||||
stackdriverTimeoutMinutes = 10
|
||||
stackDriver exporterType = "stackdriver"
|
||||
printer exporterType = "printer"
|
||||
)
|
||||
@ -68,7 +68,7 @@ func newStackDriverExporter() (*stackdriver.Exporter, error) {
|
||||
ProjectID: projectID,
|
||||
MetricPrefix: "scorecard-cron",
|
||||
MonitoredResource: gcp.Autodetect(),
|
||||
Timeout: timeoutMinutes * time.Minute,
|
||||
Timeout: stackdriverTimeoutMinutes * time.Minute,
|
||||
// Stackdriver specific quotas based on https://cloud.google.com/monitoring/quotas
|
||||
// `Time series included in a request`
|
||||
BundleCountThreshold: stackdriverTimeSeriesQuota,
|
||||
|
@ -157,7 +157,6 @@ func main() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer exporter.Flush()
|
||||
defer exporter.StopMetricsExporter()
|
||||
|
||||
checksToRun := checks.AllChecks
|
||||
@ -184,6 +183,7 @@ func main() {
|
||||
}
|
||||
// nolint: errcheck // flushes buffer
|
||||
logger.Sync()
|
||||
exporter.Flush()
|
||||
subscriber.Ack()
|
||||
}
|
||||
err = subscriber.Close()
|
||||
|
@ -19,8 +19,6 @@ import "go.opencensus.io/tag"
|
||||
var (
|
||||
// CheckName is the tag key for the check name.
|
||||
CheckName = tag.MustNewKey("checkName")
|
||||
// Repo is the tag key for the repo name.
|
||||
Repo = tag.MustNewKey("repo")
|
||||
// RequestTag is the tag key for the request type.
|
||||
RequestTag = tag.MustNewKey("requestTag")
|
||||
)
|
||||
|
@ -15,7 +15,6 @@
|
||||
package stats
|
||||
|
||||
import (
|
||||
"go.opencensus.io/plugin/ochttp"
|
||||
"go.opencensus.io/stats/view"
|
||||
"go.opencensus.io/tag"
|
||||
)
|
||||
@ -24,11 +23,12 @@ var (
|
||||
// CheckRuntime tracks CPU runtime stats.
|
||||
CheckRuntime = view.View{
|
||||
Name: "CheckRuntime",
|
||||
Description: "CPU runtime stats per repo per check",
|
||||
Description: "CPU runtime stats per check",
|
||||
Measure: CPURuntimeInSec,
|
||||
TagKeys: []tag.Key{Repo, CheckName},
|
||||
TagKeys: []tag.Key{CheckName},
|
||||
//nolint:gomnd
|
||||
Aggregation: view.Distribution(
|
||||
0,
|
||||
1<<2,
|
||||
1<<3,
|
||||
1<<4,
|
||||
@ -42,16 +42,15 @@ var (
|
||||
1<<12,
|
||||
1<<13,
|
||||
1<<14,
|
||||
1<<15,
|
||||
1<<16),
|
||||
1<<15),
|
||||
}
|
||||
|
||||
// OutgoingHTTPRequests tracks HTTPRequests made.
|
||||
OutgoingHTTPRequests = view.View{
|
||||
Name: "OutgoingHTTPRequests",
|
||||
Description: "HTTPRequests made per repo per check per URL path",
|
||||
Description: "HTTPRequests made per check",
|
||||
Measure: HTTPRequests,
|
||||
TagKeys: []tag.Key{Repo, CheckName, ochttp.KeyClientPath, RequestTag},
|
||||
TagKeys: []tag.Key{CheckName, RequestTag},
|
||||
Aggregation: view.Count(),
|
||||
}
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user