Skip to content

Commit a43e72c

Browse files
authored
Merge branch 'main' into receiver/azuremonitor-configuration-MaximumResourcesPerBatch
2 parents 52e0973 + f51e4d2 commit a43e72c

File tree

3 files changed

+47
-9
lines changed

3 files changed

+47
-9
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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: bug_fix
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: receivercreator
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Properly handle default endpoint for annotation discovery
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: [40712]
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+
Annotation discovery should not add the default endpoint explicitly. Configuration
20+
should be left empty if users do not set anything. Main flow of the receiver_creator
21+
already adds the default endpoint, if not provided, at a later stage by also checking
22+
if target receiver supports it. This patch ensures this logic is unified for both
23+
annotation discovery and templated based discovery.
24+
25+
# If your change doesn't affect end users or the exported elements of any package,
26+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
27+
# Optional: The change log or logs in which this entry should be included.
28+
# e.g. '[user]' or '[user, api]'
29+
# Include 'user' if the change is relevant to end users.
30+
# Include 'api' if there is a change to a library API.
31+
# Default: '[user]'
32+
change_logs: []

receiver/receivercreator/discovery.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,18 +180,23 @@ func getScraperConfFromAnnotations(
180180
defaultEndpoint, scopeSuffix string,
181181
logger *zap.Logger,
182182
) (userConfigMap, error) {
183-
conf := userConfigMap{}
184-
conf[endpointConfigKey] = defaultEndpoint
185-
186183
configStr, found := getHintAnnotation(annotations, otelMetricsHints, configHint, scopeSuffix)
187184
if !found || configStr == "" {
188-
return conf, nil
185+
// defaultEndpoint will be added properly later in observerHandler.startReceiver method
186+
return userConfigMap{}, nil
189187
}
188+
conf := userConfigMap{}
190189
if err := yaml.Unmarshal([]byte(configStr), &conf); err != nil {
191190
return userConfigMap{}, fmt.Errorf("could not unmarshal configuration from hint: %v", zap.Error(err))
192191
}
193192

194-
val := conf[endpointConfigKey]
193+
var val any
194+
var endpointSet bool
195+
if val, endpointSet = conf[endpointConfigKey]; !endpointSet {
196+
// skip endpoint's validation if there is no user provided endpoint
197+
// defaultEndpoint will be added properly later in observerHandler.startReceiver method
198+
return conf, nil
199+
}
195200
confEndpoint, ok := val.(string)
196201
if !ok {
197202
logger.Debug("could not extract configured endpoint")

receiver/receivercreator/discovery_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ func TestK8sHintsBuilderMetrics(t *testing.T) {
2626
collection_interval: "20s"
2727
timeout: "30s"
2828
username: "username"
29-
password: "changeme"`
29+
password: "changeme"
30+
endpoint: 1.2.3.4:6379`
3031
configRedis := `
3132
collection_interval: "20s"
3233
timeout: "130s"
3334
username: "username"
34-
password: "changeme"`
35+
password: "changeme"
36+
endpoint: 1.2.3.4:6379`
3537

3638
tests := map[string]struct {
3739
inputEndpoint observer.Endpoint
@@ -109,7 +111,7 @@ password: "changeme"`
109111
expectedReceiver: receiverTemplate{
110112
receiverConfig: receiverConfig{
111113
id: id,
112-
config: userConfigMap{"endpoint": "1.2.3.4:6379"},
114+
config: userConfigMap{},
113115
}, signals: receiverSignals{metrics: true, logs: false, traces: false},
114116
},
115117
wantError: false,
@@ -624,7 +626,6 @@ nested_example:
624626
"io.opentelemetry.discovery.metrics/config": configNoEndpoint,
625627
}, expectedConf: userConfigMap{
626628
"collection_interval": "20s",
627-
"endpoint": "1.1.1.1:8080",
628629
"initial_delay": "20s",
629630
"read_buffer_size": "10",
630631
"nested_example": userConfigMap{"foo": "bar"},

0 commit comments

Comments
 (0)