-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[otelcol] Add a custom zapcore.Core for confmap logging #10056
[otelcol] Add a custom zapcore.Core for confmap logging #10056
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10056 +/- ##
========================================
Coverage 91.67% 91.67%
========================================
Files 362 367 +5
Lines 16754 16878 +124
========================================
+ Hits 15359 15473 +114
- Misses 1056 1063 +7
- Partials 339 342 +3 ☔ View full report in Codecov by Sentry. |
Generally looks good to me |
#### Description This is an RFC to help us decide how we want `otelcol` to provide a logger before the primary logger is created. As we discuss I will update the doc. Before this is merged we should have decided on a solution and the Accepted Solution section must be updated. Related to #10056 #### Link to tracking issue This unblocks: - #9162 - #5615 --------- Co-authored-by: Pablo Baeyens <pbaeyens31+github@gmail.com> Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
@mx-psi I believe I've address all feedback |
@TylerHelmuth can you address the lint error?
I can merge after that |
The Windows test failure seems to be legit:
It's failing here
with this test opentelemetry-collector/otelcol/collector_windows_service_test.go Lines 54 to 58 in 7b63bfc
The Windows service uses a special zap core
I am wondering if the fallback logger is somehow messing with this |
Agreed that the failure is legit, looking into it. I'll be using CI as the runner lol |
@pjanotti I need some help here, why can the windows service not handle instantiating a fallback logger before returning the error on start? If I use |
…er specified logger config
Co-authored-by: Pablo Baeyens <pbaeyens31+github@gmail.com>
8164737
to
83f90b1
Compare
d190f0f
to
c3b7488
Compare
@@ -202,7 +202,7 @@ func (w windowsEventLogCore) Sync() error { | |||
|
|||
func withWindowsCore(elog *eventlog.Log, serviceConfig **service.Config) func(zapcore.Core) zapcore.Core { | |||
return func(core zapcore.Core) zapcore.Core { | |||
if serviceConfig != nil { | |||
if serviceConfig != nil && *serviceConfig != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mx-psi fixed the windows test. The issue was that when the config could not resolve then the underlying serviceConfig was nil, but this check was only checking the pointer to the pointer not being nil. When we passed the options to the fallback logger we ended up in this method and tried to do (*serviceConfig).Telemetry.Logs.OutputPaths
on nil
. Added an extra nil check to make sure the underlying serviceConfig
is also not nil.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for getting to the bottom of this Windows test, can we make you the official Windows reviewer? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for digging into this, we'll officially name you the Windows guy in a separate PR 😄 🪟
#### Description This is an RFC to help us decide how we want `otelcol` to provide a logger before the primary logger is created. As we discuss I will update the doc. Before this is merged we should have decided on a solution and the Accepted Solution section must be updated. Related to open-telemetry#10056 #### Link to tracking issue This unblocks: - open-telemetry#9162 - open-telemetry#5615 --------- Co-authored-by: Pablo Baeyens <pbaeyens31+github@gmail.com> Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
…ry#10056) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Provides a logger to confmap that buffers logs in memory until the primary logger can be used. Once the primary logger exists, places that used the original logger are given the updated Core. If an error occurs that would shut down the collector before the primary logger could be created, the logs are written to stdout/err using a fallback logger. Alternative to open-telemetry#10008 I've pushed the testing I did to show how the logger successfully updates. Before config resolution the debug log in confmap is not printed, but afterwards it is. test config: ```yaml receivers: nop: exporters: otlphttp: endpoint: http://0.0.0.0:4317 headers: # Not set x-test: ${env:TEMP3} debug: # set to "detailed" verbosity: $TEMP service: telemetry: logs: level: debug pipelines: traces: receivers: - nop exporters: - debug ``` ![image](https://github.com/open-telemetry/opentelemetry-collector/assets/12352919/6a17993f-1f97-4c54-9165-5c34dd58d108) <!-- Issue number if applicable --> #### Link to tracking issue Related to open-telemetry#9162 Related to open-telemetry#5615 <!--Describe what testing was performed and which tests were added.--> #### Testing If we like this approach I'll add tests <!--Describe the documentation added.--> #### Documentation --------- Co-authored-by: Dan Jaglowski <jaglows3@gmail.com> Co-authored-by: Pablo Baeyens <pbaeyens31+github@gmail.com>
Description
Provides a logger to confmap that buffers logs in memory until the primary logger can be used. Once the primary logger exists, places that used the original logger are given the updated Core.
If an error occurs that would shut down the collector before the primary logger could be created, the logs are written to stdout/err using a fallback logger.
Alternative to #10008
I've pushed the testing I did to show how the logger successfully updates. Before config resolution the debug log in confmap is not printed, but afterwards it is.
test config:
Link to tracking issue
Related to #9162
Related to #5615
Testing
If we like this approach I'll add tests
Documentation