Skip to content

Commit

Permalink
Logging
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandros Filios <[email protected]>
  • Loading branch information
alexandrosfilios committed Dec 19, 2024
1 parent 1a441b3 commit e8df8b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions platform/fabric/core/generic/committer/committer.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ func (c *Committer) CommitConfig(blockNumber uint64, raw []byte, env *common.Env

// Commit commits the transactions in the block passed as argument
func (c *Committer) Commit(ctx context.Context, block *common.Block) error {
logger.Infof("Received block [%d] in committer", block.Header.Number)
newCtx, span := c.metrics.Commits.Start(ctx, "commit_block")
defer span.End()

Expand Down
13 changes: 7 additions & 6 deletions platform/fabric/core/generic/delivery/delivery.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,14 @@ func (d *Delivery) Run(ctx context.Context) error {
var err error
waitTime := d.channelConfig.DeliverySleepAfterFailure()
for {
logger.Infof("Delivery service new iteration")
select {
case <-d.stop:
logger.Infof("Stop delivery run")
// Time to stop
return nil
case <-ctx.Done():
logger.Infof("Context of delivery canceled")
// Time to cancel
return errors.New("context done")
default:
Expand All @@ -161,6 +164,7 @@ func (d *Delivery) Run(ctx context.Context) error {

span.AddEvent("wait_message")
resp, err := df.Recv()
logger.Infof("Delivery service received response of type [%v]", resp.Type)
span.AddEvent("received_message")
if err != nil {
df = nil
Expand All @@ -176,17 +180,14 @@ func (d *Delivery) Run(ctx context.Context) error {
case *pb.DeliverResponse_Block:
span.SetAttributes(tracing.String(messageTypeLabel, block))
if r.Block == nil || r.Block.Data == nil || r.Block.Header == nil || r.Block.Metadata == nil {
if logger.IsEnabledFor(zapcore.DebugLevel) {
logger.Debugf("deliver service [%s:%s:%s], received nil block", d.client.Address(), d.NetworkName, d.channel)
}
logger.Infof("deliver service [%s:%s:%s], received nil block", d.client.Address(), d.NetworkName, d.channel)
span.RecordError(errors.New("nil block"))
time.Sleep(waitTime)
df = nil
}

if logger.IsEnabledFor(zapcore.DebugLevel) {
logger.Debugf("delivery service [%s:%s:%s], commit block [%d]", d.client.Address(), d.NetworkName, d.channel, r.Block.Header.Number)
}
logger.Infof("delivery service [%s:%s:%s], commit block [%d]", d.client.Address(), d.NetworkName, d.channel, r.Block.Header.Number)

d.lastBlockReceived = r.Block.Header.Number

span.AddEvent("invoke_callback")
Expand Down

0 comments on commit e8df8b3

Please sign in to comment.