Skip to content

Commit 8c304a8

Browse files
authored
Fix deprecation warning for multiline config source calls (#5829)
There is a deprecation for bare config source calls. `${source:value[?params]}` should be used instead of `$source:value[?params]`. It's also applied to multiline config source calls. One-line format like `${source:value?param1=val1,param2=val2}` should be used instead of multiline calls with a bare reference to a config source like the following DEPRECATED call: ``` config_field: | $source: value param1: val1 param2: val2 ``` However, the deprecation warning is broken. This change fixes that. So instead of ``` [WARNING] Config source expansion formatted as $uri:selector has been deprecated, use ${uri:selector[?params]} instead. Please replace $include: /Users/danoshin/Projects/otel-configs/memory-limiter.yaml watch_files: true with ${include: /Users/danoshin/Projects/otel-configs/memory-limiter.yaml watch_files: true } in your configuration ``` users will see ``` [WARNING] Calling config sources in multiline format is deprecated. Please convert the following call to the one-line format ${uri:selector?param1=value1,param2=value2}: include: /Users/danoshin/Projects/otel-configs/memory-limiter.yaml watch_files: true ``` One-line deprecation warnings stay as is.
1 parent 6fbae90 commit 8c304a8

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
- (Splunk) Add a new discovery bundle for Envoy proxy metrics ([#5780](https://github.com/signalfx/splunk-otel-collector/pull/5780))
1212

13+
### 🧰 Bug fixes 🧰
14+
15+
- (Splunk) Fix deprecation warning for multiline config source calls ([#5829](https://github.com/signalfx/splunk-otel-collector/pull/5829))
16+
1317
## v0.116.0
1418

1519
This Splunk OpenTelemetry Collector release includes changes from the [opentelemetry-collector v0.116.0](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.116.0) and the [opentelemetry-collector-contrib v0.116.0](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/v0.116.0) releases where appropriate.

internal/configsource/source.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,18 @@ func resolveStringValue(ctx context.Context, configSources map[string]ConfigSour
368368
}
369369
default:
370370
if deprecatedFormUsed {
371-
printDeprecationWarningOnce(fmt.Sprintf(
372-
"[WARNING] Config source expansion formatted as $uri:selector has been deprecated, "+
373-
"use ${uri:selector[?params]} instead. Please replace $%s with ${%s} in your configuration",
374-
expandableContent, expandableContent))
371+
if strings.Contains(expandableContent, "\n") {
372+
printDeprecationWarningOnce(fmt.Sprintf(
373+
"[WARNING] Calling config sources in multiline format is deprecated. "+
374+
"Please convert the following call to the one-line format ${uri:selector?param1"+
375+
"=value1,param2=value2}:\n %s",
376+
expandableContent))
377+
} else {
378+
printDeprecationWarningOnce(fmt.Sprintf(
379+
"[WARNING] Config source expansion formatted as $uri:selector has been deprecated, "+
380+
"use ${uri:selector[?params]} instead. Please replace $%s with ${%s} in your configuration",
381+
expandableContent, expandableContent))
382+
}
375383
}
376384
}
377385
}

0 commit comments

Comments
 (0)