Documentation
¶
Index ¶
- Variables
- func NewSegmentLoggerAdapter(log logrus.FieldLogger) segment.Logger
- func ReportPanicIfOccurs(logger ReportPanicLogger, reporter FatalErrorAnalyticsReporter)
- type FatalErrorAnalyticsReporter
- type Identity
- type NoopReporter
- func (n NoopReporter) Close() error
- func (n NoopReporter) RegisterCurrentIdentity(_ context.Context, _ kubernetes.Interface, _ string) error
- func (n NoopReporter) ReportBotEnabled(_ config.CommPlatformIntegration) error
- func (n NoopReporter) ReportCommand(_ config.CommPlatformIntegration, _ string, _ command.Origin, _ bool) error
- func (n NoopReporter) ReportFatalError(_ error) error
- func (n NoopReporter) ReportHandledEventError(_ ReportEvent, _ error) error
- func (n NoopReporter) ReportHandledEventSuccess(_ ReportEvent) error
- func (n NoopReporter) ReportSinkEnabled(_ config.CommPlatformIntegration) error
- type ReportEvent
- type ReportPanicLogger
- type Reporter
- type SegmentReporter
- func (r *SegmentReporter) Close() error
- func (r *SegmentReporter) RegisterCurrentIdentity(ctx context.Context, k8sCli kubernetes.Interface, remoteDeployID string) error
- func (r *SegmentReporter) ReportBotEnabled(platform config.CommPlatformIntegration) error
- func (r *SegmentReporter) ReportCommand(platform config.CommPlatformIntegration, command string, origin command.Origin, ...) error
- func (r *SegmentReporter) ReportFatalError(err error) error
- func (r *SegmentReporter) ReportHandledEventError(event ReportEvent, err error) error
- func (r *SegmentReporter) ReportHandledEventSuccess(event ReportEvent) error
- func (r *SegmentReporter) ReportSinkEnabled(platform config.CommPlatformIntegration) error
Constants ¶
This section is empty.
Variables ¶
var ( // APIKey contains the API key for external analytics service. It is set during application build. APIKey string )
Functions ¶
func NewSegmentLoggerAdapter ¶
func NewSegmentLoggerAdapter(log logrus.FieldLogger) segment.Logger
NewSegmentLoggerAdapter returns new Segment logger adapter for logrus.FieldLogger.
func ReportPanicIfOccurs ¶
func ReportPanicIfOccurs(logger ReportPanicLogger, reporter FatalErrorAnalyticsReporter)
ReportPanicIfOccurs recovers from a panic and reports it, and then calls log.Fatal. This function should be called with `defer` at the beginning of the goroutine logic.
NOTE: Make sure the reporter is not closed before reporting the panic. It will be cleaned up as a part of this function.
Types ¶
type FatalErrorAnalyticsReporter ¶
type FatalErrorAnalyticsReporter interface { // ReportFatalError reports a fatal app error. ReportFatalError(err error) error // Close cleans up the reporter resources. Close() error }
FatalErrorAnalyticsReporter reports a fatal errors.
type Identity ¶
type Identity struct { DeploymentID string AnonymousID string KubernetesVersion k8sVersion.Info BotkubeVersion version.Details WorkerNodeCount int ControlPlaneNodeCount int }
Identity defines an anonymous identity for a given installation.
type NoopReporter ¶
type NoopReporter struct{}
NoopReporter implements Reporter interface, but is a no-op (doesn't execute any logic).
func NewNoopReporter ¶
func NewNoopReporter() *NoopReporter
NewNoopReporter creates new NoopReporter instance.
func (NoopReporter) Close ¶
func (n NoopReporter) Close() error
Close cleans up the reporter resources.
func (NoopReporter) RegisterCurrentIdentity ¶
func (n NoopReporter) RegisterCurrentIdentity(_ context.Context, _ kubernetes.Interface, _ string) error
RegisterCurrentIdentity loads the current anonymous identity and registers it.
func (NoopReporter) ReportBotEnabled ¶
func (n NoopReporter) ReportBotEnabled(_ config.CommPlatformIntegration) error
ReportBotEnabled reports an enabled bot.
func (NoopReporter) ReportCommand ¶
func (n NoopReporter) ReportCommand(_ config.CommPlatformIntegration, _ string, _ command.Origin, _ bool) error
ReportCommand reports a new executed command. The command should be anonymized before using this method.
func (NoopReporter) ReportFatalError ¶
func (n NoopReporter) ReportFatalError(_ error) error
ReportFatalError reports a fatal app error.
func (NoopReporter) ReportHandledEventError ¶
func (n NoopReporter) ReportHandledEventError(_ ReportEvent, _ error) error
ReportHandledEventError reports a failure while handling event using a given communication platform.
func (NoopReporter) ReportHandledEventSuccess ¶
func (n NoopReporter) ReportHandledEventSuccess(_ ReportEvent) error
ReportHandledEventSuccess reports a successfully handled event using a given communication platform.
func (NoopReporter) ReportSinkEnabled ¶
func (n NoopReporter) ReportSinkEnabled(_ config.CommPlatformIntegration) error
ReportSinkEnabled reports an enabled sink.
type ReportEvent ¶ added in v1.0.0
type ReportEvent struct { IntegrationType config.IntegrationType Platform config.CommPlatformIntegration PluginName string AnonymizedEventFields map[string]any }
type ReportPanicLogger ¶
type ReportPanicLogger interface { Errorf(format string, args ...interface{}) Fatal(args ...interface{}) }
ReportPanicLogger is a fakeLogger interface used by ReportPanicIfOccurs function.
type Reporter ¶
type Reporter interface { // RegisterCurrentIdentity loads the current anonymous identity and registers it. RegisterCurrentIdentity(ctx context.Context, k8sCli kubernetes.Interface, deployID string) error // ReportCommand reports a new executed command. The command should be anonymized before using this method. ReportCommand(platform config.CommPlatformIntegration, command string, origin command.Origin, withFilter bool) error // ReportBotEnabled reports an enabled bot. ReportBotEnabled(platform config.CommPlatformIntegration) error // ReportSinkEnabled reports an enabled sink. ReportSinkEnabled(platform config.CommPlatformIntegration) error // ReportHandledEventSuccess reports a successfully handled event using a given integration type, communication platform, and plugin. ReportHandledEventSuccess(event ReportEvent) error // ReportHandledEventError reports a failure while handling event using a given integration type, communication platform, and plugin. ReportHandledEventError(event ReportEvent, err error) error // ReportFatalError reports a fatal app error. ReportFatalError(err error) error // Close cleans up the reporter resources. Close() error }
Reporter defines an analytics reporter implementation.
type SegmentReporter ¶
type SegmentReporter struct {
// contains filtered or unexported fields
}
SegmentReporter is a default Reporter implementation that uses Twilio Segment.
func NewSegmentReporter ¶
func NewSegmentReporter(log logrus.FieldLogger, cli segment.Client) *SegmentReporter
NewSegmentReporter creates a new SegmentReporter instance.
func (*SegmentReporter) Close ¶
func (r *SegmentReporter) Close() error
Close cleans up the reporter resources.
func (*SegmentReporter) RegisterCurrentIdentity ¶
func (r *SegmentReporter) RegisterCurrentIdentity(ctx context.Context, k8sCli kubernetes.Interface, remoteDeployID string) error
RegisterCurrentIdentity loads the current anonymous identity and registers it.
func (*SegmentReporter) ReportBotEnabled ¶
func (r *SegmentReporter) ReportBotEnabled(platform config.CommPlatformIntegration) error
ReportBotEnabled reports an enabled bot. The RegisterCurrentIdentity needs to be called first.
func (*SegmentReporter) ReportCommand ¶
func (r *SegmentReporter) ReportCommand(platform config.CommPlatformIntegration, command string, origin command.Origin, withFilter bool) error
ReportCommand reports a new executed command. The command should be anonymized before using this method. The RegisterCurrentIdentity needs to be called first.
func (*SegmentReporter) ReportFatalError ¶
func (r *SegmentReporter) ReportFatalError(err error) error
ReportFatalError reports a fatal app error. It doesn't need a registered identity.
func (*SegmentReporter) ReportHandledEventError ¶
func (r *SegmentReporter) ReportHandledEventError(event ReportEvent, err error) error
ReportHandledEventError reports a failure while handling event using a given communication platform. The RegisterCurrentIdentity needs to be called first.
func (*SegmentReporter) ReportHandledEventSuccess ¶
func (r *SegmentReporter) ReportHandledEventSuccess(event ReportEvent) error
ReportHandledEventSuccess reports a successfully handled event using a given communication platform. The RegisterCurrentIdentity needs to be called first.
func (*SegmentReporter) ReportSinkEnabled ¶
func (r *SegmentReporter) ReportSinkEnabled(platform config.CommPlatformIntegration) error
ReportSinkEnabled reports an enabled sink. The RegisterCurrentIdentity needs to be called first.