-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[confmap] log a warning when using $VAR in config (WIP) #9547
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9547 +/- ##
==========================================
+ Coverage 90.99% 91.03% +0.03%
==========================================
Files 353 353
Lines 18706 18709 +3
==========================================
+ Hits 17022 17031 +9
+ Misses 1356 1349 -7
- Partials 328 329 +1 ☔ View full report in Codecov by Sentry. |
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 opening the PR! I left some suggestions:
- String sets are typically represented in Go with the type `map[string]struct{}. I left some suggestions to do just that
- We need to warn only for
$var
, not for${var}
- We need some new unit tests for this!
1dc5aa6
to
04524c2
Compare
Thanks, regarding the unit tests, as stated in the PR, I would appreciate a suggestion with regards to how I could check for the warning. Not sure how do do it before the logger is being injected :/ |
For testing you can replace the logger with https://pkg.go.dev/go.uber.org/zap/zaptest/observer |
cd70dde
to
29844f3
Compare
That's what I wanted to do, but then I need to pass down the logger in ConverterSettings instead of hardcoding, so I can change it in the test, and from reading #9443 I got the impression that it is not yet totally clear how to pass it down. I would intuitively just add
Is this what you were expecting I do? |
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
@tomasmota Hey, apologies for the delay on replying, I went on vacation and had a huge backlog afterwards :) Yes, this is what I want to do, we can do it on this PR but IMO it's not necessary for testing right now |
@tomasmota is this ready for another review? |
…en-telemetry#9732) **Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> The descriptions for each header in the feature request template for this repository are useful to the person filing a request, but serve no purpose to the issue reader. These can be commented out to in the displayed markdown to save the user from having to delete each one (or if not deleted, save the reader from having to parse through extra information).
All API in the package was deprecated in 0.93.0
This follows open-telemetry#9556 and uses the Meter func instead of managing the scope in the batch processor manually. Replaces open-telemetry#9581 Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [Wandalen/wretry.action](https://togithub.com/Wandalen/wretry.action) | action | patch | `v1.4.5` -> `v1.4.9` | | [actions/cache](https://togithub.com/actions/cache) | action | patch | `v4.0.0` -> `v4.0.1` | --- ### Release Notes <details> <summary>Wandalen/wretry.action (Wandalen/wretry.action)</summary> ### [`v1.4.9`](https://togithub.com/Wandalen/wretry.action/compare/v1.4.8...v1.4.9) [Compare Source](https://togithub.com/Wandalen/wretry.action/compare/v1.4.8...v1.4.9) ### [`v1.4.8`](https://togithub.com/Wandalen/wretry.action/compare/v1.4.7...v1.4.8) [Compare Source](https://togithub.com/Wandalen/wretry.action/compare/v1.4.7...v1.4.8) ### [`v1.4.7`](https://togithub.com/Wandalen/wretry.action/compare/v1.4.6...v1.4.7) [Compare Source](https://togithub.com/Wandalen/wretry.action/compare/v1.4.6...v1.4.7) ### [`v1.4.6`](https://togithub.com/Wandalen/wretry.action/compare/v1.4.5...v1.4.6) [Compare Source](https://togithub.com/Wandalen/wretry.action/compare/v1.4.5...v1.4.6) </details> <details> <summary>actions/cache (actions/cache)</summary> ### [`v4.0.1`](https://togithub.com/actions/cache/releases/tag/v4.0.1) [Compare Source](https://togithub.com/actions/cache/compare/v4.0.0...v4.0.1) ##### What's Changed - Update README.md by [@&open-telemetry#8203;yacaovsnc](https://togithub.com/yacaovsnc) in [https://github.com/actions/cache/pull/1304](https://togithub.com/actions/cache/pull/1304) - Update examples by [@&open-telemetry#8203;yacaovsnc](https://togithub.com/yacaovsnc) in [https://github.com/actions/cache/pull/1305](https://togithub.com/actions/cache/pull/1305) - Update actions/cache publish flow by [@&open-telemetry#8203;bethanyj28](https://togithub.com/bethanyj28) in [https://github.com/actions/cache/pull/1340](https://togithub.com/actions/cache/pull/1340) - Update [@&open-telemetry#8203;actions/cache](https://togithub.com/actions/cache) by [@&open-telemetry#8203;bethanyj28](https://togithub.com/bethanyj28) in [https://github.com/actions/cache/pull/1341](https://togithub.com/actions/cache/pull/1341) ##### New Contributors - [@&open-telemetry#8203;yacaovsnc](https://togithub.com/yacaovsnc) made their first contribution in [https://github.com/actions/cache/pull/1304](https://togithub.com/actions/cache/pull/1304) **Full Changelog**: actions/cache@v4...v4.0.1 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "on tuesday" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/open-telemetry/opentelemetry-collector). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMzAuMCIsInVwZGF0ZWRJblZlciI6IjM3LjIzMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
**Description:** enable lifecycle test for otlpexporter **Link to tracking Issue:** fix open-telemetry#9684 Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
…ts. (open-telemetry#9635) **Description:** This implements support for calling `Unmarshal` on embedded structs of structs being decoded. **Link to tracking Issue:** Fixes open-telemetry#6671 **Testing:** Unit tests. Contrib fix is open: open-telemetry/opentelemetry-collector-contrib#31406
…metry#9740) **Description:** Persistent queue size backup on reads should depend on readIndex, not writeIndex.
Long story, but i'm working on updating the prometheus dependency: open-telemetry/opentelemetry-collector-contrib#30934 As part of that update, we need to adapt to a change that makes the prometheus servers' self-observability metrics independent. See prometheus/prometheus#13507 and prometheus/prometheus#13610 One way to adapt to this change is by adding a label to each receivers' metrics to differentiate one Prometheus receiver from another. I've tried taking that approach in open-telemetry/opentelemetry-collector-contrib#30934, but the current issue is that the NoOp components all have the same name, which causes the self-observability metrics to collide. I can work around this in the prometheus receiver's own tests, but I can't work around the issue in the `generated_component_test.go` tests, since those are generated. This PR makes the ID returned by `NewNopCreateSettings` unique by giving it a unique name. **Link to tracking Issue:** Part of open-telemetry/opentelemetry-collector-contrib#30883 cc @Aneurysm9 --------- Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github/codeql-action](https://togithub.com/github/codeql-action) | action | patch | `v3.24.6` -> `v3.24.7` | --- ### Release Notes <details> <summary>github/codeql-action (github/codeql-action)</summary> ### [`v3.24.7`](https://togithub.com/github/codeql-action/compare/v3.24.6...v3.24.7) [Compare Source](https://togithub.com/github/codeql-action/compare/v3.24.6...v3.24.7) </details> --- ### Configuration 📅 **Schedule**: Branch creation - "on tuesday" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/open-telemetry/opentelemetry-collector). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMzguMSIsInVwZGF0ZWRJblZlciI6IjM3LjIzOC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
**Description:** Add the nopexporter. This can be helpful if a user wants to start the Collector with a dummy pipeline to only enable extensions. It could also be used to test Collector pipeline throughput. **Link to tracking Issue:** Resolves open-telemetry#7316 **Testing:** Added lifecycle tests; the receiver doesn't do anything. **Documentation:** Added a readme for the component. cc @djaglowski @tigrannajaryan
**Description:** Add the nopreceiver. This can be helpful if a user wants to start the Collector with a dummy pipeline to only enable extensions. It could also be used to start a dynamically-configured Collector that starts with no config and waits to receive its config from a confmap.Provider that supports reloads. **Link to tracking Issue:** Works toward open-telemetry#7316 **Testing:** Added lifecycle tests; the receiver doesn't do anything. **Documentation:** Added a readme for the component.
Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
…fig.yml` (open-telemetry#9746) This PR fixes an incorrect automatic replace made in the `otel-config.yml` file in this [pull request](https://github.com/open-telemetry/opentelemetry-collector/pull/9680/files#diff-c7c8156618a7f8126b25ca1bdfde3e172a0d2cb75c533d63a71617ae2a5c54ae) by a bot. I've taken the previous value which seems right. Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
…ry#9730) **Description:** This test was out of place! Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
39b279d
to
8994209
Compare
Yes, and sorry about the mess of commits, I messed it up and got too lazy to reset properly. guess you will just squash in the end anyways. |
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.
Code looks great! Would you be up for writing some tests? You can write a function for testing like this:
func NewTestConverter() (confmap.Converter, observer.ObservedLogs) {
core, logs := observer.New(zapcore.InfoLevel)
conv := converter{ loggedDeprecations: make(map[string]struct{}), logger: zap.New(core)}
return conv, logs
}
And then call it with some example confmap.Conf
.
If this is too much, I am also happy to take over, please let me know :)
I'll take a stab at it when I get the time :) thanks for the indications! |
I have added some tests, feel free to review |
"test2": "127.0.0.1", | ||
}, | ||
expectedWarnings: []string{"HOST"}, | ||
}, |
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.
To test the QuoteMeta
change I commented above, we should add a test like $HOSTONAME${HOST.NAME}
to check that we are properly escaping characters
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.
I have added QuoteMeta because it makes sense, but in practice I'm not really understanding how it is useful or needed, because our regexp will never match ${HOST.NAME}
, and if you attempt to have $HOST.NAME
you will just end up with 127.0.0.1.NAME
according to my testing. Same if you put other special characters after $HOST
.
With that in mind, I couldn't think of a good test case, because the $VAR
way, which is the only one we match, does not play well with special characters anyways.
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.
You are right, I mistakenly assumed that .
would be a valid part of a naked environment variable name for os.Expand
, but it does not seem like that is the case.
I guess a test that has both ${HOST.NAME}
and $HOST_NAME
should be a valid test, right? Taking a look at the implementation of os.Expand
, it also seems like $?
would be a valid thing to test, but I doubt anybody is using that in practice 😄
@mx-psi i think you can review, I addressed your comments directly. |
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.
Looks good to me, I will skip the changelog on this PR and we can add it once we actually do the logging.
I left a comment on a testcase for regexp.QuoteMeta
that I think should work, let's give it a try and add it if it works
"test2": "127.0.0.1", | ||
}, | ||
expectedWarnings: []string{"HOST"}, | ||
}, |
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.
You are right, I mistakenly assumed that .
would be a valid part of a naked environment variable name for os.Expand
, but it does not seem like that is the case.
I guess a test that has both ${HOST.NAME}
and $HOST_NAME
should be a valid test, right? Taking a look at the implementation of os.Expand
, it also seems like $?
would be a valid thing to test, but I doubt anybody is using that in practice 😄
@mx-psi I added a test with what I understood you were asking for, not sure it was exactly that you meant 😅 |
Yeah, that's what I meant, thanks! |
Great, really appreciate your help and patience! |
Description: As requested by @mx-psi , added a no-op log for when variables using the deprecated $VAR style are used. The logger should be replaced once it is clear how to pass it down (see #9443). Also, from my testing, the function passed to os.Expand is in fact only run when we have$VAR and not for $ {env:VAR}, so I did not add additional checking.
Link to tracking Issue: #9162
Testing: I am not sure how to go about testing it, since we are not passing a logger in yet, there is no easy way to know what is being logged or what the map looks like. Some ideas on this would be appreciated