github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/core/quality/metrics.go (about) 1 /* 2 * Copyright (C) 2018 The "MysteriumNetwork/node" Authors. 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 package quality 19 20 import "time" 21 22 const ( 23 // StagePraseRequest describes connection request parse event. 24 StagePraseRequest = "parse_request" 25 // StageValidateRequest describes connection request validate event. 26 StageValidateRequest = "validate_request" 27 28 // StageNoProposal describes connection request event when proposal does not exists. 29 StageNoProposal = "no_proposal" 30 // StageGetProposal describes proposal get event for connection create. 31 StageGetProposal = "get_proposal" 32 33 // StageConnectionOK describes successful connection event. 34 StageConnectionOK = "connection_ok" 35 // StageConnectionCanceled describes canceled connection event. 36 StageConnectionCanceled = "connection_canceled" 37 // StageConnectionAlreadyExists describes already exists connection event. 38 StageConnectionAlreadyExists = "connection_already_exists" 39 // StageConnectionUnknownError describes unknown connection event. 40 StageConnectionUnknownError = "connection_unknown_error" 41 42 // StageRegistrationGetStatus describes getting registration status event. 43 StageRegistrationGetStatus = "registration_get_status" 44 // StageRegistrationUnregistered describes registration unregistered status event. 45 StageRegistrationUnregistered = "registration_unregistered" 46 // StageRegistrationInProgress describes registration in progress status event. 47 StageRegistrationInProgress = "registration_in_progress" 48 // StageRegistrationRegistered describes registration registered status event. 49 StageRegistrationRegistered = "registration_registered" 50 // StageRegistrationUnknown describes registration unknown status event. 51 StageRegistrationUnknown = "registration_unknown" 52 ) 53 54 // ProposalQuality represents a proposal with quality info. 55 type ProposalQuality struct { 56 ProposalID ProposalID `json:"proposalId"` 57 Quality float64 `json:"quality"` 58 MonitoringFailed bool `json:"monitoringFailed"` 59 } 60 61 // MonitoringStatus identity's monitoring status 62 type MonitoringStatus struct { 63 MonitoringStatus string `json:"monitoring_status"` 64 } 65 66 // MonitoringStatusResponse monitoring status API response 67 type MonitoringStatusResponse = map[string]MonitoringStatus 68 69 // ProviderSession represents a provider session 70 type ProviderSession struct { 71 ProposalID ProposalID `json:"proposalId"` 72 ConnectCount ConnectCount `json:"connectCount"` 73 MonitoringFailed bool `json:"monitoringFailed"` 74 } 75 76 // ProposalID represents the struct used to uniquely identify proposals. 77 type ProposalID struct { 78 ProviderID string `json:"providerId" example:"0x286f0e9eb943eca95646bf4933698856579b096e"` 79 ServiceType string `json:"serviceType" example:"openvpn"` 80 } 81 82 // ConnectCount represents the connection count statistics. 83 type ConnectCount struct { 84 Success int `json:"success" example:"100" format:"int64"` 85 Fail int `json:"fail" example:"50" format:"int64"` 86 Timeout int `json:"timeout" example:"10" format:"int64"` 87 } 88 89 // ConnectionEvent represents the connection stages events. 90 type ConnectionEvent struct { 91 ServiceType string `json:"service_type"` 92 ProviderID string `json:"provider_id"` 93 ConsumerID string `json:"consumer_id"` 94 HermesID string `json:"hermes_id"` 95 Error string `json:"error"` 96 Stage string `json:"stage"` 97 } 98 99 // PingEvent represents p2p ping keepalive events. 100 type PingEvent struct { 101 SessionID string `json:"session_id"` 102 Duration time.Duration `json:"duration"` 103 } 104 105 const ( 106 // AppTopicConnectionEvents represents event bus topic for the connection events. 107 AppTopicConnectionEvents = "connection_events" 108 109 // AppTopicConsumerPingP2P represents event bus topic for consumer p2p pings to provider. 110 AppTopicConsumerPingP2P = "consumer_ping_p2p" 111 112 // AppTopicProviderPingP2P represents event bus topic for provider p2p pings to consumer. 113 AppTopicProviderPingP2P = "provider_ping_p2p" 114 )