Skip to content

Commit

Permalink
Disable telemetry (#929)
Browse files Browse the repository at this point in the history
Disables latest version checking and log upload when telemetry is
disabled. It disables a lot of noisy logs in air-gapped version.
  • Loading branch information
jakozaur authored Oct 31, 2024
1 parent 72cab08 commit 02b8318
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
12 changes: 8 additions & 4 deletions quesma/quesma/config/config_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,6 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
if conf.Elasticsearch, err = c.getElasticsearchConfig(); err != nil {
errAcc = multierror.Append(errAcc, err)
}
if !c.DisableTelemetry {
conf.QuesmaInternalTelemetryUrl = telemetryUrl
conf.Logging.RemoteLogDrainUrl = telemetryUrl
}
// This is perhaps a little oversimplification, **but** in case any of the FE connectors has auth disabled, we disable auth for the whole incomming traffic
// After all, the "duality" of frontend connectors is still an architectural choice we tend to question
for _, fConn := range c.FrontendConnectors {
Expand All @@ -520,6 +516,14 @@ func (c *QuesmaNewConfiguration) TranslateToLegacyConfig() QuesmaConfiguration {
conf.Logging.Level = &DefaultLogLevel
}

if !c.DisableTelemetry {
conf.QuesmaInternalTelemetryUrl = telemetryUrl
conf.Logging.RemoteLogDrainUrl = telemetryUrl
} else {
conf.QuesmaInternalTelemetryUrl = nil
conf.Logging.RemoteLogDrainUrl = nil
}

conf.InstallationId = c.InstallationId
conf.LicenseKey = c.LicenseKey

Expand Down
10 changes: 7 additions & 3 deletions quesma/quesma/ui/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (qmc *QuesmaManagementConsole) generateDashboardPanel() []byte {
buffer.Html(`<div id="dashboard-quesma" class="component">`)
buffer.Html(`<h3>Quesma</h3>`)

buffer = maybePrintUpgradeAvailableBanner(buffer)
buffer.Write(qmc.maybePrintUpgradeAvailableBanner())

buffer.Html(`<div class="status">Version: `)
buffer.Text(buildinfo.Version)
Expand Down Expand Up @@ -244,13 +244,17 @@ type latestVersionCheckResult struct {

// maybePrintUpgradeAvailableBanner has time cap of 500ms to check for the latest version, if it takes longer than that,
// it will log an error message and don't render anything
func maybePrintUpgradeAvailableBanner(buffer builder.HtmlBuffer) builder.HtmlBuffer {
func (qmc *QuesmaManagementConsole) maybePrintUpgradeAvailableBanner() []byte {
if qmc.cfg.Logging.RemoteLogDrainUrl == nil {
return nil
}

resultChan := make(chan latestVersionCheckResult, 1)
go func() {
upgradeAvailable, message := buildinfo.CheckForTheLatestVersion()
resultChan <- latestVersionCheckResult{upgradeAvailable, message}
}()
buffer := builder.HtmlBuffer{}
select {
case result := <-resultChan:
if result.upgradeAvailable {
Expand All @@ -261,5 +265,5 @@ func maybePrintUpgradeAvailableBanner(buffer builder.HtmlBuffer) builder.HtmlBuf
case <-time.After(500 * time.Millisecond):
logger.Error().Msg("Timeout while checking for the latest version.")
}
return buffer
return buffer.Bytes()
}

0 comments on commit 02b8318

Please sign in to comment.