Skip to content

Commit

Permalink
Remove deprecated no-op flags to setup Colletor's logging
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu committed Oct 19, 2021
1 parent f85f13e commit 63bf940
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 50 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Rename `parserprovider.MapProvider` as `config.MapProvider` (#4178)
- Rename `parserprovider.Watchable` as `config.WatchableMapProvider` (#4178)
- Remove deprecated no-op flags to setup Colletor's logging (#)

## v0.37.0 Beta

Expand Down
9 changes: 1 addition & 8 deletions service/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"strings"

"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/collector/service/internal/telemetrylogs"
)

var (
Expand Down Expand Up @@ -52,13 +51,7 @@ func (s *stringArrayValue) String() string {

func flags() *flag.FlagSet {
flagSet := new(flag.FlagSet)
addFlagsFns := []func(*flag.FlagSet){
configtelemetry.Flags,
telemetrylogs.Flags,
}
for _, addFlags := range addFlagsFns {
addFlags(flagSet)
}
configtelemetry.Flags(flagSet)

// At least until we can use a generic, i.e.: OpenCensus, metrics exporter
// we default to Prometheus at port 8888, if not otherwise specified.
Expand Down
42 changes: 0 additions & 42 deletions service/internal/telemetrylogs/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,12 @@
package telemetrylogs // import "go.opentelemetry.io/collector/service/internal/telemetrylogs"

import (
"flag"

"go.uber.org/zap"
"go.uber.org/zap/zapcore"

"go.opentelemetry.io/collector/config"
)

const (
logLevelCfg = "log-level"
logProfileCfg = "log-profile"
logFormatCfg = "log-format"
)

var (
defaultLogValue = "deprecated"
// Command line pointer to logger level flag configuration.
loggerLevelPtr = &defaultLogValue
loggerProfilePtr = &defaultLogValue
loggerFormatPtr = &defaultLogValue
)

// Flags adds flags related to service telemetry logs to the given flagset.
// Deprecated: keep this flag for preventing the breaking change. Use `service::telemetry::logs` in config instead.
func Flags(flags *flag.FlagSet) {
loggerLevelPtr = flags.String(logLevelCfg, defaultLogValue, "Deprecated. Define the logging configuration as part of the configuration file, under the 'service' section.")

loggerProfilePtr = flags.String(logProfileCfg, defaultLogValue, "Deprecated. Define the logging configuration as part of the configuration file, under the 'service' section.")

// Note: we use "console" by default for more human-friendly mode of logging (tab delimited, formatted timestamps).
loggerFormatPtr = flags.String(logFormatCfg, defaultLogValue, "Deprecated. Define the logging configuration as part of the configuration file, under the 'service' section.")
}

func NewLogger(cfg config.ServiceTelemetryLogs, options []zap.Option) (*zap.Logger, error) {
// Copied from NewProductionConfig.
zapCfg := &zap.Config{
Expand All @@ -72,20 +45,5 @@ func NewLogger(cfg config.ServiceTelemetryLogs, options []zap.Option) (*zap.Logg
if err != nil {
return nil, err
}
logDeprecatedMessages(logger)
return logger, nil
}

func logDeprecatedMessages(logger *zap.Logger) {
if *loggerLevelPtr != defaultLogValue {
logger.Warn("`log-level` command line option has been deprecated. Use `service::telemetry::logs` in config instead!")
}

if *loggerProfilePtr != defaultLogValue {
logger.Warn("`log-profile` command line option has been deprecated. Use `service::telemetry::logs` in config instead!")
}

if *loggerFormatPtr != defaultLogValue {
logger.Warn("`log-format` command line option has been deprecated. Use `service::telemetry::logs` in config instead!")
}
}

0 comments on commit 63bf940

Please sign in to comment.