41
41
Name : "tonapi_send_message_counter" ,
42
42
Help : "The total number of messages received by /v2/blockchain/message endpoint" ,
43
43
})
44
+ savedEmulatedTraces = promauto .NewCounterVec (prometheus.CounterOpts {
45
+ Name : "saved_emulated_traces" ,
46
+ }, []string {"status" })
44
47
)
45
48
46
49
type decodedMessage struct {
@@ -398,8 +401,12 @@ func (h *Handler) EmulateMessageToAccountEvent(ctx context.Context, request *oas
398
401
trace , version , _ , err := h .storage .GetTraceWithState (ctx , hash )
399
402
if err != nil {
400
403
h .logger .Warn ("get trace from storage: " , zap .Error (err ))
404
+ savedEmulatedTraces .WithLabelValues ("error_restore" ).Inc ()
401
405
}
402
406
if trace == nil || h .tongoVersion == 0 || version > h .tongoVersion {
407
+ if version > h .tongoVersion {
408
+ savedEmulatedTraces .WithLabelValues ("expired" ).Inc ()
409
+ }
403
410
configBase64 , err := h .storage .TrimmedConfigBase64 ()
404
411
if err != nil {
405
412
return nil , toError (http .StatusInternalServerError , err )
@@ -426,8 +433,12 @@ func (h *Handler) EmulateMessageToAccountEvent(ctx context.Context, request *oas
426
433
}
427
434
err = h .storage .SaveTraceWithState (ctx , hash , trace , h .tongoVersion , []abi.MethodInvocation {}, 24 * time .Hour )
428
435
if err != nil {
429
- fmt .Println ("trace not saved: " , err )
436
+ h .logger .Warn ("trace not saved: " , zap .Error (err ))
437
+ savedEmulatedTraces .WithLabelValues ("error_save" ).Inc ()
430
438
}
439
+ savedEmulatedTraces .WithLabelValues ("success" ).Inc ()
440
+ } else {
441
+ savedEmulatedTraces .WithLabelValues ("restored" ).Inc ()
431
442
}
432
443
actions , err := bath .FindActions (ctx , trace , bath .WithInformationSource (h .storage ))
433
444
if err != nil {
@@ -459,8 +470,12 @@ func (h *Handler) EmulateMessageToEvent(ctx context.Context, request *oas.Emulat
459
470
trace , version , _ , err := h .storage .GetTraceWithState (ctx , hs )
460
471
if err != nil {
461
472
h .logger .Warn ("get trace from storage: " , zap .Error (err ))
473
+ savedEmulatedTraces .WithLabelValues ("error_restore" ).Inc ()
462
474
}
463
475
if trace == nil || h .tongoVersion == 0 || version > h .tongoVersion {
476
+ if version > h .tongoVersion {
477
+ savedEmulatedTraces .WithLabelValues ("expired" ).Inc ()
478
+ }
464
479
var m tlb.Message
465
480
if err := tlb .Unmarshal (c , & m ); err != nil {
466
481
return nil , toError (http .StatusBadRequest , err )
@@ -491,8 +506,12 @@ func (h *Handler) EmulateMessageToEvent(ctx context.Context, request *oas.Emulat
491
506
}
492
507
err = h .storage .SaveTraceWithState (ctx , hs , trace , h .tongoVersion , []abi.MethodInvocation {}, 24 * time .Hour )
493
508
if err != nil {
494
- fmt .Println ("trace not saved: " , err )
509
+ h .logger .Warn ("trace not saved: " , zap .Error (err ))
510
+ savedEmulatedTraces .WithLabelValues ("error_save" ).Inc ()
495
511
}
512
+ savedEmulatedTraces .WithLabelValues ("success" ).Inc ()
513
+ } else {
514
+ savedEmulatedTraces .WithLabelValues ("restored" ).Inc ()
496
515
}
497
516
}
498
517
actions , err := bath .FindActions (ctx , trace , bath .WithInformationSource (h .storage ))
@@ -525,8 +544,12 @@ func (h *Handler) EmulateMessageToTrace(ctx context.Context, request *oas.Emulat
525
544
trace , version , _ , err := h .storage .GetTraceWithState (ctx , hs )
526
545
if err != nil {
527
546
h .logger .Warn ("get trace from storage: " , zap .Error (err ))
547
+ savedEmulatedTraces .WithLabelValues ("error_restore" ).Inc ()
528
548
}
529
549
if trace == nil || h .tongoVersion == 0 || version > h .tongoVersion {
550
+ if version > h .tongoVersion {
551
+ savedEmulatedTraces .WithLabelValues ("expired" ).Inc ()
552
+ }
530
553
var m tlb.Message
531
554
err = tlb .Unmarshal (c , & m )
532
555
if err != nil {
@@ -558,8 +581,12 @@ func (h *Handler) EmulateMessageToTrace(ctx context.Context, request *oas.Emulat
558
581
}
559
582
err = h .storage .SaveTraceWithState (ctx , hs , trace , h .tongoVersion , []abi.MethodInvocation {}, 24 * time .Hour )
560
583
if err != nil {
561
- fmt .Println ("trace not saved: " , err )
584
+ h .logger .Warn ("trace not saved: " , zap .Error (err ))
585
+ savedEmulatedTraces .WithLabelValues ("error_save" ).Inc ()
562
586
}
587
+ savedEmulatedTraces .WithLabelValues ("success" ).Inc ()
588
+ } else {
589
+ savedEmulatedTraces .WithLabelValues ("restored" ).Inc ()
563
590
}
564
591
}
565
592
t := convertTrace (trace , h .addressBook )
@@ -654,8 +681,12 @@ func (h *Handler) EmulateMessageToWallet(ctx context.Context, request *oas.Emula
654
681
trace , version , _ , err := h .storage .GetTraceWithState (ctx , hash )
655
682
if err != nil {
656
683
h .logger .Warn ("get trace from storage: " , zap .Error (err ))
684
+ savedEmulatedTraces .WithLabelValues ("error_restore" ).Inc ()
657
685
}
658
686
if trace == nil || h .tongoVersion == 0 || version > h .tongoVersion {
687
+ if version > h .tongoVersion {
688
+ savedEmulatedTraces .WithLabelValues ("expired" ).Inc ()
689
+ }
659
690
configBase64 , err := h .storage .TrimmedConfigBase64 ()
660
691
if err != nil {
661
692
return nil , toError (http .StatusInternalServerError , err )
@@ -698,8 +729,12 @@ func (h *Handler) EmulateMessageToWallet(ctx context.Context, request *oas.Emula
698
729
}
699
730
err = h .storage .SaveTraceWithState (ctx , hash , trace , h .tongoVersion , []abi.MethodInvocation {}, 24 * time .Hour )
700
731
if err != nil {
701
- fmt .Println ("trace not saved: " , err )
732
+ h .logger .Warn ("trace not saved: " , zap .Error (err ))
733
+ savedEmulatedTraces .WithLabelValues ("error_save" ).Inc ()
702
734
}
735
+ savedEmulatedTraces .WithLabelValues ("success" ).Inc ()
736
+ } else {
737
+ savedEmulatedTraces .WithLabelValues ("restored" ).Inc ()
703
738
}
704
739
t := convertTrace (trace , h .addressBook )
705
740
actions , err := bath .FindActions (ctx , trace , bath .ForAccount (* walletAddress ), bath .WithInformationSource (h .storage ))
0 commit comments