Stats returns statistics for the service endpoint and all monitoring endpoints.
()
| 776 | |
| 777 | // Stats returns statistics for the service endpoint and all monitoring endpoints. |
| 778 | func (s *service) Stats() Stats { |
| 779 | s.m.Lock() |
| 780 | defer s.m.Unlock() |
| 781 | |
| 782 | stats := Stats{ |
| 783 | ServiceIdentity: s.serviceIdentity(), |
| 784 | Endpoints: make([]*EndpointStats, 0), |
| 785 | Type: StatsResponseType, |
| 786 | Started: s.started, |
| 787 | } |
| 788 | for _, endpoint := range s.endpoints { |
| 789 | endpointStats := &EndpointStats{ |
| 790 | Name: endpoint.stats.Name, |
| 791 | Subject: endpoint.stats.Subject, |
| 792 | QueueGroup: endpoint.stats.QueueGroup, |
| 793 | NumRequests: endpoint.stats.NumRequests, |
| 794 | NumErrors: endpoint.stats.NumErrors, |
| 795 | LastError: endpoint.stats.LastError, |
| 796 | ProcessingTime: endpoint.stats.ProcessingTime, |
| 797 | AverageProcessingTime: endpoint.stats.AverageProcessingTime, |
| 798 | } |
| 799 | if s.StatsHandler != nil { |
| 800 | data, _ := json.Marshal(s.StatsHandler(endpoint)) |
| 801 | endpointStats.Data = data |
| 802 | } |
| 803 | stats.Endpoints = append(stats.Endpoints, endpointStats) |
| 804 | } |
| 805 | return stats |
| 806 | } |
| 807 | |
| 808 | // Reset resets all statistics on a service instance. |
| 809 | func (s *service) Reset() { |
no test coverage detected