MCPcopy
hub / github.com/nats-io/nats.go / Stats

Method Stats

micro/service.go:778–806  ·  view source on GitHub ↗

Stats returns statistics for the service endpoint and all monitoring endpoints.

()

Source from the content-addressed store, hash-verified

776
777// Stats returns statistics for the service endpoint and all monitoring endpoints.
778func (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.
809func (s *service) Reset() {

Callers 1

AddServiceFunction · 0.95

Calls 1

serviceIdentityMethod · 0.95

Tested by

no test coverage detected