Skip to content

fix: nats metrics oss #76

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
38 changes: 18 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,62 @@ go 1.17

require (
github.com/caarlos0/env v3.5.0+incompatible
github.com/devtron-labs/common-lib v0.0.0-20230109070754-ff4dca200a2c
github.com/devtron-labs/common-lib v0.0.9-0.20231220132531-ea8f659a9848
github.com/devtron-labs/protos v0.0.2
github.com/gammazero/workerpool v0.0.0-20200206003619-019d125201ab
github.com/go-pg/pg v6.15.1+incompatible
github.com/google/wire v0.4.0
github.com/gorilla/handlers v1.4.2
github.com/gorilla/mux v1.7.4
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/prometheus/client_golang v1.7.1
github.com/prometheus/client_golang v1.14.0
github.com/robfig/cron/v3 v3.0.0
github.com/stretchr/testify v1.8.2
github.com/stretchr/testify v1.8.4
github.com/tidwall/gjson v1.8.0
go.uber.org/zap v1.21.0
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f
google.golang.org/grpc v1.51.0
google.golang.org/protobuf v1.28.1
golang.org/x/sys v0.11.0
google.golang.org/grpc v1.54.0
google.golang.org/protobuf v1.31.0
gopkg.in/src-d/go-git.v4 v4.13.1
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/gammazero/deque v0.0.0-20200124200322-7e84b94275b8 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd // indirect
github.com/klauspost/compress v1.15.12 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/minio/highwayhash v1.0.2 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/nats-io/jwt/v2 v2.3.0 // indirect
github.com/nats-io/nats.go v1.19.0 // indirect
github.com/nats-io/nkeys v0.3.0 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/onsi/ginkgo v1.10.3 // indirect
github.com/onsi/gomega v1.7.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.13.0 // indirect
github.com/prometheus/procfs v0.1.3 // indirect
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
github.com/prometheus/common v0.38.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/src-d/gcfg v1.4.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/tidwall/match v1.0.3 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/xanzy/ssh-agent v0.2.1 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 // indirect
google.golang.org/genproto v0.0.0-20220810155839-1856144b1d9c // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/net v0.13.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/time v0.4.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect
gopkg.in/src-d/go-billy.v4 v4.3.2 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
956 changes: 42 additions & 914 deletions go.sum

Large diffs are not rendered by default.

25 changes: 13 additions & 12 deletions pkg/git/Watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"github.com/caarlos0/env"
pubsub "github.com/devtron-labs/common-lib/pubsub-lib"
models "github.com/devtron-labs/common-lib/pubsub-lib/model"
"github.com/devtron-labs/git-sensor/internal"
"github.com/devtron-labs/git-sensor/internal/middleware"
"github.com/devtron-labs/git-sensor/internal/sql"
Expand Down Expand Up @@ -94,7 +95,7 @@ func NewGitWatcherImpl(repositoryManager RepositoryManager,
return nil, err
}

//err = watcher.SubscribePull()
// err = watcher.SubscribePull()
watcher.SubscribeWebhookEvent()
return watcher, err
}
Expand All @@ -109,7 +110,7 @@ func (impl GitWatcherImpl) Watch() {
impl.logger.Error("error in fetching watchlist", "err", err)
return
}
//impl.Publish(materials)
// impl.Publish(materials)
middleware.ActiveGitRepoCount.WithLabelValues().Set(float64(len(materials)))
impl.RunOnWorker(materials)
impl.logger.Infow("stop git watch thread")
Expand All @@ -134,7 +135,7 @@ func (impl *GitWatcherImpl) RunOnWorker(materials []*sql.GitMaterial) {
}

func (impl GitWatcherImpl) PollAndUpdateGitMaterial(material *sql.GitMaterial) (*sql.GitMaterial, error) {
//tmp expose remove in future
// tmp expose remove in future
return impl.pollAndUpdateGitMaterial(material)
}

Expand Down Expand Up @@ -217,7 +218,7 @@ func (impl GitWatcherImpl) pollGitMaterialAndNotify(material *sql.GitMaterial) e
}
impl.logger.Debugw("Running changesBySinceRepository for material - ", material)
impl.logger.Debugw("---------------------------------------------------------- ")
//parse env variables here, then search for the count field and pass here.
// parse env variables here, then search for the count field and pass here.
commits, err := impl.repositoryManager.ChangesSinceByRepository(repo, material.Value, "", "", impl.configuration.GitHistoryCount)
if err != nil {
material.Errored = true
Expand All @@ -226,7 +227,7 @@ func (impl GitWatcherImpl) pollGitMaterialAndNotify(material *sql.GitMaterial) e
} else if len(commits) > 0 {
latestCommit := commits[0]
if latestCommit.Commit != material.LastSeenHash {
//new commit found
// new commit found
mb := &CiPipelineMaterialBean{
Id: material.Id,
Value: material.Value,
Expand Down Expand Up @@ -295,9 +296,9 @@ func (impl GitWatcherImpl) NotifyForMaterialUpdate(materials []*CiPipelineMateri
}

func (impl GitWatcherImpl) SubscribeWebhookEvent() error {
callback := func(msg *pubsub.PubSubMsg) {
callback := func(msg *models.PubSubMsg) {
impl.logger.Debugw("received msg", "msg", msg)
//msg.Ack() //ack immediate if lost next min it would get a new message
// msg.Ack() //ack immediate if lost next min it would get a new message
webhookEvent := &WebhookEvent{}
err := json.Unmarshal([]byte(msg.Data), webhookEvent)
if err != nil {
Expand Down Expand Up @@ -342,7 +343,7 @@ func (impl GitWatcherImpl) PathMatcher(fileStats *object.FileStats, gitMaterial
for i, filter := range pathsForFilter {
isExcludeFilter := false
isMatched := false
//TODO - handle ! in file name with /!
// TODO - handle ! in file name with /!
const ExcludePathIdentifier = "!"
if strings.Contains(filter, ExcludePathIdentifier) {
filter = strings.Replace(filter, ExcludePathIdentifier, "", 1)
Expand All @@ -360,23 +361,23 @@ func (impl GitWatcherImpl) PathMatcher(fileStats *object.FileStats, gitMaterial
}
if isMatched {
if isExcludeFilter {
//if matched for exclude filter
// if matched for exclude filter
excluded = true
} else {
//if matched for include filter
// if matched for include filter
excluded = false
}
return excluded
} else if i == len-1 {
//if it's a last item
// if it's a last item
if isExcludeFilter {
excluded = false
} else {
excluded = true
}
return excluded
} else {
//GO TO THE NEXT FILTER
// GO TO THE NEXT FILTER
}
}

Expand Down
8 changes: 0 additions & 8 deletions vendor/github.com/cespare/xxhash/v2/.travis.yml

This file was deleted.

37 changes: 21 additions & 16 deletions vendor/github.com/cespare/xxhash/v2/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vendor/github.com/cespare/xxhash/v2/testall.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 20 additions & 28 deletions vendor/github.com/cespare/xxhash/v2/xxhash.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading