[#1080] metabase: Add StorageID metric
Vulncheck / Vulncheck (pull_request) Successful in 1m13s Details
DCO action / DCO (pull_request) Successful in 2m4s Details
Build / Build Components (1.21) (pull_request) Successful in 4m47s Details
Build / Build Components (1.20) (pull_request) Successful in 4m56s Details
Tests and linters / gopls check (pull_request) Successful in 5m49s Details
Tests and linters / Staticcheck (pull_request) Successful in 6m13s Details
Tests and linters / Lint (pull_request) Successful in 6m50s Details
Tests and linters / Tests (1.20) (pull_request) Successful in 9m13s Details
Tests and linters / Tests with -race (pull_request) Successful in 9m13s Details
Tests and linters / Tests (1.21) (pull_request) Successful in 9m43s Details

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
Dmitrii Stepanov 2024-04-09 15:29:49 +03:00
parent b0e70fa312
commit e7203ae8cd
1 changed files with 9 additions and 1 deletions

View File

@ -36,6 +36,14 @@ func (r StorageIDRes) StorageID() []byte {
// StorageID returns storage descriptor for objects from the blobstor.
// It is put together with the object can makes get/delete operation faster.
func (db *DB) StorageID(ctx context.Context, prm StorageIDPrm) (res StorageIDRes, err error) {
var (
startedAt = time.Now()
success = false
)
defer func() {
db.metrics.AddMethodDuration("StorageID", time.Since(startedAt), success)
}()
_, span := tracing.StartSpanFromContext(ctx, "metabase.StorageID",
trace.WithAttributes(
attribute.String("address", prm.addr.EncodeToString()),
@ -54,7 +62,7 @@ func (db *DB) StorageID(ctx context.Context, prm StorageIDPrm) (res StorageIDRes
return err
})
success = err == nil
return res, metaerr.Wrap(err)
}