Skip to content

Commit

Permalink
chore: Add debug logging (#2042)
Browse files Browse the repository at this point in the history
Add debug logging
  • Loading branch information
shazlehu authored Dec 16, 2024
1 parent 5a8d2f4 commit 0bb6aaf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions opamp/observiq/observiq_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,13 +370,15 @@ func (c *Client) onRemoteConfigHandler(ctx context.Context, remoteConfig *protob
remoteCfgStatus.ErrorMessage = fmt.Sprintf("Failed to apply config changes: %s", err.Error())
}

c.logger.Debug("Setting remote config status", zap.String("status", remoteCfgStatus.Status.String()))
// Set the remote config status
if err := c.opampClient.SetRemoteConfigStatus(remoteCfgStatus); err != nil {
return fmt.Errorf("failed to set remote config status: %w", err)
}

// If we changed the config call UpdateEffectiveConfig
if changed {
c.logger.Debug("Updating effective config")
if err := c.opampClient.UpdateEffectiveConfig(ctx); err != nil {
return fmt.Errorf("failed to update effective config: %w", err)
}
Expand Down
9 changes: 7 additions & 2 deletions opamp/observiq/reload_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func managerReload(client *Client, managerConfigPath string) opamp.ReloadFunc {
func collectorReload(client *Client, collectorConfigPath string) opamp.ReloadFunc {
return func(contents []byte) (bool, error) {
rollbackFunc, cleanupFunc, err := prepRollback(collectorConfigPath)
client.logger.Debug("Rollback prepped", zap.String("collectorConfigPath", collectorConfigPath))
if err != nil {
return false, fmt.Errorf("failed to prep for rollback: %w", err)
}
Expand All @@ -129,15 +130,18 @@ func collectorReload(client *Client, collectorConfigPath string) opamp.ReloadFun
if err := updateConfigFile(CollectorConfigName, collectorConfigPath, contents); err != nil {
return false, err
}

client.logger.Debug("Config file updated", zap.String("name", CollectorConfigName), zap.String("collectorConfigPath", collectorConfigPath))
// Stop collector monitoring as we are going to restart it
client.stopCollectorMonitoring()

client.logger.Debug("Collector monitoring stopped")
// Setup new monitoring after collector has been restarted
defer client.startCollectorMonitoring(context.Background())

// Reload collector
if err := client.collector.Restart(context.Background()); err != nil {
client.logger.Debug("OTEL Collector restart error", zap.Error(err))

// Rollback file
if rollbackErr := rollbackFunc(); rollbackErr != nil {
client.logger.Error("Rollback failed for collector config", zap.Error(rollbackErr))
Expand All @@ -150,9 +154,10 @@ func collectorReload(client *Client, collectorConfigPath string) opamp.ReloadFun

return false, fmt.Errorf("collector failed to restart: %w", err)
}

client.logger.Debug("OTEL Collector restarted")
// Reset Snapshot Reporter
report.GetSnapshotReporter().Reset()
client.logger.Debug("Snapshot reporter reset")

return true, nil
}
Expand Down

0 comments on commit 0bb6aaf

Please sign in to comment.