-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(47): add initial gitlab scraper with basic repo count metric (#72)
* feat: gitlab scraper first pass WIP * feat: fix workspace errors and introduce genqlient * chore: fix bearerauth and add new queries. * chore: fix broken graphql queries and genqclient * chore: merge changes from main branch * feat: cleanup unworking code for small batch delivery and run checks * chore: fix up config yaml to include gitlab configuration * chore: fix genqlient make command * chore: remove main.go & go files at root of repository * chore: re-add ds_store back to ignore * chore: update alpine image as .2 is removed from docker --------- Co-authored-by: shwaddell28 <shwaddell28@gmail.com> Co-authored-by: Adriel Perkins <adrielp@liatrio.com>
- Loading branch information
1 parent
36d6f19
commit 765cd87
Showing
13 changed files
with
32,805 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,5 @@ dist/ | |
# MacOS | ||
.DS_Store | ||
|
||
# JetBrains IDEs | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
pkg/receiver/gitproviderreceiver/internal/scraper/gitlabscraper/config.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package gitlabscraper | ||
|
||
import ( | ||
"go.opentelemetry.io/collector/config/confighttp" | ||
|
||
"github.com/liatrio/liatrio-otel-collector/pkg/receiver/gitproviderreceiver/internal" | ||
"github.com/liatrio/liatrio-otel-collector/pkg/receiver/gitproviderreceiver/internal/metadata" | ||
) | ||
|
||
// Config relating to GitLab Metric Scraper. | ||
type Config struct { | ||
metadata.MetricsBuilderConfig `mapstructure:",squash"` | ||
confighttp.HTTPClientSettings `mapstructure:",squash"` | ||
internal.ScraperConfig | ||
// GitLabOrg is the name of the GitLab organization to srape (gitlab scraper only) | ||
GitLabOrg string `mapstructure:"gitlab_org"` | ||
} |
50 changes: 50 additions & 0 deletions
50
pkg/receiver/gitproviderreceiver/internal/scraper/gitlabscraper/factory.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package gitlabscraper | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"go.opentelemetry.io/collector/config/confighttp" | ||
"go.opentelemetry.io/collector/receiver" | ||
"go.opentelemetry.io/collector/receiver/scraperhelper" | ||
|
||
"github.com/liatrio/liatrio-otel-collector/pkg/receiver/gitproviderreceiver/internal" | ||
"github.com/liatrio/liatrio-otel-collector/pkg/receiver/gitproviderreceiver/internal/metadata" | ||
) | ||
|
||
// This file implements factory for the GitLab Scraper as part of the Git Provider Receiver | ||
|
||
const ( | ||
// TypeStr is the value of "type" key in configuration. | ||
TypeStr = "gitlab" | ||
defaultHTTPTimeout = 15 * time.Second | ||
) | ||
|
||
type Factory struct{} | ||
|
||
func (f *Factory) CreateDefaultConfig() internal.Config { | ||
return &Config{ | ||
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(), | ||
HTTPClientSettings: confighttp.HTTPClientSettings{ | ||
Timeout: defaultHTTPTimeout, | ||
}, | ||
} | ||
} | ||
|
||
func (f *Factory) CreateMetricsScraper( | ||
ctx context.Context, | ||
params receiver.CreateSettings, | ||
cfg internal.Config, | ||
) (scraperhelper.Scraper, error) { | ||
conf := cfg.(*Config) | ||
s := newGitLabScraper(ctx, params, conf) | ||
|
||
return scraperhelper.NewScraper( | ||
TypeStr, | ||
s.scrape, | ||
scraperhelper.WithStart(s.start), | ||
) | ||
} |
Oops, something went wrong.