From 52d2552f149341e1854c25840ff0aedd8412fcc9 Mon Sep 17 00:00:00 2001 From: Adriel Perkins Date: Thu, 27 Jul 2023 12:08:41 -0400 Subject: [PATCH] fix: add ignore to archived and forked repositories on search (#56) Many orgs have multiple repos that are forks and archived. adding `isArchived: false` and `isFork: false` to the `repositories` query reduces the overhead of getting metrics on non-maintained repositories and increases performance by reducing the amount of subsequent calls and iterations. This may be feature flagged via config in the future. --- .../internal/scraper/githubscraper/github_scraper.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/receiver/gitproviderreceiver/internal/scraper/githubscraper/github_scraper.go b/pkg/receiver/gitproviderreceiver/internal/scraper/githubscraper/github_scraper.go index af6a12b7..72a5945f 100644 --- a/pkg/receiver/gitproviderreceiver/internal/scraper/githubscraper/github_scraper.go +++ b/pkg/receiver/gitproviderreceiver/internal/scraper/githubscraper/github_scraper.go @@ -306,7 +306,7 @@ func (ghs *githubScraper) scrape(ctx context.Context) (pmetric.Metrics, error) { HasNextPage bool } Edges []RepositoryEdge - } `graphql:"repositories(first: 100, affiliations:OWNER, after: $repoCursor)"` + } `graphql:"repositories(first: 100, affiliations: OWNER, after: $repoCursor, isArchived: false, isFork: false)"` } `graphql:"user(login: $login)"` } @@ -319,7 +319,7 @@ func (ghs *githubScraper) scrape(ctx context.Context) (pmetric.Metrics, error) { HasNextPage bool } Edges []RepositoryEdge - } `graphql:"repositories(first: 100, after: $repoCursor)"` + } `graphql:"repositories(first: 100, after: $repoCursor, affiliations: OWNER, isArchived: false, isFork: false)"` } `graphql:"organization(login: $login)"` }