Skip to content

Commit d1ed4de

Browse files
dmitryaxFiery-Fenix
authored andcommitted
[receiver_creator] Fix kafkametrics receiver instantiation (open-telemetry#39395)
#### Description Fix dynamic start of kafka metrics receiver #### Link to tracking issue Fixes open-telemetry#39313. The issue is caused by adding the custom unmarshaler to the kafka metrics receiver, specifically [this line](https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/38634/files#diff-ac118f5e10dc8be3556f9c7b192ca2a98161c1289a5a0bc9ddaa812e397acfaaR65). The extra `Unmashall` call seems to be redundant. However, it's an establish practice in other receivers. So I don't want to change that yet. The change in `receiver_creator` also resolves the problem and doesn't have any side effects. #### Testing Follow reproducing steps from the issue
1 parent e7fa2f9 commit d1ed4de

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: receiver_creator
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Fix kafkametrics receiver instantiation
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [39313]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user]

receiver/receivercreator/runner.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,8 @@ func mergeTemplatedAndDiscoveredConfigs(factory rcvr.Factory, templated, discove
158158
endpointConfigKey: targetEndpoint,
159159
})
160160
if err := endpointConfig.Unmarshal(factory.CreateDefaultConfig()); err != nil {
161-
// rather than attach to error content that can change over time,
162-
// confirm the error only arises w/ ErrorUnused mapstructure setting ("invalid keys")
163-
if err = endpointConfig.Unmarshal(factory.CreateDefaultConfig(), confmap.WithIgnoreUnused()); err == nil {
164-
delete(discovered, endpointConfigKey)
165-
}
161+
// we assume that the error is due to unused keys in the config, so we need to remove endpoint key
162+
delete(discovered, endpointConfigKey)
166163
}
167164
}
168165
discoveredConfig := confmap.NewFromStringMap(discovered)

0 commit comments

Comments
 (0)