Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move persist duration timer to ExportResult #1197

Merged
merged 1 commit into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions chain/indexer/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ func (me *ModelExporter) ExportResult(ctx context.Context, strg model.Storage, h
defer span.End()
start := time.Now()
ctx, _ = tag.New(ctx, tag.Upsert(metrics.TaskType, res.Name))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

if err := strg.PersistBatch(ctx, res.Model); err != nil {
stats.Record(ctx, metrics.PersistFailure.M(1))
Expand Down
19 changes: 0 additions & 19 deletions model/actors/common/actors.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ func (a *Actor) Persist(ctx context.Context, s model.StorageBatch, version model

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "actors"))
metrics.RecordCount(ctx, metrics.PersistModel, 1)
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

return s.PersistModel(ctx, a)
}
Expand All @@ -64,8 +62,6 @@ func (actors ActorList) Persist(ctx context.Context, s model.StorageBatch, versi

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "actors"))
metrics.RecordCount(ctx, metrics.PersistModel, len(actors))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

if len(actors) == 0 {
return nil
Expand Down Expand Up @@ -95,9 +91,6 @@ func (as *ActorState) Persist(ctx context.Context, s model.StorageBatch, version
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "actor_states"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

metrics.RecordCount(ctx, metrics.PersistModel, 1)
return s.PersistModel(ctx, as)
}
Expand All @@ -113,8 +106,6 @@ func (states ActorStateList) Persist(ctx context.Context, s model.StorageBatch,
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "actor_states"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

if len(states) == 0 {
return nil
Expand Down Expand Up @@ -143,17 +134,12 @@ func (a *ActorCode) Persist(ctx context.Context, s model.StorageBatch, version m

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "actor_codes"))
metrics.RecordCount(ctx, metrics.PersistModel, 1)
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

return s.PersistModel(ctx, a)
}

func (acl ActorCodeList) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "actor_codes"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

metrics.RecordCount(ctx, metrics.PersistModel, len(acl))
return s.PersistModel(ctx, acl)
}
Expand All @@ -177,17 +163,12 @@ func (a *ActorMethod) Persist(ctx context.Context, s model.StorageBatch, version

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "actor_methods"))
metrics.RecordCount(ctx, metrics.PersistModel, 1)
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

return s.PersistModel(ctx, a)
}

func (acl ActorMethodList) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "actor_methods"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

metrics.RecordCount(ctx, metrics.PersistModel, len(acl))
return s.PersistModel(ctx, acl)
}
4 changes: 0 additions & 4 deletions model/actors/datacap/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ type DataCapBalance struct {

func (d *DataCapBalance) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "data_cap_balances"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

return s.PersistModel(ctx, d)
}
Expand All @@ -36,8 +34,6 @@ type DataCapBalanceList []*DataCapBalance

func (d DataCapBalanceList) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "data_cap_balances"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

if len(d) == 0 {
return nil
Expand Down
4 changes: 0 additions & 4 deletions model/actors/init/idaddress.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ func (ia *IDAddress) AsVersion(version model.Version) (interface{}, bool) {

func (ia *IDAddress) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "id_addresses"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

m, ok := ia.AsVersion(version)
if !ok {
Expand All @@ -75,8 +73,6 @@ func (ias IDAddressList) Persist(ctx context.Context, s model.StorageBatch, vers
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "id_addresses"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

if version.Major != 1 {
// Support older versions, but in a non-optimal way
Expand Down
6 changes: 0 additions & 6 deletions model/actors/market/dealproposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ type MarketDealProposal struct {

func (dp *MarketDealProposal) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "market_deal_proposals"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

metrics.RecordCount(ctx, metrics.PersistModel, 1)
return s.PersistModel(ctx, dp)
}
Expand All @@ -72,9 +69,6 @@ func (dps MarketDealProposals) Persist(ctx context.Context, s model.StorageBatch
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "market_deal_proposals"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

metrics.RecordCount(ctx, metrics.PersistModel, len(dps))
return s.PersistModel(ctx, dps)
}
6 changes: 0 additions & 6 deletions model/actors/market/dealstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ type MarketDealState struct {

func (ds *MarketDealState) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "market_deal_states"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

metrics.RecordCount(ctx, metrics.PersistModel, 1)
return s.PersistModel(ctx, ds)
}
Expand All @@ -39,9 +36,6 @@ func (dss MarketDealStates) Persist(ctx context.Context, s model.StorageBatch, v
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "market_deal_states"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

metrics.RecordCount(ctx, metrics.PersistModel, len(dss))
return s.PersistModel(ctx, dss)
}
5 changes: 0 additions & 5 deletions model/actors/miner/beneficiary.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ func (m *MinerBeneficiary) Persist(ctx context.Context, s model.StorageBatch, ve
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_beneficiaries"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

metrics.RecordCount(ctx, metrics.PersistModel, 1)
return s.PersistModel(ctx, m)
}
Expand All @@ -47,8 +44,6 @@ func (ml MinerBeneficiaryList) Persist(ctx context.Context, s model.StorageBatch
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_beneficiaries"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

if len(ml) == 0 {
return nil
Expand Down
5 changes: 0 additions & 5 deletions model/actors/miner/currentdeadline.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ func (m *MinerCurrentDeadlineInfo) Persist(ctx context.Context, s model.StorageB
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_current_deadline_infos"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

metrics.RecordCount(ctx, metrics.PersistModel, 1)
return s.PersistModel(ctx, m)
}
Expand All @@ -42,8 +39,6 @@ func (ml MinerCurrentDeadlineInfoList) Persist(ctx context.Context, s model.Stor
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_current_deadline_infos"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

if len(ml) == 0 {
return nil
Expand Down
4 changes: 0 additions & 4 deletions model/actors/miner/feedebt.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ func (m *MinerFeeDebt) Persist(ctx context.Context, s model.StorageBatch, versio
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_fee_debts"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

vm, ok := m.AsVersion(version)
if !ok {
Expand All @@ -72,8 +70,6 @@ func (ml MinerFeeDebtList) Persist(ctx context.Context, s model.StorageBatch, ve
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_fee_debts"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

if len(ml) == 0 {
return nil
Expand Down
4 changes: 0 additions & 4 deletions model/actors/miner/lockedfunds.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ func (m *MinerLockedFund) Persist(ctx context.Context, s model.StorageBatch, ver
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_locked_funds"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

vm, ok := m.AsVersion(version)
if !ok {
Expand All @@ -78,8 +76,6 @@ func (ml MinerLockedFundsList) Persist(ctx context.Context, s model.StorageBatch
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_locked_funds"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

if len(ml) == 0 {
return nil
Expand Down
5 changes: 0 additions & 5 deletions model/actors/miner/minerinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ func (m *MinerInfo) Persist(ctx context.Context, s model.StorageBatch, version m
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_infos"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

metrics.RecordCount(ctx, metrics.PersistModel, 1)
return s.PersistModel(ctx, m)
}
Expand All @@ -49,8 +46,6 @@ func (ml MinerInfoList) Persist(ctx context.Context, s model.StorageBatch, versi
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_infos"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

if len(ml) == 0 {
return nil
Expand Down
4 changes: 0 additions & 4 deletions model/actors/miner/precommit.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ func (mpi *MinerPreCommitInfo) AsVersion(version model.Version) (interface{}, bo

func (mpi *MinerPreCommitInfo) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_pre_commit_infos"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

m, ok := mpi.AsVersion(version)
if !ok {
Expand All @@ -111,8 +109,6 @@ func (ml MinerPreCommitInfoList) Persist(ctx context.Context, s model.StorageBat
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_pre_commit_infos"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

if len(ml) == 0 {
return nil
Expand Down
4 changes: 0 additions & 4 deletions model/actors/miner/precommitV9.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ func (mpi *MinerPreCommitInfoV9) AsVersion(version model.Version) (interface{},

func (mpi *MinerPreCommitInfoV9) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_pre_commit_infos"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

m, ok := mpi.AsVersion(version)
if !ok {
Expand All @@ -65,8 +63,6 @@ func (ml MinerPreCommitInfoV9List) Persist(ctx context.Context, s model.StorageB
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_pre_commit_infos"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

if len(ml) == 0 {
return nil
Expand Down
8 changes: 0 additions & 8 deletions model/actors/miner/sector.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ func (msi *MinerSectorInfoV7) AsVersion(version model.Version) (interface{}, boo

func (msi *MinerSectorInfoV7) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_sector_infos_v7"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

m, ok := msi.AsVersion(version)
if !ok {
Expand All @@ -134,8 +132,6 @@ func (ml MinerSectorInfoV7List) Persist(ctx context.Context, s model.StorageBatc
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_sector_infos_v7"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

if len(ml) == 0 {
return nil
Expand Down Expand Up @@ -185,8 +181,6 @@ func (msi *MinerSectorInfoV1_6) AsVersion(version model.Version) (interface{}, b

func (msi *MinerSectorInfoV1_6) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_sector_infos"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

m, ok := msi.AsVersion(version)
if !ok {
Expand All @@ -207,8 +201,6 @@ func (ml MinerSectorInfoV1_6List) Persist(ctx context.Context, s model.StorageBa
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_sector_infos"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

if len(ml) == 0 {
return nil
Expand Down
5 changes: 0 additions & 5 deletions model/actors/miner/sectordeals.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ type MinerSectorDeal struct {

func (ds *MinerSectorDeal) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_sector_deals"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

metrics.RecordCount(ctx, metrics.PersistModel, 1)
return s.PersistModel(ctx, ds)
}
Expand All @@ -36,8 +33,6 @@ func (ml MinerSectorDealList) Persist(ctx context.Context, s model.StorageBatch,
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_sector_deals"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

if len(ml) == 0 {
return nil
Expand Down
5 changes: 0 additions & 5 deletions model/actors/miner/sectorevents.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ type MinerSectorEvent struct {

func (mse *MinerSectorEvent) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_sector_events"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

metrics.RecordCount(ctx, metrics.PersistModel, 1)
return s.PersistModel(ctx, mse)
}
Expand All @@ -58,8 +55,6 @@ func (l MinerSectorEventList) Persist(ctx context.Context, s model.StorageBatch,
defer span.End()

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_sector_events"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

if len(l) == 0 {
return nil
Expand Down
6 changes: 0 additions & 6 deletions model/actors/miner/sectorposts.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ type MinerSectorPostList []*MinerSectorPost

func (msp *MinerSectorPost) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_sector_posts"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

metrics.RecordCount(ctx, metrics.PersistModel, 1)
return s.PersistModel(ctx, msp)
}
Expand All @@ -40,9 +37,6 @@ func (ml MinerSectorPostList) Persist(ctx context.Context, s model.StorageBatch,
}

ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "miner_sector_posts"))
stop := metrics.Timer(ctx, metrics.PersistDuration)
defer stop()

metrics.RecordCount(ctx, metrics.PersistModel, len(ml))
return s.PersistModel(ctx, ml)
}
Loading