Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce amount of anonymous analytics events #1310

Merged
merged 3 commits into from
Nov 17, 2023

Conversation

pkosiec
Copy link
Collaborator

@pkosiec pkosiec commented Nov 16, 2023

Description

Changes proposed in this pull request:

  • Reduce amount of anonymous analytics events

Testing

The easiest way is to reduce the tickDuration in code (Segment Reporter):

 // NewSegmentReporter creates a new SegmentReporter instance.
 func NewSegmentReporter(log logrus.FieldLogger, cli segment.Client) *SegmentReporter {
 	return &SegmentReporter{
 		log:          log,
 		cli:          cli,
 		batchedData:  batched.NewData(defaultTimeWindowInHours),
-		tickDuration: defaultTimeWindowInHours * time.Hour,
+		tickDuration: 10 * time.Seconds,
 	}
 }

In the same file, you can set fixed APIKey:

 var (
 	// APIKey contains the API key for external analytics service. It is set during application build.
-	APIKey string
+	APIKey string = "abc..."
 )

Run Botkube with debug log (export BOTKUBE_SETTINGS_LOG_LEVEL=debug) and observe Segment events in debugger. Emit some sample events.

Screenshots

image
image

Related issue(s)

@pkosiec pkosiec added the enhancement New feature or request label Nov 16, 2023
@pkosiec pkosiec marked this pull request as ready for review November 16, 2023 19:07
@pkosiec pkosiec requested a review from PrasadG193 as a code owner November 16, 2023 19:07
@pkosiec pkosiec requested review from a team and mszostok November 16, 2023 19:07
Copy link
Collaborator

@mszostok mszostok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't test that with real segment, but code LGTM 👍

But please double-check with Ole that Segment.io doesn't have any message size limit.

Because we may switch the events quota problems to size quota problem 😄

If so, we can keep details maybe about N last source events? while counters will still tell about the exact number. This will prevent us from failing to send an event when e.g. agent cluster is misconfigured and someone watches e.g. for all events.

internal/analytics/segment_reporter.go Outdated Show resolved Hide resolved
@pkosiec pkosiec enabled auto-merge (squash) November 17, 2023 09:36
@pkosiec
Copy link
Collaborator Author

pkosiec commented Nov 17, 2023

Merging as the integration test issue for Discord wasn't related to the PR and Slack tests passed 👍

@pkosiec pkosiec disabled auto-merge November 17, 2023 10:09
@pkosiec pkosiec merged commit b8dc1bb into kubeshop:main Nov 17, 2023
15 checks passed
@pkosiec pkosiec deleted the improve-telemetry branch November 17, 2023 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants