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(share/eds) add dagstore shards status metric #2642

Merged
merged 3 commits into from
Sep 4, 2023
Merged
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
24 changes: 24 additions & 0 deletions share/eds/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const (
longOpUnresolved longOpResult = "unresolved"
longOpOK longOpResult = "ok"
longOpFailed longOpResult = "failed"

dagstoreShardStatusKey = "shard_status"
)

var (
Expand Down Expand Up @@ -116,9 +118,31 @@ func (s *Store) WithMetrics() error {
return err
}

dagStoreShards, err := meter.Int64ObservableGauge("eds_store_dagstore_shards",
metric.WithDescription("dagstore amount of shards by status"))
if err != nil {
return err
}

if err = s.cache.withMetrics(); err != nil {
return err
}

callback := func(ctx context.Context, observer metric.Observer) error {
stats := s.dgstr.Stats()
for status, amount := range stats {
observer.ObserveInt64(dagStoreShards, int64(amount),
metric.WithAttributes(
attribute.String(dagstoreShardStatusKey, status.String()),
))
}
return nil
}

if _, err := meter.RegisterCallback(callback, dagStoreShards); err != nil {
return err
}

s.metrics = &metrics{
putTime: putTime,
getCARTime: getCARTime,
Expand Down
Loading