Skip to content

Commit 62e599c

Browse files
authored
Fix manager logger initialization (#4585)
- Apply config before setting up logger to configure it properly - Fixes #4584
1 parent 21da3b8 commit 62e599c

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: bug_fix
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
5+
component: config
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: Fix manager logger initialization
9+
10+
# One or more tracking issues related to the change
11+
issues: [4584]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext: |
17+
Apply config before setting up logger to configure it properly.

main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ func main() {
9898
panic(err)
9999
}
100100

101+
err := cfg.Apply(configFile)
102+
if err != nil {
103+
fmt.Printf("configuration error: %v\n", err)
104+
os.Exit(1)
105+
}
106+
101107
opts.EncoderConfigOptions = append(opts.EncoderConfigOptions, func(ec *zapcore.EncoderConfig) {
102108
ec.MessageKey = cfg.Zap.MessageKey
103109
ec.LevelKey = cfg.Zap.LevelKey
@@ -114,12 +120,6 @@ func main() {
114120

115121
configLog := ctrl.Log.WithName("config")
116122

117-
err := cfg.Apply(configFile)
118-
if err != nil {
119-
configLog.Error(err, "configuration error")
120-
os.Exit(1)
121-
}
122-
123123
v := version.Get()
124124

125125
logger.Info("Starting the OpenTelemetry Operator",

0 commit comments

Comments
 (0)