Skip to content
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

feat: add metrics package for DMT info and Prometheus integration #150

Merged
merged 18 commits into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
530ee0c
feat: add metrics package for DMT info and Prometheus integration
juev Mar 20, 2025
432fc79
feat: refactor metrics pusher initialization and enhance token handling
juev Mar 20, 2025
52c77a7
feat: add metrics pusher functionality to main execution flow
juev Mar 20, 2025
a9f6f58
feat: add Prometheus client_golang dependency to go.mod
juev Mar 20, 2025
f785dc4
feat: enhance metrics pusher initialization and error handling
juev Mar 20, 2025
a31afe1
feat: improve metrics handling by adding repository address retrieval…
juev Mar 20, 2025
a129cd4
feat: add gopkg.in/ini.v1 dependency to go.mod
juev Mar 20, 2025
3c8d7fc
feat: refine repository ID handling and improve URL parsing in metric…
juev Mar 20, 2025
6b78de3
feat: fix potential panic by using a valid directory variable in metr…
juev Mar 21, 2025
c71af2f
wip
juev Mar 21, 2025
a6441f4
feat: enhance metric conversion and implement metrics sending functio…
juev Mar 21, 2025
6c5cb48
feat: refactor promremote client initialization for improved configur…
juev Mar 21, 2025
ea4daeb
feat: add prometheus client_model dependency for enhanced metrics sup…
juev Mar 21, 2025
6bbedc0
feat: improve error handling by using %w for wrapping errors in promr…
juev Mar 21, 2025
3067c20
feat: improve error handling by using %w for wrapping errors in promr…
juev Mar 21, 2025
efc9374
feat: refactor metrics sending functionality and move to metrics package
juev Mar 24, 2025
c7c9a16
feat: convert repository URL from SSH to HTTPS format
juev Mar 24, 2025
d1a6182
feat: implement Prometheus metrics service and refactor metrics handling
juev Mar 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cmd/dmt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ limitations under the License.
package main

import (
"context"
"os"

"github.com/fatih/color"

"github.com/deckhouse/dmt/internal/logger"
"github.com/deckhouse/dmt/internal/manager"
"github.com/deckhouse/dmt/internal/metrics"
"github.com/deckhouse/dmt/pkg/config"
)

Expand All @@ -42,6 +44,14 @@ func runLint(dir string) {
mng.Run()
mng.PrintResult()

metricsClient, err := metrics.NewPrometheusMetricsService(os.Getenv("DMT_METRICS_URL"), os.Getenv("DMT_METRICS_TOKEN"))
if err != nil {
logger.ErrorF("Failed to create metrics client: %v", err)
}

metricsClient.AddMetrics(metrics.GetInfo(dir))
metricsClient.Send(context.Background())

if mng.HasCriticalErrors() {
os.Exit(1)
}
Expand Down
51 changes: 27 additions & 24 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ require (
github.com/Masterminds/semver/v3 v3.3.0
github.com/Masterminds/sprig v2.22.0+incompatible
github.com/bmatcuk/doublestar v1.3.4
github.com/fatih/color v1.14.1
github.com/fatih/color v1.16.0
github.com/flant/addon-operator v1.5.0
github.com/ghodss/yaml v1.0.0
github.com/go-openapi/spec v0.21.0
github.com/go-openapi/swag v0.23.0
github.com/golang/protobuf v1.5.4
github.com/golang/snappy v0.0.4
github.com/google/go-containerregistry v0.20.2
github.com/iancoleman/strcase v0.3.0
github.com/kyokomi/emoji v2.2.4+incompatible
Expand All @@ -20,10 +22,14 @@ require (
github.com/mitchellh/hashstructure/v2 v2.0.2
github.com/mitchellh/mapstructure v1.5.0
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
github.com/prometheus/client_golang v1.21.0-rc.0
github.com/prometheus/client_model v0.6.1
github.com/prometheus/prometheus v0.302.1
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.10.0
gopkg.in/ini.v1 v1.67.0
gopkg.in/yaml.v3 v3.0.1
helm.sh/helm/v3 v3.17.1
k8s.io/api v0.32.1
Expand All @@ -39,7 +45,7 @@ require (
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/sprig/v3 v3.3.0 // indirect
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
Expand All @@ -50,28 +56,26 @@ require (
github.com/flant/kube-client v1.2.0 // indirect
github.com/flant/libjq-go v1.6.3-0.20201126171326-c46a40ff22ee // indirect
github.com/flant/shell-operator v1.4.12 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-chi/chi/v5 v5.1.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/analysis v0.19.10 // indirect
github.com/go-openapi/errors v0.19.7 // indirect
github.com/go-openapi/analysis v0.23.0 // indirect
github.com/go-openapi/errors v0.22.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/loads v0.19.5 // indirect
github.com/go-openapi/runtime v0.19.16 // indirect
github.com/go-openapi/strfmt v0.19.5 // indirect
github.com/go-openapi/validate v0.19.12 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/go-openapi/loads v0.22.0 // indirect
github.com/go-openapi/strfmt v0.23.0 // indirect
github.com/go-openapi/validate v0.24.0 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gofrs/uuid/v5 v5.3.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
Expand All @@ -82,23 +86,23 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kennygrant/sanitize v1.2.4 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/common v0.62.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
Expand All @@ -115,21 +119,20 @@ require (
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
go.mongodb.org/mongo-driver v1.5.4 // indirect
go.mongodb.org/mongo-driver v1.14.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/oauth2 v0.25.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/term v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.7.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
golang.org/x/time v0.9.0 // indirect
google.golang.org/protobuf v1.36.4 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/robfig/cron.v2 v2.0.0-20150107220207-be2e0b0deed5 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/client-go v0.32.1 // indirect
Expand Down
Loading