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

service: prepend the windowsEventLogCore #5298

Merged
merged 2 commits into from
May 5, 2022

Conversation

braydonk
Copy link
Contributor

@braydonk braydonk commented Apr 29, 2022

Description:
When the windowsEventLogCore is appended to the logging options, it makes the event log core run before any user specified options. This is undesirable because it means the logs are sent to the event log before any of the user's options are applied. This PR changes newWithWindowsEventLogCore to prepending the windowsEventLogCore option to the array of LoggingOptions, so it will always run after the user specified options.

Link to tracking Issue: #5297

Testing:

  • make and make fmt
  • Manually tested by making a collector with one core in collector.LogSettings that changes all Info level logs to Error. With the fix in this PR, the change from Info to Error was successfully observed.

@braydonk braydonk requested review from a team and mx-psi April 29, 2022 21:21
@braydonk braydonk marked this pull request as draft April 29, 2022 21:21
@codecov
Copy link

codecov bot commented May 2, 2022

Codecov Report

Merging #5298 (4268dd2) into main (9be6ecc) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #5298   +/-   ##
=======================================
  Coverage   90.58%   90.58%           
=======================================
  Files         190      190           
  Lines       11109    11109           
=======================================
  Hits        10063    10063           
  Misses        824      824           
  Partials      222      222           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9be6ecc...4268dd2. Read the comment docs.

@braydonk braydonk marked this pull request as ready for review May 4, 2022 17:37
Copy link
Contributor

@dashpole dashpole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a changelog entry

@codeboten codeboten merged commit 9230753 into open-telemetry:main May 5, 2022
mx-psi pushed a commit that referenced this pull request Sep 16, 2024
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
In the CollectorSettings LoggingOptions, when the options are
`zap.WrapCore`, the final core wrapped will end up running first. For
this reason, the windowsEventLogCore must be the first option in the
list of user supplied options, to ensure user supplied options are run
before the core that writes to the Windows Event Log.

Prior art: I fixed this before in #5298.

<!-- Issue number if applicable -->
#### Link to tracking issue
#5297 

<!--Describe what testing was performed and which tests were added.-->
#### Testing
Testing was manual by running the Collector as a service after this
change. I tried to add a unit test but could not find an effective way
to do that due to all the type indirection done by the `zap` package. I
was hoping to find an easy way to tell that the `windowsEventLogCore` is
the first core wrapped in the options but I could not find a way to pull
that off. Open to ideas if anyone can find a way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants