forked from TrueCloudLab/frostfs-node
[#373] blobovnizca: Add missed/fix tracing spans
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
028d4a8058
commit
a8526d45e9
10 changed files with 58 additions and 20 deletions
|
@ -1,17 +1,30 @@
|
|||
package blobovnicza
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||
"go.etcd.io/bbolt"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
// Exists check if object with the specified address is stored in b.
|
||||
func (b *Blobovnicza) Exists(addr oid.Address) (bool, error) {
|
||||
func (b *Blobovnicza) Exists(ctx context.Context, addr oid.Address) (bool, error) {
|
||||
var (
|
||||
exists bool
|
||||
addrKey = addressKey(addr)
|
||||
exists = false
|
||||
)
|
||||
|
||||
_, span := tracing.StartSpanFromContext(ctx, "Blobovnicza.Exists",
|
||||
trace.WithAttributes(
|
||||
attribute.String("path", b.path),
|
||||
attribute.String("address", addr.EncodeToString()),
|
||||
))
|
||||
defer span.End()
|
||||
|
||||
addrKey := addressKey(addr)
|
||||
|
||||
err := b.boltDB.View(func(tx *bbolt.Tx) error {
|
||||
return tx.ForEach(func(_ []byte, buck *bbolt.Bucket) error {
|
||||
exists = buck.Get(addrKey) != nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue