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

Make separate goroutines for metrics collection method calls #66

Closed
Closed
Changes from all commits
Commits
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
34 changes: 30 additions & 4 deletions internal/entrypoint/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"fmt"
"os"
"runtime"
"sync"
"time"

pstoreServices "github.com/dell/csm-metrics-powerstore/internal/service"
Expand Down Expand Up @@ -116,6 +117,8 @@
select {
case <-volumeTicker.C:
ctx, span := tracer.GetTracer(ctx, "volume-metrics")
wg := new(sync.WaitGroup)

if !config.LeaderElector.IsLeader() {
logger.Info("not leader pod to collect metrics")
span.End()
Expand All @@ -126,9 +129,15 @@
span.End()
continue
}
powerStoreSvc.ExportVolumeStatistics(ctx)
wg.Add(1)
go func() {
defer wg.Done()
powerStoreSvc.ExportVolumeStatistics(ctx)

Check failure on line 136 in internal/entrypoint/run.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)

Check failure on line 136 in internal/entrypoint/run.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)
}()
span.End()
case <-spaceTicker.C:
wg := new(sync.WaitGroup)
ctx, span := tracer.GetTracer(ctx, "volume-space-metrics")
if !config.LeaderElector.IsLeader() {
logger.Info("not leader pod to collect metrics")
Expand All @@ -140,9 +149,15 @@
span.End()
continue
}
powerStoreSvc.ExportSpaceVolumeMetrics(ctx)
wg.Add(1)
go func() {
defer wg.Done()
powerStoreSvc.ExportSpaceVolumeMetrics(ctx)

Check failure on line 156 in internal/entrypoint/run.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)

Check failure on line 156 in internal/entrypoint/run.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)
}()
span.End()
case <-arrayTicker.C:
wg := new(sync.WaitGroup)
ctx, span := tracer.GetTracer(ctx, "array-space-metrics")
if !config.LeaderElector.IsLeader() {
logger.Info("not leader pod to collect metrics")
Expand All @@ -154,9 +169,15 @@
span.End()
continue
}
powerStoreSvc.ExportArraySpaceMetrics(ctx)
wg.Add(1)
go func() {
defer wg.Done()
powerStoreSvc.ExportArraySpaceMetrics(ctx)

Check failure on line 176 in internal/entrypoint/run.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)

Check failure on line 176 in internal/entrypoint/run.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)
}()
span.End()
case <-filesystemTicker.C:
wg := new(sync.WaitGroup)
ctx, span := tracer.GetTracer(ctx, "filesystem-metrics")
if !config.LeaderElector.IsLeader() {
logger.Info("not leader pod to collect metrics")
Expand All @@ -168,7 +189,12 @@
span.End()
continue
}
powerStoreSvc.ExportFileSystemStatistics(ctx)
wg.Add(1)
go func() {
defer wg.Done()
powerStoreSvc.ExportFileSystemStatistics(ctx)

Check failure on line 196 in internal/entrypoint/run.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)

Check failure on line 196 in internal/entrypoint/run.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)
}()
span.End()
case err := <-errCh:
if err == nil {
Expand Down
Loading