Documentation ¶
Overview ¶
Package cplogs This file contains the code that handle logging information that get sent to an external server We send warning alerts when something that we do not expect happens We send operational metrics for each command such as, command name, arguments, duration, status etc..
Index ¶
Constants ¶
const ErrorFailedToSendDataToLoggingAPI = "failed to send the post request to the logging API"
ErrorFailedToSendDataToLoggingAPI is used as a log message when the post request to the logging api had failed
Variables ¶
This section is empty.
Functions ¶
func EndSessionAndSendErrorCause ¶
func EndSessionAndSendErrorCause(rc *RemoteCommand, s *session.CommandSession, err error)
func GetLogProxyAddr ¶
GetLogProxyAddr gets the api address for the cp logging proxy
Types ¶
type RemoteCommand ¶
type RemoteCommand struct { //to be set once the command terminates Duration time.Duration `json:"duration"` Status RemoteCommandStatus `json:"status"` //to be set at the beginning of the command execution Command string `json:"command"` Arguments []string `json:"arguments"` OsArch string `json:"os_arch"` ToolVersion string `json:"tool_version"` ConfigSettings RemoteCommandSettings `json:"config_settings"` //to be set at the beginning of the command execution, only for fetch, push, watch IgnoreFileContent string `json:"ignore_file_content"` //to be set at the beginning of the command execution, only for fetch IgnoreFetchFileContent string `json:"ignore_fetch_file_content"` }
RemoteCommand holds the data that is logged when a command terminates
func NewRemoteCommand ¶
func NewRemoteCommand(cmd string, args []string) *RemoteCommand
NewRemoteCommand create a new remote command struct for the given command and arguments
func (*RemoteCommand) Ended ¶
func (rc *RemoteCommand) Ended(code int, reason string, stack string, cmdSession session.CommandSession) *RemoteCommand
Ended indicates that the remote command has terminated its execution sets the duration and the command status
func (*RemoteCommand) EndedOk ¶
func (rc *RemoteCommand) EndedOk(cmdSession session.CommandSession) *RemoteCommand
EndedOk calls Ended setting the http status OK status
type RemoteCommandSender ¶
type RemoteCommandSender struct{}
RemoteCommandSender holds the dependencies required for the RemoteCommandSender
func NewRemoteCommandSender ¶
func NewRemoteCommandSender() *RemoteCommandSender
NewRemoteCommandSender ctor for RemoteCommandSender
func (RemoteCommandSender) Send ¶
func (s RemoteCommandSender) Send(rc RemoteCommand) error
Send sends a RemoteCommand to the log proxy url
type RemoteCommandSettings ¶
type RemoteCommandSettings struct { Username string `json:"username"` FlowID string `json:"flow-id"` ClusterIdentifier string `json:"cluster-identifier"` KubeEnvironmentName string `json:"kube-environment-name"` RemoteName string `json:"remote-name"` RemoteBranch string `json:"remote-branch"` Service string `json:"service"` RemoteEnvironmentID string `json:"remote-environment-id"` InitStatus string `json:"init-status"` CpKubeProxyEnabled string `json:"kube-proxy-enabled"` KubeDirectClusterAddr string `json:"kube-direct-cluster-addr"` KubeDirectClusterUser string `json:"kube-direct-cluster-user"` }
RemoteCommandSettings contains a subset of the local configuration data that we want to send along with logging information
type RemoteCommandStatus ¶
type RemoteCommandStatus struct { //An integer that represents the status. Should be between 100 and 999. Same as HTTP codes, the first digit categorises the event: //2xx: Success //3xx: Worked, but.. not sure if it should have happened //4xx: Something went wrong, but that’s very likely to be user’s fault //5xx: Something went wrong, very likely to be system’s fault Code int `json:"code"` //The reason describing why the event is a success or a failure. Reason string `json:"reason"` //The full error stack Stack string `json:"error_stack"` //A unique id which can be used to find any messages sent to Sentry or in the logs DebugIdentifier string `json:"debug_identifier"` }
RemoteCommandStatus groups status information about the remote command execution