Documentation ¶
Overview ¶
package for monitoring and reporting the daemon metrics
package for monitoring and reporting the daemon metrics
package for monitoring and reporting the daemon metrics
package for monitoring and reporting the daemon metrics
Index ¶
- Constants
- func ConvertStructToJSON(payLoad interface{}) ([]byte, error)
- func GenXid() string
- func GetDaemonID() string
- func GetSize(v interface{}) uint64
- func GetValue(md metadata.MD, key string) string
- func HeartbeatHandler(rw http.ResponseWriter, r *http.Request)
- func Publish(payload interface{}, serviceUrl string, commonStats *CommonStats) bool
- func PublishResponseStats(commonStats *CommonStats, duration time.Duration, err error) bool
- func RegisterDaemon(serviceURL string) bool
- func SetDaemonGrpId(grpId string)
- func SetIsNoAlertsConfig(state bool)
- func SetNoHeartbeatURLState(state bool)
- func SignMessageForMetering(req *http.Request, commonStats *CommonStats)
- func ValidateHeartbeatConfig() error
- func ValidateNotificationConfig() error
- type ChannelStats
- type CommonStats
- type DaemonHeartbeat
- type Notification
- type RegisterDaemonPayload
- type RequestStats
- type Response
- type ResponseStats
- type Status
- type TokenGenerated
Constants ¶
const MeteringPrefix = "_usage"
Variables ¶
This section is empty.
Functions ¶
func ConvertStructToJSON ¶
convert the given struct to its corresponding json.
func GetDaemonID ¶
func GetDaemonID() string
generates DaemonID nad returns i.e. DaemonID = HASH (Org Name, Service Name, daemon endpoint)
func GetSize ¶
func GetSize(v interface{}) uint64
Generic utility to determine the size of the srtuct passed
func HeartbeatHandler ¶
func HeartbeatHandler(rw http.ResponseWriter, r *http.Request)
Heartbeat request handler function : upon request it will hit the service for status and wraps the results in daemons heartbeat
func Publish ¶
func Publish(payload interface{}, serviceUrl string, commonStats *CommonStats) bool
convert the payload to JSON and publish it to the serviceUrl passed
func PublishResponseStats ¶
func PublishResponseStats(commonStats *CommonStats, duration time.Duration, err error) bool
Publish response received as a payload for reporting /metrics analysis If there is an error in the response received from the service, then send out a notification as well.
func RegisterDaemon ¶
New Daemon registration. Generates the DaemonID and use that as getting access token
func SetIsNoAlertsConfig ¶
func SetIsNoAlertsConfig(state bool)
set the no alerts URL and email State
func SetNoHeartbeatURLState ¶
func SetNoHeartbeatURLState(state bool)
set the no heartbeat URL State
func SignMessageForMetering ¶
func SignMessageForMetering(req *http.Request, commonStats *CommonStats)
func ValidateHeartbeatConfig ¶
func ValidateHeartbeatConfig() error
validates the heartbeat configurations
func ValidateNotificationConfig ¶
func ValidateNotificationConfig() error
validates the heartbeat configurations
Types ¶
type ChannelStats ¶
type CommonStats ¶
type CommonStats struct { ID string ServiceMethod string RequestReceivedTime string OrganizationID string ServiceID string GroupID string DaemonEndPoint string Version string ClientType string UserDetails string UserAgent string ChannelId string UserName string PaymentMode string UserAddress string }
func BuildCommonStats ¶
func BuildCommonStats(receivedTime time.Time, methodName string) *CommonStats
type DaemonHeartbeat ¶
type DaemonHeartbeat struct { DaemonID string `json:"daemonID"` Timestamp string `json:"timestamp"` Status string `json:"status"` ServiceHeartbeat string `json:"serviceheartbeat"` }
define heartbeat data model. Service Status JSON object Array marshalled to a string
func GetHeartbeat ¶
func GetHeartbeat(serviceURL string, serviceType string, serviceID string) (heartbeat DaemonHeartbeat, err error)
prepares the heartbeat, which includes calling to underlying service DAemon is serving
func (*DaemonHeartbeat) Check ¶ added in v0.1.8
func (service *DaemonHeartbeat) Check(ctx context.Context, req *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error)
Check implements `service Health`.
func (*DaemonHeartbeat) Watch ¶ added in v0.1.8
func (service *DaemonHeartbeat) Watch(*grpc_health_v1.HealthCheckRequest, grpc_health_v1.Health_WatchServer) error
Watch implements `service Watch todo for later`.
type Notification ¶
type Notification struct { DaemonID string `json:"component_id"` Timestamp string `json:"timestamp"` Recipient string `json:"recipient"` Message string `json:"message"` Details string `json:"details"` Component string `json:"component"` Type string `json:"type"` Level string `json:"level"` }
define heartbeat data model. Service Status JSON object Array marshalled to a string
func (*Notification) Send ¶
func (alert *Notification) Send() bool
function for sending an alert to a given endpoint
type RegisterDaemonPayload ¶
type RequestStats ¶
type RequestStats struct { Type string `json:"type"` RegistryAddressKey string `json:"registry_address_key"` EthereumJsonRpcEndpointKey string `json:"ethereum_json_rpc_endpoint"` RequestID string `json:"request_id"` InputDataSize string `json:"input_data_size"` ServiceMethod string `json:"service_method"` RequestReceivedTime string `json:"request_received_time"` OrganizationID string `json:"organization_id"` ServiceID string `json:"service_id"` GroupID string `json:"group_id"` DaemonEndPoint string `json:"daemon_end_point"` Version string `json:"version"` ClientType string `json:"client_type"` UserDetails string `json:"user_details"` UserAgent string `json:"user_agent"` ChannelId string `json:"channel_id"` }
Request stats that will be captured
type ResponseStats ¶
type ResponseStats struct { Type string `json:"type"` RegistryAddressKey string `json:"registry_address_key"` EthereumJsonRpcEndpointKey string `json:"ethereum_json_rpc_endpoint"` RequestID string `json:"request_id"` OrganizationID string `json:"organization_id"` ServiceID string `json:"service_id"` GroupID string `json:"group_id"` ServiceMethod string `json:"service_method"` ResponseSentTime string `json:"response_sent_time"` RequestReceivedTime string `json:"request_received_time"` ResponseTime string `json:"response_time"` ResponseCode string `json:"response_code"` ErrorMessage string `json:"error_message"` Version string `json:"version"` ClientType string `json:"client_type"` UserDetails string `json:"user_details"` UserAgent string `json:"user_agent"` ChannelId string `json:"channel_id"` UserName string `json:"username"` Operation string `json:"operation"` UsageType string `json:"usage_type"` Status string `json:"status"` StartTime string `json:"start_time"` EndTime string `json:"end_time"` UsageValue int `json:"usage_value"` TimeZone string `json:"time_zone"` PaymentMode string `json:"payment_mode"` UserAddress string `json:"user_address"` }
Response stats that will be captured and published