Documentation ¶
Index ¶
- Variables
- func NewSegmentLoggerAdapter(log logrus.FieldLogger) segment.Logger
- func ReportPanicIfOccurs(log logrus.FieldLogger, reporter FatalErrorAnalyticsReporter)
- type BatchedDataStore
- 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, _ int) error
- func (n NoopReporter) ReportCommand(_ ReportCommandInput) error
- func (n NoopReporter) ReportFatalError(_ error) error
- func (n NoopReporter) ReportHandledEventError(_ ReportEventInput, _ error) error
- func (n NoopReporter) ReportHandledEventSuccess(_ ReportEventInput) error
- func (n NoopReporter) ReportPluginsEnabled(_ map[string]config.Executors, _ map[string]config.Sources) error
- func (n NoopReporter) ReportSinkEnabled(_ config.CommPlatformIntegration, _ int) error
- func (n NoopReporter) Run(_ context.Context) error
- type ReportCommandInput
- type ReportEventInput
- 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, commGroupIdx int) error
- func (r *SegmentReporter) ReportCommand(in ReportCommandInput) error
- func (r *SegmentReporter) ReportFatalError(err error) error
- func (r *SegmentReporter) ReportHandledEventError(event ReportEventInput, err error) error
- func (r *SegmentReporter) ReportHandledEventSuccess(event ReportEventInput) error
- func (r *SegmentReporter) ReportPluginsEnabled(executors map[string]config.Executors, sources map[string]config.Sources) error
- func (r *SegmentReporter) ReportSinkEnabled(platform config.CommPlatformIntegration, commGroupIdx int) error
- func (r *SegmentReporter) Run(ctx context.Context) 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(log logrus.FieldLogger, 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 BatchedDataStore ¶ added in v1.6.0
type BatchedDataStore interface { AddSourceEvent(event batched.SourceEvent) HeartbeatProperties() batched.HeartbeatProperties IncrementTimeWindowInHours() Reset() }
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, _ int) error
ReportBotEnabled reports an enabled bot.
func (NoopReporter) ReportCommand ¶
func (n NoopReporter) ReportCommand(_ ReportCommandInput) 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(_ ReportEventInput, _ error) error
ReportHandledEventError reports a failure while handling event using a given communication platform.
func (NoopReporter) ReportHandledEventSuccess ¶
func (n NoopReporter) ReportHandledEventSuccess(_ ReportEventInput) error
ReportHandledEventSuccess reports a successfully handled event using a given communication platform.
func (NoopReporter) ReportPluginsEnabled ¶ added in v1.9.0
func (n NoopReporter) ReportPluginsEnabled(_ map[string]config.Executors, _ map[string]config.Sources) error
ReportPluginsEnabled reports plugins enabled.
func (NoopReporter) ReportSinkEnabled ¶
func (n NoopReporter) ReportSinkEnabled(_ config.CommPlatformIntegration, _ int) error
ReportSinkEnabled reports an enabled sink.
type ReportCommandInput ¶ added in v1.6.0
type ReportEventInput ¶ added in v1.6.0
type ReportEventInput struct { IntegrationType config.IntegrationType Platform config.CommPlatformIntegration PluginName string AnonymizedEventFields map[string]any }
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(in ReportCommandInput) error // ReportBotEnabled reports an enabled bot. ReportBotEnabled(platform config.CommPlatformIntegration, commGroupIdx int) error // ReportSinkEnabled reports an enabled sink. ReportSinkEnabled(platform config.CommPlatformIntegration, commGroupIdx int) error // ReportHandledEventSuccess reports a successfully handled event using a given integration type, communication platform, and plugin. ReportHandledEventSuccess(event ReportEventInput) error // ReportHandledEventError reports a failure while handling event using a given integration type, communication platform, and plugin. ReportHandledEventError(event ReportEventInput, err error) error // ReportFatalError reports a fatal app error. ReportFatalError(err error) error // ReportPluginsEnabled reports plugins enabled. ReportPluginsEnabled(executors map[string]config.Executors, sources map[string]config.Sources) error Run(ctx context.Context) 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, commGroupIdx int) error
ReportBotEnabled reports an enabled bot. The RegisterCurrentIdentity needs to be called first.
func (*SegmentReporter) ReportCommand ¶
func (r *SegmentReporter) ReportCommand(in ReportCommandInput) 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 ReportEventInput, 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 ReportEventInput) error
ReportHandledEventSuccess reports a successfully handled event using a given communication platform. The RegisterCurrentIdentity needs to be called first.
func (*SegmentReporter) ReportPluginsEnabled ¶ added in v1.9.0
func (r *SegmentReporter) ReportPluginsEnabled(executors map[string]config.Executors, sources map[string]config.Sources) error
ReportPluginsEnabled reports plugins enabled.
func (*SegmentReporter) ReportSinkEnabled ¶
func (r *SegmentReporter) ReportSinkEnabled(platform config.CommPlatformIntegration, commGroupIdx int) error
ReportSinkEnabled reports an enabled sink. The RegisterCurrentIdentity needs to be called first.