Gather graphsync metrics on provider side as well

This commit is contained in:
Łukasz Magiera 2021-10-19 19:45:25 +02:00
parent 32a855b984
commit d2e9d21031
2 changed files with 44 additions and 39 deletions

View File

@ -4,15 +4,14 @@ import (
"context" "context"
"time" "time"
"go.opencensus.io/stats"
"go.uber.org/fx"
"github.com/ipfs/go-graphsync" "github.com/ipfs/go-graphsync"
graphsyncimpl "github.com/ipfs/go-graphsync/impl" graphsyncimpl "github.com/ipfs/go-graphsync/impl"
gsnet "github.com/ipfs/go-graphsync/network" gsnet "github.com/ipfs/go-graphsync/network"
"github.com/ipfs/go-graphsync/storeutil" "github.com/ipfs/go-graphsync/storeutil"
"github.com/libp2p/go-libp2p-core/host" "github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/peer"
"go.opencensus.io/stats"
"go.uber.org/fx"
"github.com/filecoin-project/lotus/metrics" "github.com/filecoin-project/lotus/metrics"
"github.com/filecoin-project/lotus/node/config" "github.com/filecoin-project/lotus/node/config"
@ -56,6 +55,13 @@ func Graphsync(parallelTransfersForStorage uint64, parallelTransfersForRetrieval
} }
}) })
graphsyncStats(mctx, lc, gs)
return gs, nil
}
}
func graphsyncStats(mctx helpers.MetricsCtx, lc fx.Lifecycle, gs dtypes.Graphsync) {
stopStats := make(chan struct{}) stopStats := make(chan struct{})
lc.Append(fx.Hook{ lc.Append(fx.Hook{
OnStart: func(context.Context) error { OnStart: func(context.Context) error {
@ -92,7 +98,4 @@ func Graphsync(parallelTransfersForStorage uint64, parallelTransfersForRetrieval
return nil return nil
}, },
}) })
return gs, nil
}
} }

View File

@ -408,6 +408,8 @@ func StagingGraphsync(parallelTransfersForStorage uint64, parallelTransfersForRe
graphsyncimpl.MaxLinksPerIncomingRequests(config.MaxTraversalLinks), graphsyncimpl.MaxLinksPerIncomingRequests(config.MaxTraversalLinks),
graphsyncimpl.MaxLinksPerOutgoingRequests(config.MaxTraversalLinks)) graphsyncimpl.MaxLinksPerOutgoingRequests(config.MaxTraversalLinks))
graphsyncStats(mctx, lc, gs)
return gs return gs
} }
} }