Remove Repo CPU runtime stat logging (#1186)

Co-authored-by: Azeem Shaikh <azeems@google.com>
This commit is contained in:
Azeem Shaikh 2021-10-29 00:37:44 -04:00 committed by GitHub
parent 1db0f9745f
commit 138552848d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 0 additions and 47 deletions

View File

@ -144,8 +144,6 @@ func startMetricsExporter() (monitoring.Exporter, error) {
if err := view.Register( if err := view.Register(
&stats.CheckRuntime, &stats.CheckRuntime,
&stats.CheckErrorCount, &stats.CheckErrorCount,
// TODO: Debug high monitoring costs for Stackdriver before re-enabling.
// &stats.RepoRuntime,
&stats.OutgoingHTTPRequests, &stats.OutgoingHTTPRequests,
&githubstats.GithubTokens); err != nil { &githubstats.GithubTokens); err != nil {
return nil, fmt.Errorf("error during view.Register: %w", err) return nil, fmt.Errorf("error during view.Register: %w", err)

View File

@ -21,23 +21,14 @@ import (
"sync" "sync"
"time" "time"
opencensusstats "go.opencensus.io/stats"
"go.opencensus.io/tag"
"github.com/ossf/scorecard/v3/checker" "github.com/ossf/scorecard/v3/checker"
"github.com/ossf/scorecard/v3/clients" "github.com/ossf/scorecard/v3/clients"
"github.com/ossf/scorecard/v3/clients/githubrepo" "github.com/ossf/scorecard/v3/clients/githubrepo"
"github.com/ossf/scorecard/v3/clients/localdir" "github.com/ossf/scorecard/v3/clients/localdir"
sce "github.com/ossf/scorecard/v3/errors" sce "github.com/ossf/scorecard/v3/errors"
"github.com/ossf/scorecard/v3/repos" "github.com/ossf/scorecard/v3/repos"
"github.com/ossf/scorecard/v3/stats"
) )
func logStats(ctx context.Context, startTime time.Time) {
runTimeInSecs := time.Now().Unix() - startTime.Unix()
opencensusstats.Record(ctx, stats.RepoRuntimeInSec.M(runTimeInSecs))
}
func runEnabledChecks(ctx context.Context, func runEnabledChecks(ctx context.Context,
repo clients.Repo, checksToRun checker.CheckNameToFnMap, repoClient clients.RepoClient, repo clients.Repo, checksToRun checker.CheckNameToFnMap, repoClient clients.RepoClient,
resultsCh chan checker.CheckResult) { resultsCh chan checker.CheckResult) {
@ -117,12 +108,6 @@ func RunScorecards(ctx context.Context,
repoURI *repos.RepoURI, repoURI *repos.RepoURI,
checksToRun checker.CheckNameToFnMap, checksToRun checker.CheckNameToFnMap,
repoClient clients.RepoClient) (ScorecardResult, error) { repoClient clients.RepoClient) (ScorecardResult, error) {
ctx, err := tag.New(ctx, tag.Upsert(stats.Repo, repoURI.URL()))
if err != nil {
return ScorecardResult{}, sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("tag.New: %v", err))
}
defer logStats(ctx, time.Now())
repo, err := createRepo(repoURI) repo, err := createRepo(repoURI)
if err != nil { if err != nil {
return ScorecardResult{}, sce.WithMessage(err, "") return ScorecardResult{}, sce.WithMessage(err, "")

View File

@ -22,9 +22,6 @@ var (
stats.UnitSeconds) stats.UnitSeconds)
// CheckErrors measures the count of errors per check. // CheckErrors measures the count of errors per check.
CheckErrors = stats.Int64("CheckErrors", "Measures the count of errors", stats.UnitDimensionless) CheckErrors = stats.Int64("CheckErrors", "Measures the count of errors", stats.UnitDimensionless)
// RepoRuntimeInSec measures the CPU runtime in seconds per repo.
RepoRuntimeInSec = stats.Int64("RepoRuntimeInSec", "Measures the CPU runtime in seconds for a repo",
stats.UnitSeconds)
// HTTPRequests measures the count of HTTP requests. // HTTPRequests measures the count of HTTP requests.
HTTPRequests = stats.Int64("HTTPRequests", "Measures the count of HTTP requests", stats.UnitDimensionless) HTTPRequests = stats.Int64("HTTPRequests", "Measures the count of HTTP requests", stats.UnitDimensionless)
) )

View File

@ -21,8 +21,6 @@ var (
CheckName = tag.MustNewKey("checkName") CheckName = tag.MustNewKey("checkName")
// ErrorName is the tag key for errors. // ErrorName is the tag key for errors.
ErrorName = tag.MustNewKey("errorName") ErrorName = tag.MustNewKey("errorName")
// Repo is the tag key for the repo name.
Repo = tag.MustNewKey("repo")
// RequestTag is the tag key for the request type. // RequestTag is the tag key for the request type.
RequestTag = tag.MustNewKey("requestTag") RequestTag = tag.MustNewKey("requestTag")
) )

View File

@ -55,31 +55,6 @@ var (
Aggregation: view.Count(), Aggregation: view.Count(),
} }
// RepoRuntime tracks CPU runtime stats for repos.
RepoRuntime = view.View{
Name: "RepoRuntime",
Description: "CPU runtime stats per repo",
Measure: RepoRuntimeInSec,
TagKeys: []tag.Key{Repo},
//nolint:gomnd
Aggregation: view.Distribution(
0,
1<<2,
1<<3,
1<<4,
1<<5,
1<<6,
1<<7,
1<<8,
1<<9,
1<<10,
1<<11,
1<<12,
1<<13,
1<<14,
1<<15),
}
// OutgoingHTTPRequests tracks HTTPRequests made. // OutgoingHTTPRequests tracks HTTPRequests made.
OutgoingHTTPRequests = view.View{ OutgoingHTTPRequests = view.View{
Name: "OutgoingHTTPRequests", Name: "OutgoingHTTPRequests",