Skip to content

Instantly share code, notes, and snippets.

@rolandshoemaker
Last active August 29, 2015 14:18
Show Gist options
  • Save rolandshoemaker/14c5b35bd622cb1853fb to your computer and use it in GitHub Desktop.
Save rolandshoemaker/14c5b35bd622cb1853fb to your computer and use it in GitHub Desktop.
activity monitor performance logging
deliveryTimings := make(map[string]time.Time)
// Run forever.
for d := range deliveries {
if d.ReplyTo != "" {
deliveryTimings[fmt.Sprintf("%s:%s", d.CorrelationId, d.ReplyTo)] = time.Now()
} else {
rpcSent := deliveryTimings[fmt.Sprintf("%s:%s", d.CorrelationId, d.RoutingKey)]
if rpcSent != nil {
respTime := time.Since(rpcSent)
delete(deliveryTimings, fmt.Sprintf("%s:%s", d.CorrelationId, d.RoutingKey))
fmt.Printf("RPC call [%s] from [%s] took %s\n", d.Type, d.RoutingKey, respTime)
}
}
// Pass each message to the Analysis Engine
err = ae.ProcessMessage(d)
if err != nil {
logger.Alert(fmt.Sprintf("Could not process message: %s", err))
} else {
// Only ack the delivery we actually handled (ackMultiple=false)
const ackMultiple = false
d.Ack(ackMultiple)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment