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

Include undo and apply functional options pattern for setting logger #8

Merged
merged 10 commits into from
Dec 16, 2024

Conversation

rdforte
Copy link
Owner

@rdforte rdforte commented Dec 15, 2024

Description

This change is in accordance with Proposal 2 for open-telemetry/opentelemetry-collector-contrib#36814

This change extends the Set method by:

  • returning the error and an undo function which is responsible for reverting GOMAXPROCS to its previous value.
  • Applies functional options pattern to allow for extending the config
  • Adds the WithLogger method which allows the client to add their own logger that adheres to Printf
  • Checks to see if GOMAXPROCS env variable is already set and then honors it.

Adds a new method IsECS to check if current process running in ECS.

NOTES

For anyone using Set this does break their current usage of Set. So we can either add this change as a new method and bump the minor version or update the existing Set method and bump the major version.

@rdforte rdforte self-assigned this Dec 15, 2024
@codecov-commenter
Copy link

codecov-commenter commented Dec 15, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Files with missing lines Coverage Δ
gomaxecs.go 100.00% <100.00%> (ø)
internal/config/config.go 100.00% <100.00%> (ø)
internal/task/meta.go 100.00% <ø> (ø)
internal/task/task.go 100.00% <100.00%> (ø)
maxprocs/maxprocs.go 100.00% <100.00%> (ø)

@r0mdau
Copy link
Contributor

r0mdau commented Dec 16, 2024

Hi @rdforte , I just used this implementation + an adaptation to my proposition change in the extension/cgroupruntime of opentelemetry-collector-contrib and it works like a charm, running in ECS of course !

Log output:

Dec 16, 2024 @ 18:39:10.773649964 | 2024-12-16T18:39:10.773Z	info	cgroupruntimeextension/extension.go:61	GOMEMLIMIT has been set	{"kind": "extension", "name": "cgroupruntime", "GOMEMLIMIT": 429496729}
Dec 16, 2024 @ 18:39:10.773259452 | 2024-12-16T18:39:10.773Z	info	cgroupruntimeextension/extension.go:50	GOMAXPROCS has been set	{"kind": "extension", "name": "cgroupruntime", "GOMAXPROCS": 1}

@rdforte rdforte changed the title [WIP] include undo and apply functional options pattern for setting logger Iinclude undo and apply functional options pattern for setting logger Dec 16, 2024
@rdforte rdforte changed the title Iinclude undo and apply functional options pattern for setting logger Include undo and apply functional options pattern for setting logger Dec 16, 2024
@rdforte rdforte marked this pull request as ready for review December 16, 2024 21:50
@rdforte rdforte merged commit 0281e1c into main Dec 16, 2024
1 check passed
@rdforte rdforte deleted the extend-set-with-logger-and-undo branch December 16, 2024 21:51
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.

3 participants