Skip to content

Commit

Permalink
Improve logging on telemetry initialization (#4189)
Browse files Browse the repository at this point in the history
  • Loading branch information
mx-psi authored Oct 12, 2021
1 parent a298b10 commit 6654804
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions service/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ var collectorTelemetry collectorTelemetryExporter = &colTelemetry{}
// AddCollectorVersionTag indicates if the collector version tag should be added to all telemetry metrics
const AddCollectorVersionTag = true

const (
zapKeyTelemetryAddress = "address"
zapKeyTelemetryLevel = "level"
)

type collectorTelemetryExporter interface {
init(asyncErrorChannel chan<- error, ballastSizeBytes uint64, logger *zap.Logger) error
shutdown() error
Expand All @@ -72,15 +77,20 @@ func (tel *colTelemetry) init(asyncErrorChannel chan<- error, ballastSizeBytes u
}

func (tel *colTelemetry) initOnce(asyncErrorChannel chan<- error, ballastSizeBytes uint64, logger *zap.Logger) error {
logger.Info("Setting up own telemetry...")

level := configtelemetry.GetMetricsLevelFlagValue()
metricsAddr := getMetricsAddr()

if level == configtelemetry.LevelNone || metricsAddr == "" {
logger.Info(
"Skipping telemetry setup.",
zap.String(zapKeyTelemetryAddress, metricsAddr),
zap.String(zapKeyTelemetryLevel, level.String()),
)
return nil
}

logger.Info("Setting up own telemetry...")

var instanceID string

if getAddInstanceID() {
Expand All @@ -105,8 +115,8 @@ func (tel *colTelemetry) initOnce(asyncErrorChannel chan<- error, ballastSizeByt

logger.Info(
"Serving Prometheus metrics",
zap.String("address", metricsAddr),
zap.Int8("level", int8(level)), // TODO: make it human friendly
zap.String(zapKeyTelemetryAddress, metricsAddr),
zap.String(zapKeyTelemetryLevel, level.String()),
zap.String(semconv.AttributeServiceInstanceID, instanceID),
zap.String(semconv.AttributeServiceVersion, version.Version),
)
Expand Down

0 comments on commit 6654804

Please sign in to comment.