Skip to content

Commit

Permalink
Correct Telemetry uploading message reported in node.log (algorand#1605)
Browse files Browse the repository at this point in the history
Correct Telemetry uploading message reported in node.log
  • Loading branch information
algonautshant committed Oct 12, 2020
1 parent 95e4404 commit 284f69a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion daemon/algod/server.go
Expand Up @@ -103,10 +103,12 @@ func (s *Server) Initialize(cfg config.Local, phonebookAddresses []string, genes
// collected metrics decorations.
fmt.Fprintln(logWriter, "++++++++++++++++++++++++++++++++++++++++")
fmt.Fprintln(logWriter, "Logging Starting")
if s.log.GetTelemetryEnabled() {
if s.log.GetTelemetryUploadingEnabled() {
// May or may not be logging to node.log
fmt.Fprintf(logWriter, "Telemetry Enabled: %s\n", s.log.GetTelemetryHostName())
fmt.Fprintf(logWriter, "Session: %s\n", s.log.GetTelemetrySession())
} else {
// May or may not be logging to node.log
fmt.Fprintln(logWriter, "Telemetry Disabled")
}
fmt.Fprintln(logWriter, "++++++++++++++++++++++++++++++++++++++++")
Expand Down
11 changes: 11 additions & 0 deletions logging/log.go
Expand Up @@ -156,6 +156,7 @@ type Logger interface {
EnableTelemetry(cfg TelemetryConfig) error
UpdateTelemetryURI(uri string) error
GetTelemetryEnabled() bool
GetTelemetryUploadingEnabled() bool
Metrics(category telemetryspec.Category, metrics telemetryspec.MetricDetails, details interface{})
Event(category telemetryspec.Category, identifier telemetryspec.Event)
EventWithDetails(category telemetryspec.Category, identifier telemetryspec.Event, details interface{})
Expand Down Expand Up @@ -380,6 +381,9 @@ func (l logger) UpdateTelemetryURI(uri string) (err error) {
return
}

// GetTelemetryEnabled returns true if
// logging.config Enable, or SendToLog or config.json
// TelemetryToLog is true.
func (l logger) GetTelemetryEnabled() bool {
return l.loggerState.telemetry != nil
}
Expand All @@ -400,6 +404,13 @@ func (l logger) GetTelemetryURI() string {
return telemetryConfig.URI
}

// GetTelemetryUploadingEnabled returns true if telemetry logging is
// enabled for uploading messages.
// This is decided by Enable parameter in logging.config
func (l logger) GetTelemetryUploadingEnabled() bool {
return telemetryConfig.Enable
}

func (l logger) Metrics(category telemetryspec.Category, metrics telemetryspec.MetricDetails, details interface{}) {
if l.loggerState.telemetry != nil {
l.loggerState.telemetry.logMetrics(l, category, metrics, details)
Expand Down

0 comments on commit 284f69a

Please sign in to comment.