amit.ghosh | 6ab2a98 | 2022-09-15 21:04:53 +0200 | [diff] [blame] | 1 | /* |
Joey Armstrong | 7f8436c | 2023-07-09 20:23:27 -0400 | [diff] [blame] | 2 | * Copyright 2018-2023 Open Networking Foundation (ONF) and the ONF Contributors |
amit.ghosh | 6ab2a98 | 2022-09-15 21:04:53 +0200 | [diff] [blame] | 3 | |
Joey Armstrong | 7f8436c | 2023-07-09 20:23:27 -0400 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
amit.ghosh | 6ab2a98 | 2022-09-15 21:04:53 +0200 | [diff] [blame] | 7 | |
Joey Armstrong | 7f8436c | 2023-07-09 20:23:27 -0400 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
amit.ghosh | 6ab2a98 | 2022-09-15 21:04:53 +0200 | [diff] [blame] | 9 | |
Joey Armstrong | 7f8436c | 2023-07-09 20:23:27 -0400 | [diff] [blame] | 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
amit.ghosh | 6ab2a98 | 2022-09-15 21:04:53 +0200 | [diff] [blame] | 15 | */ |
| 16 | package stats |
| 17 | |
| 18 | type DeviceCounter string |
| 19 | type NonDeviceCounter string |
| 20 | |
| 21 | type NonDeviceDuration string |
| 22 | type DeviceDuration string |
| 23 | |
| 24 | // The unit for all the time based metrics are in milli seconds |
| 25 | |
| 26 | const ( |
| 27 | // OLT Device stats |
| 28 | //----------------- |
| 29 | // Number of ONU Discovery messages received by the OLT adapter |
| 30 | NumDiscoveriesReceived DeviceCounter = "discoveries_received_total" |
| 31 | // Number of ONUs successfully activated by the OLT adapter |
| 32 | NumOnusActivated DeviceCounter = "activated_onus_total" |
| 33 | |
| 34 | // ONT Device stats |
| 35 | //----------------- |
| 36 | // Number of times transmission retries for OMCI messages were done for a specific ONU |
| 37 | OmciCCTxRetries DeviceCounter = "omci_cc_tx_retries_total" |
| 38 | // Number of times transmission timeouts for OMCI messages happened for a specific ONU |
| 39 | OmciCCTxTimeouts DeviceCounter = "omci_cc_tx_timeous_total" |
| 40 | |
| 41 | // Other not device specific stats |
| 42 | //-------------------------------- |
| 43 | // Number of times writing to the message bus failed, could be collected by adapters as well as vCore |
| 44 | NumErrorsWritingToBus NonDeviceCounter = "bus_write_errors_total" |
| 45 | // Number of times rpc calls to the vCore resulted in errors at the adapters |
| 46 | NumCoreRpcErrors NonDeviceCounter = "core_rpc_errors_total" |
| 47 | // Number of times rpc calls to the adapters resulted in errors at the vCore |
| 48 | NumAdapterRpcErrors NonDeviceCounter = "adapter_rpc_errors_total" |
| 49 | |
| 50 | // OLT Device durations |
| 51 | //--------------------- |
| 52 | // Time taken at the OLT adapter to process successfully an ONU Discovery message received |
| 53 | OnuDiscoveryProcTime DeviceDuration = "onu_discovery_proc_time" |
| 54 | // Time taken at the OLT adapter to successfully activate an ONU |
| 55 | OnuDiscToActivateTime DeviceDuration = "onu_discovery_to_activate_time" |
| 56 | // Time taken at the OLT adapter from the time the ONU Discovery was received to the first flow being pushed for the ONU |
| 57 | OnuDiscToFlowsPushedTime DeviceDuration = "onu_disc_to_flows_pushed_time" |
| 58 | |
| 59 | // ONU Device durations |
| 60 | //--------------------- |
| 61 | |
| 62 | // Other not device specific durations |
| 63 | //------------------------------------ |
| 64 | // Time taken to write an entry to the database, could be collected by all the three users of the database |
| 65 | DBWriteTime NonDeviceDuration = "db_write_time" |
| 66 | // Time taken to read an entry from the database, could be collected by all the three users of the database |
| 67 | DBReadTime NonDeviceDuration = "db_read_time" |
| 68 | ) |
| 69 | |
| 70 | func (s DeviceCounter) String() string { |
| 71 | switch s { |
| 72 | case NumDiscoveriesReceived: |
| 73 | return "discoveries_received_total" |
| 74 | case NumOnusActivated: |
| 75 | return "activated_onus_total" |
| 76 | case OmciCCTxRetries: |
| 77 | return "omci_cc_tx_retries_total" |
| 78 | case OmciCCTxTimeouts: |
| 79 | return "omci_cc_tx_timeous_total" |
| 80 | } |
| 81 | return "unknown" |
| 82 | } |
| 83 | |
| 84 | func (s NonDeviceCounter) String() string { |
| 85 | switch s { |
| 86 | case NumErrorsWritingToBus: |
| 87 | return "bus_write_errors_total" |
| 88 | case NumCoreRpcErrors: |
| 89 | return "core_rpc_errors_total" |
| 90 | case NumAdapterRpcErrors: |
| 91 | return "adapter_rpc_errors_total" |
| 92 | } |
| 93 | return "unknown" |
| 94 | } |
| 95 | |
| 96 | func (s NonDeviceDuration) String() string { |
| 97 | switch s { |
| 98 | case DBWriteTime: |
| 99 | return "db_write_time" |
| 100 | case DBReadTime: |
| 101 | return "db_read_time" |
| 102 | } |
| 103 | return "unknown" |
| 104 | } |
| 105 | |
| 106 | func (s DeviceDuration) String() string { |
| 107 | switch s { |
| 108 | case OnuDiscoveryProcTime: |
| 109 | return "onu_discovery_proc_time" |
| 110 | case OnuDiscToActivateTime: |
| 111 | return "onu_discovery_to_activate_time" |
| 112 | case OnuDiscToFlowsPushedTime: |
| 113 | return "onu_disc_to_flows_pushed_time" |
| 114 | } |
| 115 | return "unknown" |
| 116 | } |