2023-05-04 10:58:26 +00:00
|
|
|
package shard
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2023-05-31 09:24:04 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
2023-05-04 10:58:26 +00:00
|
|
|
"go.opentelemetry.io/otel/attribute"
|
|
|
|
"go.opentelemetry.io/otel/trace"
|
|
|
|
)
|
|
|
|
|
|
|
|
// LogicalObjectsCount returns logical objects count.
|
|
|
|
func (s *Shard) LogicalObjectsCount(ctx context.Context) (uint64, error) {
|
|
|
|
_, span := tracing.StartSpanFromContext(ctx, "Shard.LogicalObjectsCount",
|
|
|
|
trace.WithAttributes(
|
|
|
|
attribute.String("shard_id", s.ID().String()),
|
|
|
|
))
|
|
|
|
defer span.End()
|
|
|
|
|
|
|
|
s.m.RLock()
|
|
|
|
defer s.m.RUnlock()
|
|
|
|
|
|
|
|
if s.GetMode().NoMetabase() {
|
|
|
|
return 0, ErrDegradedMode
|
|
|
|
}
|
|
|
|
|
2024-04-26 09:11:42 +00:00
|
|
|
cc, err := s.metaBase.ObjectCounters(ctx)
|
2023-05-04 10:58:26 +00:00
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
2023-12-04 14:35:11 +00:00
|
|
|
return cc.Logic, nil
|
2023-05-04 10:58:26 +00:00
|
|
|
}
|