zero/telemetry: calculate DAU and MAU (#4810)

This commit is contained in:
Denis Mishin 2023-12-11 13:37:01 -05:00 committed by GitHub
parent e0ac870442
commit c4dd965f2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 485 additions and 0 deletions

View file

@ -5,11 +5,13 @@ import (
"context"
"errors"
"fmt"
"time"
"github.com/rs/zerolog"
"golang.org/x/sync/errgroup"
"github.com/pomerium/pomerium/internal/log"
"github.com/pomerium/pomerium/internal/zero/analytics"
"github.com/pomerium/pomerium/internal/zero/bootstrap"
"github.com/pomerium/pomerium/internal/zero/reconciler"
"github.com/pomerium/pomerium/pkg/cmd/pomerium"
@ -43,6 +45,7 @@ func Run(ctx context.Context, opts ...Option) error {
eg.Go(func() error { return run(ctx, "pomerium-core", c.runPomeriumCore, src.WaitReady) })
eg.Go(func() error { return run(ctx, "zero-reconciler", c.runReconciler, src.WaitReady) })
eg.Go(func() error { return run(ctx, "connect-log", c.RunConnectLog, nil) })
eg.Go(func() error { return run(ctx, "zero-analytics", c.runAnalytics, src.WaitReady) })
return eg.Wait()
}
@ -117,3 +120,13 @@ func (c *controller) runReconciler(ctx context.Context) error {
reconciler.WithDataBrokerClient(c.GetDataBrokerServiceClient()),
)
}
func (c *controller) runAnalytics(ctx context.Context) error {
err := analytics.Collect(ctx, c.GetDataBrokerServiceClient(), time.Second*30)
if err != nil && ctx.Err() == nil {
log.Ctx(ctx).Error().Err(err).Msg("error collecting analytics, disabling")
return nil
}
return err
}