1 // pubsubplus-go-client 2 // 3 // Copyright 2021-2025 Solace Corporation. All rights reserved. 4 // 5 // Licensed under the Apache License, Version 2.0 (the "License"); 6 // you may not use this file except in compliance with the License. 7 // You may obtain a copy of the License at 8 // 9 // http://www.apache.org/licenses/LICENSE-2.0 10 // 11 // Unless required by applicable law or agreed to in writing, software 12 // distributed under the License is distributed on an "AS IS" BASIS, 13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 // See the License for the specific language governing permissions and 15 // limitations under the License. 16 17 // Package metrics contains the various metrics that can be retrieved as well as the 18 // interface for retrieving the metrics. 19 package metrics 20 21 // Metric represents the various metrics retrievable from a MessagingService's APIMetrics instance. 22 type Metric int 23 24 // The various metrics available. 25 const ( 26 // BrokerDiscardNotificationsReceived is the number of received messages 27 // with discard indication set. 28 BrokerDiscardNotificationsReceived Metric = iota 29 30 // CompressedBytesReceived is the number of bytes received before decompression. 31 CompressedBytesReceived 32 33 // ConnectionAttempts is the total number of TCP connection attempts. 34 ConnectionAttempts 35 36 // ControlBytesReceived is the number of control (non-data) messages received 37 // by the MessagingService. 38 ControlBytesReceived 39 40 // ControlBytesSent is the total number of control (non-data) bytes transmitted 41 // by the MessagingService. 42 ControlBytesSent 43 44 // ControlMessagesReceived is the total number of control (non-data) messages 45 // received by MessagingService. 46 ControlMessagesReceived 47 48 // ControlMessagesSent is the total number of control (non-data) messages 49 // transmitted by MessagingService. 50 ControlMessagesSent 51 52 // DirectBytesReceived is the number of direct messaging bytes received 53 // across all direct message publishers on the MessagingService. 54 DirectBytesReceived 55 56 // DirectBytesSent is the number of direct messaging bytes sent 57 // across all direct message publishers on the MessagingService. 58 DirectBytesSent 59 60 // DirectMessagesReceived is the number of direct messages received 61 // across all direct message publishers on the MessagingService. 62 DirectMessagesReceived 63 64 // DirectMessagesSent is the number of direct messages sent 65 // across all direct message publishers on the MessagingService. 66 DirectMessagesSent 67 68 // InternalDiscardNotifications is the number of messages received with 69 // internal discard notifications set. 70 InternalDiscardNotifications 71 72 // PersistentAcknowledgeSent is the number of acknowledgements 73 // sent for guaranteed messaging across all persistent message receivers 74 // on the MessagingService. 75 PersistentAcknowledgeSent 76 77 // PersistentBytesReceived is the number of persistent bytes received 78 // across all persistent message receivers on the Messaging Service. 79 PersistentBytesReceived 80 81 // PersistentBytesRedelivered is the number of persistent bytes 82 // redelivered across all persistent message publishers on the MessagingService. 83 PersistentBytesRedelivered 84 85 // PersistentBytesSent is the number of persistent bytes sent 86 // across all persistent message publishers on the MessagingService. 87 PersistentBytesSent 88 89 // The number of guaranteed messages dropped for being duplicates. 90 PersistentDuplicateMessagesDiscarded 91 92 // PersistentMessagesReceived is the number of persistent messages 93 // received across all persistent message receivers on the MessagingService. 94 PersistentMessagesReceived 95 96 // PersistentMessagesRedelivered is the number of persistent messages 97 // redelivered across all persistent message publishers on the MessagingService. 98 PersistentMessagesRedelivered 99 100 // PersistentMessagesSent is the number of persistent messages 101 // sent across all persistent message publishers on the MessagingService. 102 PersistentMessagesSent 103 104 // PersistentNoMatchingFlowMessagesDiscarded is the number of persistent 105 // messages discarded for not having a matching flow on the MessagingService. 106 PersistentNoMatchingFlowMessagesDiscarded 107 108 // PersistentOutOfOrderMessagesDiscarded is the number of persistent 109 // messages discarded for being received out of order across all 110 // persistent message receivers on the MessagingService. 111 PersistentOutOfOrderMessagesDiscarded 112 113 // Number of messages settled with "ACCEPTED" outcome. 114 PersistentMessagesAccepted 115 116 // Number of messages settled with "FAILED" outcome. 117 PersistentMessagesFailed 118 119 // Number of messages settled with "REJECTED" outcome. 120 PersistentMessagesRejected 121 122 // PublishMessagesDiscarded is the number of messages discarded due to 123 // channel failure. 124 PublishMessagesDiscarded 125 126 // PublishedMessagesAcknowledged is the number of guaranteed messages that have 127 // been published and acknowledged across all persistent message receivers 128 // on the MessagingService 129 PublishedMessagesAcknowledged 130 131 // PublisherAcknowledgementReceived is the number of publisher acknowledgements 132 // received by all persistent message publishers on the MessagingService. 133 PublisherAcknowledgementReceived 134 135 // PublisherAcknowledgementTimeouts is the number of expired acknowledgement timers 136 // across all persistent message publishers on the MessagingService. 137 PublisherAcknowledgementTimeouts 138 139 // PublisherWindowClosed is the nunber of times the transmit window closed across 140 // all message publishers on the MessagingService. 141 PublisherWindowClosed 142 143 // The number of messages not accepted due to would block (non-blocking publish only). 144 PublisherWouldBlock 145 146 // TotalBytesReceived is the total number of bytes received by the MessagingService 147 // and all of its message receivers. 148 TotalBytesReceived 149 150 // TotalBytesSent is the total number of bytes sent by the MessagingService 151 // and all of its message publishers. 152 TotalBytesSent 153 154 // TotalMessagesReceived is the total number of messages received by the 155 // MessagingService and all of its receivers. 156 TotalMessagesReceived 157 158 // TotalMessagesSent is the total number of messages sent by the MessagingService 159 // and all of its publishers. 160 TotalMessagesSent 161 162 // TooBigMessagesDiscarded is the number of messages discarded due to being too large. 163 TooBigMessagesDiscarded 164 165 // UnknownParameterMessagesDiscarded is the number of messages discarded due to the 166 // presence of an unknown element or unknown protocol in the Solace Message Format 167 // (SMF) header. 168 UnknownParameterMessagesDiscarded 169 170 // ReceivedMessagesTerminationDiscarded is the number of messages discarded due to 171 // a receiver being terminated either by application initiated termination or 172 // failure event termination. 173 ReceivedMessagesTerminationDiscarded 174 175 // ReceivedMessagesBackpressureDiscarded is the number of messages discarded due to 176 // a receiver not having buffer space to queue a message 177 ReceivedMessagesBackpressureDiscarded 178 179 // PublishMessagesTerminationDiscarded is the number of messages discarded due to 180 // a publisher being terminated either by application initiated termination or 181 // failure event termination. 182 PublishMessagesTerminationDiscarded 183 184 // PublishMessagesBackpressureDiscarded is the number of messages discarded due to 185 // a publisher not having buffer space to queue a message when in a buffered 186 // backpressure configuration. 187 PublishMessagesBackpressureDiscarded 188 189 // CacheRequestsSent indicates number of sent cache requests. 190 CacheRequestsSent 191 192 // CacheRequestsFailed indicates number of cache requests that failed. 193 CacheRequestsFailed 194 195 // CacheRequestsSucceeded indicates number of cache requests that succeeded. 196 CacheRequestsSucceeded 197 198 // MetricCount is the number of metrics defined by this package. 199 MetricCount int = iota 200 ) 201 202 // APIInfo allows for retrieval of various API properties transmitted to the Broker on connect. 203 type APIInfo interface { 204 // GetAPIBuildDate returns the build date of the current API in use. 205 GetAPIBuildDate() string 206 // GetAPIVersion returns the version of the current API in use. 207 GetAPIVersion() string 208 // GetAPIUserID returns the user ID transmitted to the broker. 209 GetAPIUserID() string 210 // GetAPIImplementationVendor returns the API implementation vendor transmitted to broker. 211 GetAPIImplementationVendor() string 212 } 213 214 // APIMetrics allows for retrieval of various metrics stored by the API. 215 type APIMetrics interface { 216 // GetValue will retrieve the value/count of the specified Metric. 217 GetValue(metric Metric) uint64 218 // Reset resets all metrics. 219 Reset() 220 } 221