github.com/filecoin-project/bacalhau@v0.3.23-0.20230228154132-45c989550ace/pkg/publisher/tracing/tracing.go (about) 1 package tracing 2 3 import ( 4 "context" 5 "fmt" 6 7 "github.com/filecoin-project/bacalhau/pkg/model" 8 "github.com/filecoin-project/bacalhau/pkg/publisher" 9 "github.com/filecoin-project/bacalhau/pkg/system" 10 "github.com/filecoin-project/bacalhau/pkg/util/reflection" 11 ) 12 13 type tracingPublisher struct { 14 delegate publisher.Publisher 15 name string 16 } 17 18 func Wrap(delegate publisher.Publisher) publisher.Publisher { 19 return &tracingPublisher{ 20 delegate: delegate, 21 name: reflection.StructName(delegate), 22 } 23 } 24 25 func (t *tracingPublisher) IsInstalled(ctx context.Context) (bool, error) { 26 ctx, span := system.NewSpan(ctx, system.GetTracer(), fmt.Sprintf("%s.IsInstalled", t.name)) 27 defer span.End() 28 29 return t.delegate.IsInstalled(ctx) 30 } 31 32 func (t *tracingPublisher) PublishShardResult( 33 ctx context.Context, shard model.JobShard, hostID string, shardResultPath string, 34 ) (model.StorageSpec, error) { 35 ctx, span := system.NewSpan(ctx, system.GetTracer(), fmt.Sprintf("%s.PublishShardResult", t.name)) 36 defer span.End() 37 38 return t.delegate.PublishShardResult(ctx, shard, hostID, shardResultPath) 39 } 40 41 var _ publisher.Publisher = &tracingPublisher{}