Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated no-op flags to setup Colletor's logging #4213

Merged
merged 3 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 (#4213)
codeboten marked this conversation as resolved.
Show resolved Hide resolved

## 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!")
}
}