*pubsub.Message) { start := time.Now() log.Println("Receive message") log.Printf("Start consume process") statsHandler.HandleProcess(ctx, &Receive{ BeginTime: start, }) defer func() { log.Printf("End consume process. time: %v", time.Since(start)) if p := recover(); p != nil { raven.CaptureError(err, nil) log.Printf("Revoery from panic: %v", p) } }() consumeBeginTime := time.Now() var err error ctx = statsHandler.TagProcess(ctx, &ConsumeBeginTag{}) defer func() { statsHandler.HandleProcess(ctx, &ConsumeEnd{ BeginTime: consumeBeginTime, EndTime: time.Now(), Error: err, }) statsHandler.HandleProcess(ctx, &End{ MsgCount: 1, BeginTime: start, EndTime: time.Now(), }) } var post Post if err = json.Unmarshal(msg.Data, &post); err != nil { raven.CaptureError(err, nil) log.Printf("could not decode message data: %#v", msg) msg.Ack() return } if err = update(post); err != nil { raven.CaptureError(err, nil) log.Printf("[ID %d] could not update: %v", post.Id, err) msg.Nack() return } msg.Ack() }) ෳϝοηʔδΛॲཧ͍ͨ͠