44 "context"
55 "errors"
66 "fmt"
7+ "strconv"
78 "strings"
89 "time"
910
@@ -29,9 +30,10 @@ type SQLSinker struct {
2930
3031 stats * Stats
3132 lastAppliedBlockNum * uint64
33+ manifestPath string // Store manifest path for metrics
3234}
3335
34- func New (sink * sink.Sinker , loader * db.Loader , logger * zap.Logger , tracer logging.Tracer ) (* SQLSinker , error ) {
36+ func New (sink * sink.Sinker , loader * db.Loader , logger * zap.Logger , tracer logging.Tracer , manifestPath string ) (* SQLSinker , error ) {
3537 return & SQLSinker {
3638 Shutter : shutter .New (),
3739 Sinker : sink ,
@@ -42,6 +44,7 @@ func New(sink *sink.Sinker, loader *db.Loader, logger *zap.Logger, tracer loggin
4244
4345 stats : NewStats (logger ),
4446 lastAppliedBlockNum : nil ,
47+ manifestPath : manifestPath ,
4548 }, nil
4649}
4750
@@ -90,6 +93,24 @@ func (s *SQLSinker) Run(ctx context.Context) {
9093 zap .String ("database" , s .loader .GetDatabase ()),
9194 zap .String ("schema" , s .loader .GetSchema ()),
9295 )
96+
97+ endpoint , _ , _ := s .EndpointConfig ()
98+ endBlockStr := "open"
99+ if endBlock := s .BlockRange ().EndBlock (); endBlock != nil {
100+ endBlockStr = strconv .FormatUint (* endBlock , 10 )
101+ }
102+
103+ SinkInfo .SetInt64 (1 ,
104+ endpoint ,
105+ s .loader .GetDatabase (),
106+ s .loader .GetSchema (),
107+ s .loader .GetDatabaseHost (),
108+ s .manifestPath ,
109+ s .OutputModuleName (),
110+ s .OutputModuleHash (),
111+ strconv .FormatUint (s .BlockRange ().StartBlock (), 10 ),
112+ endBlockStr ,
113+ strconv .FormatUint (cursor .Block ().Num (), 10 ))
93114 s .Sinker .Run (ctx , cursor , s )
94115}
95116
0 commit comments