Skip to content

Commit

Permalink
Replication metrics support added for Powerstore (#85)
Browse files Browse the repository at this point in the history
* initial changes

* fixed unit error

Signed-off-by: shefali-malhotra <[email protected]>

* updated logic to read param of repl metrics

* added mirror bw param to repl metrics

* go mod tidy

* added volume handle for metro

* added volume handle for metro

* fixed logic of volume handle

Signed-off-by: shefali-malhotra <[email protected]>

* corrected the metrics tests

* updated the metrics label

* updated the label in volume test

Signed-off-by: shefali-malhotra <[email protected]>

* updated the unit test cases

Signed-off-by: shefali-malhotra <[email protected]>

* updated the unit test cases and go generate test cases

Signed-off-by: shefali-malhotra <[email protected]>

* updated the unit test cases and go generate test cases

Signed-off-by: shefali-malhotra <[email protected]>

* updated the licenses

Signed-off-by: shefali-malhotra <[email protected]>

* reverted the unnecessary changes

Signed-off-by: shefali-malhotra <[email protected]>

* updated the licenses

Signed-off-by: shefali-malhotra <[email protected]>

* updated the licenses

Signed-off-by: shefali-malhotra <[email protected]>

* uint64 issue

Signed-off-by: shefali-malhotra <[email protected]>

* Delete ~

* Update service.go

* added UTs to increase service coverage

Signed-off-by: shefali-malhotra <[email protected]>

* fixed make format issue

Signed-off-by: shefali-malhotra <[email protected]>

---------

Signed-off-by: shefali-malhotra <[email protected]>
  • Loading branch information
shefali-malhotra authored Oct 10, 2024
1 parent 26799c6 commit 6123e78
Show file tree
Hide file tree
Showing 10 changed files with 406 additions and 149 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ tag:
check:
./scripts/check.sh ./cmd/... ./opentelemetry/... ./internal/...

.PHONY: format
format:
@gofmt -w -s .

.PHONY: download-csm-common
download-csm-common:
curl -O -L https://raw.githubusercontent.com/dell/csm/main/config/csm-common.mk
19 changes: 10 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module github.com/dell/csm-metrics-powerstore

go 1.22.0
go 1.23

toolchain go1.23.1

require (
github.com/dell/gocsi v1.11.0
github.com/dell/gopowerstore v1.15.1
github.com/dell/gopowerstore v1.15.2-0.20241008144633-6990d1b86e5b
github.com/fsnotify/fsnotify v1.6.0
github.com/golang/mock v1.6.0
github.com/sirupsen/logrus v1.9.3
Expand All @@ -26,19 +28,18 @@ require (
)

require (
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/errors v0.20.2 // indirect
github.com/go-openapi/errors v0.22.0 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/strfmt v0.21.2 // indirect
github.com/go-openapi/strfmt v0.23.0 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
Expand Down Expand Up @@ -66,14 +67,14 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.mongodb.org/mongo-driver v1.9.1 // indirect
go.mongodb.org/mongo-driver v1.17.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.7.0 // indirect
go.opentelemetry.io/proto/otlp v0.16.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
google.golang.org/protobuf v1.34.2 // indirect
Expand Down
49 changes: 14 additions & 35 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func GetPowerStoreArrays(filePath string, logger *logrus.Logger) (map[string]*se
if err != nil {
logger.Errorf("can't get throttling rate limit, using default")
} else {
clientOptions.SetRateLimit(uint64(rateLimit)) // #nosec G115 -- This is a false positive
clientOptions.SetRateLimit(rateLimit) // #nosec G115 -- This is a false positive
}
}

Expand Down
89 changes: 67 additions & 22 deletions internal/service/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type MetricsRecorder interface {
Record(ctx context.Context, meta interface{},
readBW, writeBW,
readIOPS, writeIOPS,
readLatency, writeLatency float32) error
readLatency, writeLatency, syncronizationBW, mirrorBW, dataRemaining float32) error
RecordSpaceMetrics(ctx context.Context, meta interface{},
logicalProvisioned, logicalUsed int64) error
RecordArraySpaceMetrics(ctx context.Context, arrayID, driver string,
Expand All @@ -42,7 +42,7 @@ type MetricsRecorder interface {
RecordFileSystemMetrics(ctx context.Context, meta interface{},
readBW, writeBW,
readIOPS, writeIOPS,
readLatency, writeLatency float32) error
readLatency, writeLatency, syncronizationBW, mirrorBW, dataRemaining float32) error
}

// Float64UpDownCounterCreater creates a Float64UpDownCounter InstrumentProvider
Expand Down Expand Up @@ -75,12 +75,15 @@ type ArraySpaceMetrics struct {

// Metrics contains the list of metrics data that is collected
type Metrics struct {
ReadBW asyncfloat64.UpDownCounter
WriteBW asyncfloat64.UpDownCounter
ReadIOPS asyncfloat64.UpDownCounter
WriteIOPS asyncfloat64.UpDownCounter
ReadLatency asyncfloat64.UpDownCounter
WriteLatency asyncfloat64.UpDownCounter
ReadBW asyncfloat64.UpDownCounter
WriteBW asyncfloat64.UpDownCounter
ReadIOPS asyncfloat64.UpDownCounter
WriteIOPS asyncfloat64.UpDownCounter
ReadLatency asyncfloat64.UpDownCounter
WriteLatency asyncfloat64.UpDownCounter
SyncronizationBW asyncfloat64.UpDownCounter
MirrorBW asyncfloat64.UpDownCounter
DataRemaining asyncfloat64.UpDownCounter
}

func (mw *MetricsWrapper) initMetrics(prefix, metaID string, labels []attribute.KeyValue) (*Metrics, error) {
Expand Down Expand Up @@ -114,13 +117,31 @@ func (mw *MetricsWrapper) initMetrics(prefix, metaID string, labels []attribute.
return nil, err
}

syncBW, err := mw.Meter.AsyncFloat64().UpDownCounter(prefix + "syncronization_bw_megabytes_per_second")
if err != nil {
return nil, err
}

mirrorBW, err := mw.Meter.AsyncFloat64().UpDownCounter(prefix + "mirror_bw_megabytes_per_second")
if err != nil {
return nil, err
}

dataRemaining, err := mw.Meter.AsyncFloat64().UpDownCounter(prefix + "data_remaining_bytes")
if err != nil {
return nil, err
}

metrics := &Metrics{
ReadBW: readBW,
WriteBW: writeBW,
ReadIOPS: readIOPS,
WriteIOPS: writeIOPS,
ReadLatency: readLatency,
WriteLatency: writeLatency,
ReadBW: readBW,
WriteBW: writeBW,
ReadIOPS: readIOPS,
WriteIOPS: writeIOPS,
ReadLatency: readLatency,
WriteLatency: writeLatency,
SyncronizationBW: syncBW,
MirrorBW: mirrorBW,
DataRemaining: dataRemaining,
}

mw.Metrics.Store(metaID, metrics)
Expand All @@ -133,7 +154,7 @@ func (mw *MetricsWrapper) initMetrics(prefix, metaID string, labels []attribute.
func (mw *MetricsWrapper) Record(ctx context.Context, meta interface{},
readBW, writeBW,
readIOPS, writeIOPS,
readLatency, writeLatency float32,
readLatency, writeLatency, syncronizationBW, mirrorBW, dataRemaining float32,
) error {
var prefix string
var metaID string
Expand Down Expand Up @@ -201,6 +222,9 @@ func (mw *MetricsWrapper) Record(ctx context.Context, meta interface{},
metrics.WriteIOPS.Observe(ctx, float64(writeIOPS), labels...)
metrics.ReadLatency.Observe(ctx, float64(readLatency), labels...)
metrics.WriteLatency.Observe(ctx, float64(writeLatency), labels...)
metrics.SyncronizationBW.Observe(ctx, float64(syncronizationBW), labels...)
metrics.MirrorBW.Observe(ctx, float64(mirrorBW), labels...)
metrics.DataRemaining.Observe(ctx, float64(dataRemaining), labels...)

return nil
}
Expand Down Expand Up @@ -492,13 +516,31 @@ func (mw *MetricsWrapper) initFileSystemMetrics(prefix, metaID string, labels []
return nil, err
}

syncBW, err := mw.Meter.AsyncFloat64().UpDownCounter(prefix + "syncronization_bw_megabytes_per_second")
if err != nil {
return nil, err
}

mirrorBW, err := mw.Meter.AsyncFloat64().UpDownCounter(prefix + "mirror_bw_megabytes_per_second")
if err != nil {
return nil, err
}

dataRemaining, err := mw.Meter.AsyncFloat64().UpDownCounter(prefix + "data_remaining_bytes")
if err != nil {
return nil, err
}

metrics := &Metrics{
ReadBW: readBW,
WriteBW: writeBW,
ReadIOPS: readIOPS,
WriteIOPS: writeIOPS,
ReadLatency: readLatency,
WriteLatency: writeLatency,
ReadBW: readBW,
WriteBW: writeBW,
ReadIOPS: readIOPS,
WriteIOPS: writeIOPS,
ReadLatency: readLatency,
WriteLatency: writeLatency,
SyncronizationBW: syncBW,
MirrorBW: mirrorBW,
DataRemaining: dataRemaining,
}

mw.Metrics.Store(metaID, metrics)
Expand All @@ -511,7 +553,7 @@ func (mw *MetricsWrapper) initFileSystemMetrics(prefix, metaID string, labels []
func (mw *MetricsWrapper) RecordFileSystemMetrics(ctx context.Context, meta interface{},
readBW, writeBW,
readIOPS, writeIOPS,
readLatency, writeLatency float32,
readLatency, writeLatency, syncBW, mirrorBW, dataRemaining float32,
) error {
var prefix string
var metaID string
Expand Down Expand Up @@ -580,6 +622,9 @@ func (mw *MetricsWrapper) RecordFileSystemMetrics(ctx context.Context, meta inte
metrics.WriteIOPS.Observe(ctx, float64(writeIOPS), labels...)
metrics.ReadLatency.Observe(ctx, float64(readLatency), labels...)
metrics.WriteLatency.Observe(ctx, float64(writeLatency), labels...)
metrics.DataRemaining.Observe(ctx, float64(dataRemaining), labels...)
metrics.SyncronizationBW.Observe(ctx, float64(syncBW), labels...)
metrics.MirrorBW.Observe(ctx, float64(mirrorBW), labels...)

return nil
}
Loading

0 comments on commit 6123e78

Please sign in to comment.