[receiver/azurefunctions] fix config round-trip by using pointer types for optional IDs - #47606
Closed
alliasgher wants to merge 2 commits into
Closed
[receiver/azurefunctions] fix config round-trip by using pointer types for optional IDs#47606alliasgher wants to merge 2 commits into
alliasgher wants to merge 2 commits into
Conversation
The check to enable the kafka.cluster.alias resource attribute was in createDefaultConfig(), which runs before user config is applied. At that point ClusterAlias is always the zero value, so the attribute was never enabled even when cluster_alias was set by the user. Move the check to createMetricsReceiver(), where the user-supplied config is available. Fixes open-telemetry#47573 Signed-off-by: alliasgher <alliasgher123@gmail.com>
…s for optional IDs
component.ID marshals as an empty string when zero-valued. Unmarshaling
that empty string calls component.ID.UnmarshalText(""), which returns an
error because component type must not be empty. This makes the default
config fail a YAML marshal/unmarshal round-trip.
Change Auth and Logs.Encoding to pointer types (*component.ID). A nil
pointer is omitted from the marshaled output and is represented as absent
in YAML, so the default config (both pointers nil) round-trips cleanly.
The Validate check is updated to compare against nil instead of the zero
struct value.
Fixes open-telemetry#47039
Signed-off-by: alliasgher <alliasgher123@gmail.com>
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! |
paulojmdias
reviewed
Apr 13, 2026
|
|
||
| func createDefaultConfig() component.Config { | ||
| config := &Config{ | ||
| return &Config{ |
Member
There was a problem hiding this comment.
I think this changes does not belong to this PR
paulojmdias
reviewed
Apr 13, 2026
| @@ -0,0 +1,27 @@ | |||
| # Use this changelog template to create an entry for release notes. | |||
Member
There was a problem hiding this comment.
This changelog does not belong to this PR
Contributor
Author
|
Reopening with a clean branch that only contains the azurefunctions fix — the previous branch accidentally included unrelated kafkametrics changes from the parent branch. Sorry about the noise! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #47039.
component.IDmarshals to an empty string""when it holds the zero value. Unmarshaling that empty string callscomponent.ID.UnmarshalText(""), which returns"id must not be empty". This causes the default config to fail a YAML marshal → unmarshal round-trip (as surfaced byCheckConfigStructand the round-trip validation work in open-telemetry/opentelemetry-collector#14599).The two affected fields (
AuthandLogs.Encoding) are optional — neither is required in the default config:authlogs.encodingFix
Change both fields from
component.ID(value type) to*component.ID(pointer type). Anilpointer is omitted from marshaled YAML and deserialized back tonil, so the default config round-trips cleanly. TheValidate()method now compares againstnilinstead of the zero struct value.Before
After
Link to tracking Issue
Fixes #47039
Testing
All existing tests pass (
go test ./receiver/azurefunctionsreceiver/...). The test fixtures forAuthandLogs.Encodingare updated to use*component.IDpointers.