// publishFailure publishes a failure/panic event to be monitored. func publishFailure(r interface{}) { var p string switch r.(type) { case string: p = r.(string) case error: p = fmt.Sprintf("%v", r.(error)) default: p = "Unknown panic" } b := make([]byte, 1024) runtime.Stack(b, true) if err := client.Pub("com.hailocab.monitor.failure", &fproto.Failure{ ServiceName: proto.String(Name), ServiceVersion: proto.Uint64(Version), AzName: proto.String(az), Hostname: proto.String(hostname), InstanceId: proto.String(InstanceID), Timestamp: proto.Int64(time.Now().Unix()), Uptime: proto.Int64(int64(time.Since(serviceStarted).Seconds())), Type: proto.String("PANIC"), Reason: proto.String(p), Stack: proto.String(string(b)), }); err != nil { log.Errorf("[Server] Failed to publish failure event: %v", err) } }
// publish func (s *stats) publish(status string) { if err := client.Pub("com.hailocab.monitor.stats", s.get(status)); err != nil { log.Errorf("[Server] Failed to publish service monitoring stats: %v", err) } }
// pubLastSample pings this healthcheck sample out into the ether func pubLastSample(hc *HealthCheck, ls *Sample) { client.Pub("com.hailocab.monitor.healthcheck", healthCheckSampleToProto(hc, ls)) }