-
Notifications
You must be signed in to change notification settings - Fork 141
Feat: better telemetry for cron execs #861
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
Changes from 6 commits
b90084d
a5fd4e3
b61677e
59076ce
7c1f418
93b8b3d
7c1e687
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,8 @@ import ( | |
|
|
||
| var ( | ||
| LabelExecuteReadySchedules = "execute_ready_schedules" | ||
| LabelExecuteCronSchedule = "execute_cron_schedule" | ||
| LabelExecuteCronContract = "execute_cron_contract" | ||
| LabelScheduleCount = "schedule_count" | ||
| LabelScheduleExecutionsCount = "schedule_executions_count" | ||
|
|
||
|
|
@@ -67,7 +69,7 @@ func (k *Keeper) Logger(ctx sdk.Context) log.Logger { | |
| // ExecuteReadySchedules gets all schedules that are due for execution (with limit that is equal to Params.Limit) | ||
| // and executes messages in each one | ||
| func (k *Keeper) ExecuteReadySchedules(ctx sdk.Context, executionStage types.ExecutionStage) { | ||
| telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), LabelExecuteReadySchedules) | ||
| defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), LabelExecuteReadySchedules) | ||
| schedules := k.getSchedulesReadyForExecution(ctx, executionStage) | ||
|
|
||
| for _, schedule := range schedules { | ||
|
|
@@ -182,12 +184,14 @@ func (k *Keeper) getSchedulesReadyForExecution(ctx sdk.Context, executionStage t | |
| func (k *Keeper) executeSchedule(ctx sdk.Context, schedule types.Schedule) error { | ||
| // Even if contract execution returned an error, we still increase the height | ||
| // and execute it after this interval | ||
| defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), LabelExecuteCronSchedule, schedule.Name) | ||
| schedule.LastExecuteHeight = uint64(ctx.BlockHeight()) //nolint:gosec | ||
| k.storeSchedule(ctx, schedule) | ||
|
|
||
| cacheCtx, writeFn := ctx.CacheContext() | ||
|
|
||
| for idx, msg := range schedule.Msgs { | ||
| startTimeContract := time.Now() | ||
| executeMsg := wasmtypes.MsgExecuteContract{ | ||
| Sender: k.accountKeeper.GetModuleAddress(types.ModuleName).String(), | ||
| Contract: msg.Contract, | ||
|
|
@@ -205,6 +209,7 @@ func (k *Keeper) executeSchedule(ctx sdk.Context, schedule types.Schedule) error | |
| ) | ||
| return err | ||
| } | ||
| defer telemetry.ModuleMeasureSince(types.ModuleName, startTimeContract, LabelExecuteCronContract, schedule.Name, msg.Contract) | ||
|
||
| } | ||
|
|
||
| // only save state if all the messages in a schedule were executed successfully | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in case of error, you are missing both
telemetry.ModuleMeasureSincecalls, it's better to usedefer