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

Respect telemetry configuration when running as a Windows service #9726

Merged

Conversation

pjanotti
Copy link
Contributor

@pjanotti pjanotti commented Mar 8, 2024

Description:
Fixes #5300

With this change the service telemetry section is respected by the collector when running as a Windows service. Log lever can be used to control the verbosity of the events logged and the logger can be redirected to a file by specifying an output path on the service telemetry config. By default stdout and stderr are redirected to the event log when running as a Windows service to keep the current behavior.

The code change itself was made with a focus of not breaking the public APIs and not reading the config more than once. That said it is probably something to be refactored when the public APIs can be touched again.

Link to tracking Issue:
#5300

Testing:
The test is an integration test that depends on the actual executable. It checks for event publication and file output.

@pjanotti pjanotti requested review from a team and dmitryax March 8, 2024 01:43
Copy link

codecov bot commented Mar 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.99%. Comparing base (eb5d2b9) to head (14924e0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9726   +/-   ##
=======================================
  Coverage   90.99%   90.99%           
=======================================
  Files         353      353           
  Lines       18635    18636    +1     
=======================================
+ Hits        16957    16958    +1     
  Misses       1352     1352           
  Partials      326      326           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pjanotti
Copy link
Contributor Author

pjanotti commented Mar 8, 2024

Contrib test failure is related to sumologic, see https://github.com/open-telemetry/opentelemetry-collector/actions/runs/8197473377/job/22419508605?pr=9726#step:4:1263

=== FAIL: .  (0.00s)
panic: test timed out after 5m0s
running tests:
	TestRegisterEmptyCollectorNameForceRegistration (5m0s)

goroutine 526 [running]:
testing.(*M).startAlarm.func1()
	/opt/hostedtoolcache/go/1.21.7/x64/src/testing/testing.go:2259 +0x259
created by time.goFunc
	/opt/hostedtoolcache/go/1.21.7/x64/src/time/sleep.go:176 +0x45

goroutine 1 [chan receive, 4 minutes]:
testing.tRunner.func1()
	/opt/hostedtoolcache/go/1.21.7/x64/src/testing/testing.go:1561 +0x9ac
testing.tRunner(0xc000270000, 0xc000219a60)
	/opt/hostedtoolcache/go/1.21.7/x64/src/testing/testing.go:1601 +0x295
testing.runTests(0xc0002492c0?, {0x18cdc20, 0x14, 0x14}, {0x7f15dfe76a68?, 0xd0?, 0x18dac80?})
	/opt/hostedtoolcache/go/1.21.7/x64/src/testing/testing.go:2052 +0x8ae
testing.(*M).Run(0xc0002492c0)
	/opt/hostedtoolcache/go/1.21.7/x64/src/testing/testing.go:1925 +0xcd8
github.com/open-telemetry/opentelemetry-collector-contrib/extension/sumologicextension.TestMain(0xd7c03559dc3d7f54?)
	/tmp/opentelemetry-collector-contrib/extension/sumologicextension/extension_test.go:39 +0x55
main.main()
	_testmain.go:87 +0x308

more at the link above.

@pjanotti
Copy link
Contributor Author

Unrelated failure: https://github.com/open-telemetry/opentelemetry-collector/actions/runs/8235184573/job/22518707884?pr=9726#step:4:975:~:text=%23%20github.com/open,977

# github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor [github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor.test]
Error: ./processor.go:60:11: proc.exp undefined (type Processor has no field or method exp)
Error: ./processor.go:61:23: proc.exp undefined (type Processor has no field or method exp)
WARN invalid TestEvent: FAIL	github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor [build failed]

Copy link
Member

@dmitryax dmitryax left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @pjanotti

@dmitryax dmitryax merged commit 8990be3 into open-telemetry:main Mar 15, 2024
32 of 46 checks passed
@github-actions github-actions bot added this to the next release milestone Mar 15, 2024
@pjanotti pjanotti deleted the win32svc-uses-col-service-telemetry branch March 15, 2024 17:06
codeboten pushed a commit that referenced this pull request Aug 1, 2024
I'm volunteering myself to own the tier 2 support for windows/amd64.
This will put the windows/amd64 on par with the other tier 2 platforms
by having a specific person owning it.

Some of Windows related things that I contribute(d):

* Codeowner of various Windows related components in contrib
(pkg/winperfcounters, activedirectorydsreceiver, iisreceiver,
windowseventlogreceiver, and windowsperfcountersreceiver)
* Fixing Windows related issues (e.g.: #9042, #9689, #9726,
open-telemetry/opentelemetry-collector-contrib#30743)
* MSI on the collector releases repo
(open-telemetry/opentelemetry-collector-releases#560)
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.

HowTo: Telemetry Logging to File when running as windows service
3 participants