Delete all subscriptions when Ran is under reset.
[ric-plt/submgr.git] / pkg / control / metrics.go
1 package control
2
3 import (
4         "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
5 )
6
7 const (
8         cSubReqFromXapp         string = "SubReqFromXapp"
9         cRestSubReqFromXapp     string = "RestSubReqFromXapp"
10         cSubFailToXapp          string = "SubFailToXapp"
11         cSubRespToXapp          string = "SubRespToXapp"
12         cRestSubRespToXapp      string = "RestSubRespToXapp"
13         cRestSubFailToXapp      string = "RestSubFailToXapp"
14         cRestReqRejDueE2Down    string = "RestReqRejDueE2Down"
15         cRestSubNotifToXapp     string = "RestSubNotifToXapp"
16         cRestSubFailNotifToXapp string = "RestSubFailNotifToXapp"
17         cSubReqToE2             string = "SubReqToE2"
18         cSubReReqToE2           string = "SubReReqToE2"
19         cSubRespFromE2          string = "SubRespFromE2"
20         cPartialSubRespFromE2   string = "PartialSubRespFromE2"
21         cSubFailFromE2          string = "SubFailFromE2"
22         cSubReqTimerExpiry      string = "SubReqTimerExpiry"
23         cRouteCreateFail        string = "RouteCreateFail"
24         cRouteCreateUpdateFail  string = "RouteCreateUpdateFail"
25         cMergedSubscriptions    string = "MergedSubscriptions"
26         cDuplicateE2SubReq      string = "DuplicateE2SubReq"
27         cSubDelReqFromXapp      string = "SubDelReqFromXapp"
28         cSubDelRespToXapp       string = "SubDelRespToXapp"
29         cRestSubDelReqFromXapp  string = "RestSubDelReqFromXapp"
30         cRestSubDelRespToXapp   string = "RestSubDelRespToXapp"
31         cRestSubDelFailToXapp   string = "RestSubDelFailToXapp"
32         cSubDelReqToE2          string = "SubDelReqToE2"
33         cSubDelReReqToE2        string = "SubDelReReqToE2"
34         cSubDelRespFromE2       string = "SubDelRespFromE2"
35         cSubDelFailFromE2       string = "SubDelFailFromE2"
36         cSubDelReqTimerExpiry   string = "SubDelReqTimerExpiry"
37         cSubDelRequFromE2       string = "SubDelRequiredFromE2"
38         cRouteDeleteFail        string = "RouteDeleteFail"
39         cRouteDeleteUpdateFail  string = "RouteDeleteUpdateFail"
40         cUnmergedSubscriptions  string = "UnmergedSubscriptions"
41         cSDLWriteFailure        string = "SDLWriteFailure"
42         cSDLReadFailure         string = "SDLReadFailure"
43         cSDLRemoveFailure       string = "SDLRemoveFailure"
44         cE2StateChangedToUp     string = "E2StateChangedToUp"
45         cE2StateChangedToDown   string = "E2StateChangedToDown"
46         cE2StateUnderReset      string = "E2StateChangedToUnderReset"
47 )
48
49 func GetMetricsOpts() []xapp.CounterOpts {
50         return []xapp.CounterOpts{
51
52                 // Subscrition create counters
53                 {Name: cSubReqFromXapp, Help: "The total number of SubscriptionRequest messages received from xApp"},
54                 {Name: cSubRespToXapp, Help: "The total number of SubscriptionResponse messages sent to xApp"},
55                 {Name: cSubFailToXapp, Help: "The total number of SubscriptionFailure messages sent to xApp"},
56                 {Name: cRestSubReqFromXapp, Help: "The total number of Rest SubscriptionRequest messages received from xApp"},
57                 {Name: cRestSubRespToXapp, Help: "The total number of Rest SubscriptionResponse messages sent to xApp"},
58                 {Name: cRestSubFailToXapp, Help: "The total number of Rest SubscriptionFailure messages sent to xApp"},
59                 {Name: cRestReqRejDueE2Down, Help: "The total number of Rest SubscriptionRequest messages rejected due E2 Interface down"},
60                 {Name: cRestSubNotifToXapp, Help: "The total number of successful Rest SubscriptionNotification messages sent to xApp"},
61                 {Name: cRestSubFailNotifToXapp, Help: "The total number of failure Rest SubscriptionNotification messages sent to xApp"},
62                 {Name: cSubReqToE2, Help: "The total number of SubscriptionRequest messages sent to E2Term"},
63                 {Name: cSubReReqToE2, Help: "The total number of SubscriptionRequest messages resent to E2Term"},
64                 {Name: cPartialSubRespFromE2, Help: "The total number of partial SubscriptionResponse messages from E2Term"},
65                 {Name: cSubRespFromE2, Help: "The total number of SubscriptionResponse messages from E2Term"},
66                 {Name: cSubFailFromE2, Help: "The total number of SubscriptionFailure messages from E2Term"},
67                 {Name: cSubReqTimerExpiry, Help: "The total number of SubscriptionRequest timer expires"},
68                 {Name: cRouteCreateFail, Help: "The total number of subscription route create failure"},
69                 {Name: cRouteCreateUpdateFail, Help: "The total number of subscription route create update failure"},
70                 {Name: cMergedSubscriptions, Help: "The total number of merged Subscriptions"},
71                 {Name: cDuplicateE2SubReq, Help: "The total number of same E2 SubscriptionRequest messages from same xApp"},
72
73                 // Subscrition delete counters
74                 {Name: cSubDelReqFromXapp, Help: "The total number of SubscriptionDeleteRequest messages received from xApp"},
75                 {Name: cSubDelRespToXapp, Help: "The total number of SubscriptionDeleteResponse messages sent to xApp"},
76                 {Name: cRestSubDelReqFromXapp, Help: "The total number of Rest SubscriptionDeleteRequest messages received from xApp"},
77                 {Name: cRestSubDelRespToXapp, Help: "The total number of Rest SubscriptionDeleteResponse messages sent to xApp"},
78                 {Name: cRestSubDelFailToXapp, Help: "The total number of Rest SubscriptionDeleteFailure messages sent to xApp"},
79                 {Name: cSubDelReqToE2, Help: "The total number of SubscriptionDeleteRequest messages sent to E2Term"},
80                 {Name: cSubDelReReqToE2, Help: "The total number of SubscriptionDeleteRequest messages resent to E2Term"},
81                 {Name: cSubDelRespFromE2, Help: "The total number of SubscriptionDeleteResponse messages from E2Term"},
82                 {Name: cSubDelFailFromE2, Help: "The total number of SubscriptionDeleteFailure messages from E2Term"},
83                 {Name: cSubDelReqTimerExpiry, Help: "The total number of SubscriptionDeleteRequest timer expires"},
84                 {Name: cSubDelRequFromE2, Help: "The total number of SubscriptionDeleteRequired messages from E2Term"},
85                 {Name: cRouteDeleteFail, Help: "The total number of subscription route delete failure"},
86                 {Name: cRouteDeleteUpdateFail, Help: "The total number of subscription route delete update failure"},
87                 {Name: cUnmergedSubscriptions, Help: "The total number of unmerged Subscriptions"},
88
89                 // SDL failure counters
90                 {Name: cSDLWriteFailure, Help: "The total number of SDL write failures"},
91                 {Name: cSDLReadFailure, Help: "The total number of SDL read failures"},
92                 {Name: cSDLRemoveFailure, Help: "The total number of SDL remove failures"},
93
94                 // E2 interface state counters
95                 {Name: cE2StateChangedToUp, Help: "The total number of E2 interface change connected state"},
96                 {Name: cE2StateChangedToDown, Help: "The total number of E2 interface change disconnected state"},
97                 {Name: cE2StateUnderReset, Help: "The total number of E2 interface change under reset state"},
98         }
99 }
100
101 func (c *Control) UpdateCounter(counterName string) {
102         xapp.Logger.Debug("Add counterName=%v", counterName)
103         c.Counters[counterName].Inc()
104 }