Skip to content

[windowsservicereceiver] Initial implementation#42545

Merged
atoulme merged 37 commits into
open-telemetry:mainfrom
merdzikdominik:merdzikdominik-windowsservicereceiver
Nov 4, 2025
Merged

[windowsservicereceiver] Initial implementation#42545
atoulme merged 37 commits into
open-telemetry:mainfrom
merdzikdominik:merdzikdominik-windowsservicereceiver

Conversation

@merdzikdominik

Copy link
Copy Markdown
Contributor

Fully working windowsservicereceiver.

Performed testing by running:

  • make test
  • make lint

@merdzikdominik merdzikdominik requested review from a team and pjanotti as code owners September 7, 2025 22:18
@linux-foundation-easycla

linux-foundation-easycla Bot commented Sep 7, 2025

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: pjanotti / name: Paulo Janotti (4399e54)

@github-actions github-actions Bot added the first-time contributor PRs made by new contributors label Sep 7, 2025
@github-actions

github-actions Bot commented Sep 7, 2025

Copy link
Copy Markdown
Contributor

Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib.

Important reminders:

A maintainer will review your pull request soon. Thank you for helping make OpenTelemetry better!

Comment thread receiver/windowsservicereceiver/README.md Outdated
Comment thread receiver/windowsservicereceiver/README.md Outdated
@shalper2

shalper2 commented Sep 8, 2025

Copy link
Copy Markdown
Contributor

Het @merdzikdominik thanks for taking a look at this issue and contributing to it! Could you please include tests for the code that you are contributing?

Comment thread receiver/windowsservicereceiver/scraper.go Outdated
Comment thread receiver/windowsservicereceiver/scraper.go

@pjanotti pjanotti left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for working on this @merdzikdominik!

// SPDX-License-Identifier: Apache-2.0

//revive:disable:unused-parameter
//go:build windows

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since there is a file named factory_windows.go this file, factory.go, is expected to have code that is common to all platforms and this file should not need this compile directive.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This directive shouldn't be necessary anymore... I see that it is still needed because there is still a NewFactory implementation in factory_others.go...

Comment thread receiver/windowsservicereceiver/factory.go Outdated
)
}

func createDefaultConfig() component.Config {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This same function is also defined in factory.go so there is no need to have it here, as long as the compile directive //go:build windows is removed from factory.go.

Side note: the suffix of the file names in go, e.g.: factory_windows.go, is in general enough for the compiler, but I personally like to have the compile directives there too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is still an issue.

Comment thread cmd/otelcontribcol/builder-config.yaml Outdated

var errUnsupportedOS = errors.New("windowsservicereceiver: supported only on Windows")

func NewFactory() receiver.Factory {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

At first I think this will be better if you have the same NewFactory at factory.go but then changing line 26 to receiver.WithMetrics(createMetricsReceiver, metadata.MetricsStability) and then implement the platform dependent createMetricsReceiver in factory_windows.go and factory_others.go. See receiver/windowsperfcountersreceiver for an example.

Comment thread receiver/windowsservicereceiver/scraper.go Outdated
continue
}

val := int64(mapStateToMetricValue(State(svc.status.State)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn't possible to cast directly from svc.status.State?

Comment thread receiver/windowsservicereceiver/scraper.go Outdated
Comment thread receiver/windowsservicereceiver/winservice.go Outdated
@atoulme

atoulme commented Sep 17, 2025

Copy link
Copy Markdown
Contributor

Please follow https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md for new components - please create and link an issue here.

@atoulme atoulme added the Sponsor Needed New component seeking sponsor label Sep 17, 2025
@atoulme atoulme marked this pull request as draft September 17, 2025 05:53
replaced "get" prefixes with "update" for method names accordingly to their logic
(1) Errors are collected and returned collectively at the end (errsCh channel + multierr.Append).

(2) Scrape is parallel (errgroup + concurrency-limiting semaphore).

(3) Status is cast directly from svc.status.State with range validation.

(4) Removed an unnecessary, unused bool from mapStartTypeToAttr; start has a clean signature.

(5) Method names indicate the mutation: updateService, updateStatus, updateConfig.
(1) Errors are collected and returned collectively at the end (errsCh channel + multierr.Append).

(2) Scrape is parallel (errgroup + concurrency-limiting semaphore).

(3) Status is cast directly from svc.status.State with range validation.

(4) Removed an unnecessary, unused bool from mapStartTypeToAttr; start has a clean signature.

(5) Method names indicate the mutation: updateService, updateStatus, updateConfig.
@pjanotti pjanotti added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Oct 13, 2025
@github-actions

Copy link
Copy Markdown
Contributor

Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib.

Important reminders:

A maintainer will review your pull request soon. Thank you for helping make OpenTelemetry better!

@pjanotti pjanotti left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we get the file organization and API cleaned up I think we can move ahead. The next steps will be to:

  1. Add an integration test (select a server running on GH runners and check that we get the expected metrics)
  2. Refactor serviceManager (likely remove it) so we can directly use the mgr.Mgr (see comment)

// SPDX-License-Identifier: Apache-2.0

//revive:disable:unused-parameter
//go:build windows

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This directive shouldn't be necessary anymore... I see that it is still needed because there is still a NewFactory implementation in factory_others.go...

Comment thread receiver/windowsservicereceiver/factory_others.go
Comment thread receiver/windowsservicereceiver/scraper.go
Comment thread receiver/windowsservicereceiver/scraper.go Outdated
Comment thread receiver/windowsservicereceiver/winapi.go
Comment thread receiver/windowsservicereceiver/winapi.go Outdated
Comment thread cmd/otelcontribcol/builder-config.yaml Outdated
Comment thread receiver/windowsservicereceiver/factory_others.go Outdated
Comment thread receiver/windowsservicereceiver/winapi.go Outdated
@pjanotti

Copy link
Copy Markdown
Contributor

@merdzikdominik Please, review the comments.

@github-actions

Copy link
Copy Markdown
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions Bot added the Stale label Oct 28, 2025
@github-actions github-actions Bot removed the Stale label Oct 30, 2025
@pjanotti pjanotti removed the Sponsor Needed New component seeking sponsor label Nov 3, 2025
@pjanotti pjanotti marked this pull request as ready for review November 3, 2025 23:02
@pjanotti pjanotti added the Run Windows Enable running windows test on a PR label Nov 3, 2025
@github-actions

github-actions Bot commented Nov 3, 2025

Copy link
Copy Markdown
Contributor

Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib.

Important reminders:

A maintainer will review your pull request soon. Thank you for helping make OpenTelemetry better!

@pjanotti pjanotti changed the title Pull request for windowsservice receiver [windowsservicereceiver] Initial implementation Nov 3, 2025
@atoulme atoulme merged commit ac173bc into open-telemetry:main Nov 4, 2025
225 checks passed
@otelbot

otelbot Bot commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

Thank you for your contribution @merdzikdominik! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey. If you are getting started contributing, you can also join the CNCF Slack channel #opentelemetry-new-contributors to ask for guidance and get help.

@github-actions github-actions Bot added this to the next release milestone Nov 4, 2025
jelly-afk pushed a commit to jelly-afk/opentelemetry-collector-contrib that referenced this pull request Nov 6, 2025
Fully working windowsservicereceiver.

Performed testing by running:
- make test
- make lint

---------

Co-authored-by: Paulo Janotti <pjanotti@splunk.com>
dyl10s pushed a commit to dyl10s/opentelemetry-collector-contrib that referenced this pull request Nov 21, 2025
Fully working windowsservicereceiver.

Performed testing by running:
- make test
- make lint

---------

Co-authored-by: Paulo Janotti <pjanotti@splunk.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmd/otelcontribcol otelcontribcol command first-time contributor PRs made by new contributors receiver/windowsservice Run Windows Enable running windows test on a PR Skip Changelog PRs that do not require a CHANGELOG.md entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants