Repository: quarkusio/quarkus
Issue: Use of the `quarkus-opentelemetry` extension yields config warnings

### Describe the bug

When running the `opentelemetr-quickstart` using Quarkus from 2d2e1cf4d3c15c250fdd960f868371757b5f77fe, one seems the following warnings:

```posh
2023-03-29 11:14:50,109 WARN  [io.qua.config] (Quarkus Main Thread) Unrecognized configuration key "quarkus.opentelemetry.tracer.enabled" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2023-03-29 11:14:50,109 WARN  [io.qua.config] (Quarkus Main Thread) Unrecognized configuration key "quarkus.opentelemetry.tracer.sampler" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2023-03-29 11:14:50,109 WARN  [io.qua.config] (Quarkus Main Thread) Unrecognized configuration key "quarkus.opentelemetry.enabled" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
```

which no user action can remove.

### Expected behavior

No config warnings

### Actual behavior

_No response_

### How to Reproduce?

Just run the `opentelemetry-quickstart` from the `development` branch.

### Output of `uname -a` or `ver`

_No response_

### Output of `java -version`

_No response_

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

https://github.com/quarkusio/quarkus/commit/2d2e1cf4d3c15c250fdd960f868371757b5f77fe

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

_No response_

### Additional information

_No response_

Changed files:
extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/OtelConfigRelocateConfigSourceInterceptor.java
extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryLegacyConfigurationTest.java
extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/OTelFallbackConfigSourceInterceptor.java

diff --git a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryLegacyConfigurationTest.java b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryLegacyConfigurationTest.java
index 79cd04d59c3..6ae06be3500 100644
--- a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryLegacyConfigurationTest.java
+++ b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryLegacyConfigurationTest.java
@@ -5,7 +5,7 @@
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import java.util.Arrays;
+import java.util.List;
 
 import jakarta.inject.Inject;
 
@@ -24,6 +24,7 @@ class OpenTelemetryLegacyConfigurationTest {
             .overrideConfigKey("quarkus.opentelemetry.enabled", "false")
             .overrideConfigKey("quarkus.opentelemetry.tracer.enabled", "false")
             .overrideConfigKey("quarkus.opentelemetry.propagators", "tracecontext")
+            .overrideConfigKey("quarkus.opentelemetry.tracer.resource-attributes", "service.name=authservice")
             .overrideConfigKey("quarkus.opentelemetry.tracer.suppress-non-application-uris", "false")
             .overrideConfigKey("quarkus.opentelemetry.tracer.include-static-resources", "true")
             .overrideConfigKey("quarkus.opentelemetry.tracer.sampler", "off")
@@ -46,7 +47,9 @@ void config() {
         assertEquals(FALSE, oTelBuildConfig.enabled());
         assertTrue(oTelBuildConfig.traces().enabled().isPresent());
         assertEquals(FALSE, oTelBuildConfig.traces().enabled().get());
-        assertEquals(Arrays.asList("tracecontext"), oTelBuildConfig.propagators()); // will not include the default baggagge
+        assertEquals(List.of("tracecontext"), oTelBuildConfig.propagators()); // will not include the default baggagge
+        assertTrue(oTelRuntimeConfig.resourceAttributes().isPresent());
+        assertEquals("service.name=authservice", oTelRuntimeConfig.resourceAttributes().get().get(0));
         assertEquals(FALSE, oTelRuntimeConfig.traces().suppressNonApplicationUris());
         assertEquals(TRUE, oTelRuntimeConfig.traces().includeStaticResources());
         assertEquals("always_off", oTelBuildConfig.traces().sampler());
diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/OTelFallbackConfigSourceInterceptor.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/OTelFallbackConfigSourceInterceptor.java
index ce1ea166938..9d97991d4ca 100644
--- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/OTelFallbackConfigSourceInterceptor.java
+++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/OTelFallbackConfigSourceInterceptor.java
@@ -1,5 +1,6 @@
 package io.quarkus.opentelemetry.runtime.config;
 
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
@@ -15,21 +16,27 @@
 
 @Priority(Priorities.LIBRARY + 300 + 5)
 public class OTelFallbackConfigSourceInterceptor extends FallbackConfigSourceInterceptor {
+    private final static Map<String, String> FALLBACKS = new HashMap<>();
     private final static LegacySamplerNameConverter LEGACY_SAMPLER_NAME_CONVERTER = new LegacySamplerNameConverter();
 
+    static {
+        FALLBACKS.put("quarkus.otel.enabled", "quarkus.opentelemetry.enabled");
+        FALLBACKS.put("quarkus.otel.traces.enabled", "quarkus.opentelemetry.tracer.enabled");
+        FALLBACKS.put("quarkus.otel.propagators", "quarkus.opentelemetry.propagators");
+        FALLBACKS.put("quarkus.otel.resource.attributes", "quarkus.opentelemetry.tracer.resource-attributes");
+        FALLBACKS.put("quarkus.otel.traces.suppress-non-application-uris",
+                "quarkus.opentelemetry.tracer.suppress-non-application-uris");
+        FALLBACKS.put("quarkus.otel.traces.include-static-resources", "quarkus.opentelemetry.tracer.include-static-resources");
+        FALLBACKS.put("quarkus.otel.traces.sampler", "quarkus.opentelemetry.tracer.sampler");
+        FALLBACKS.put("quarkus.otel.traces.sampler.arg", "quarkus.opentelemetry.tracer.sampler.ratio");
+        FALLBACKS.put("quarkus.otel.exporter.otlp.enabled", "quarkus.opentelemetry.tracer.exporter.otlp.enabled");
+        FALLBACKS.put("quarkus.otel.exporter.otlp.traces.legacy-endpoint",
+                "quarkus.opentelemetry.tracer.exporter.otlp.endpoint");
+        FALLBACKS.put("quarkus.otel.exporter.otlp.traces.headers", "quarkus.opentelemetry.tracer.exporter.otlp.headers");
+    }
+
     public OTelFallbackConfigSourceInterceptor() {
-        super(Map.of(
-                "quarkus.otel.enabled", "quarkus.opentelemetry.enabled",
-                "quarkus.otel.traces.enabled", "quarkus.opentelemetry.tracer.enabled",
-                "quarkus.otel.propagators", "quarkus.opentelemetry.propagators",
-                "quarkus.otel.traces.suppress-non-application-uris",
-                "quarkus.opentelemetry.tracer.suppress-non-application-uris",
-                "quarkus.otel.traces.include-static-resources", "quarkus.opentelemetry.tracer.include-static-resources",
-                "quarkus.otel.traces.sampler", "quarkus.opentelemetry.tracer.sampler",
-                "quarkus.otel.traces.sampler.arg", "quarkus.opentelemetry.tracer.sampler.ratio",
-                "quarkus.otel.exporter.otlp.enabled", "quarkus.opentelemetry.tracer.exporter.otlp.enabled",
-                "quarkus.otel.exporter.otlp.traces.headers", "quarkus.opentelemetry.tracer.exporter.otlp.headers",
-                "quarkus.otel.exporter.otlp.traces.legacy-endpoint", "quarkus.opentelemetry.tracer.exporter.otlp.endpoint"));
+        super(FALLBACKS);
     }
 
     @Override
@@ -44,10 +51,28 @@ public ConfigValue getValue(final ConfigSourceInterceptorContext context, final
     @Override
     public Iterator<String> iterateNames(final ConfigSourceInterceptorContext context) {
         Set<String> names = new HashSet<>();
-        Iterator<String> namesIterator = super.iterateNames(context);
+        Iterator<String> namesIterator = context.iterateNames();
         while (namesIterator.hasNext()) {
-            names.add(namesIterator.next());
+            String name = namesIterator.next();
+            String fallback = FALLBACKS.get(name);
+            // We only include the used property, so if it is a fallback (not mapped), it will be reported as unknown
+            if (fallback != null) {
+                ConfigValue nameValue = context.proceed(name);
+                ConfigValue fallbackValue = context.proceed(fallback);
+                if (nameValue == null) {
+                    names.add(fallback);
+                } else if (fallbackValue == null) {
+                    names.add(name);
+                } else if (nameValue.getConfigSourceOrdinal() >= fallbackValue.getConfigSourceOrdinal()) {
+                    names.add(name);
+                } else {
+                    names.add(fallback);
+                }
+            } else {
+                names.add(name);
+            }
         }
+
         // TODO - Required because the defaults ConfigSource for mappings does not provide configuration names.
         names.add("quarkus.otel.enabled");
         names.add("quarkus.otel.metrics.exporter");
diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/OtelConfigRelocateConfigSourceInterceptor.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/OtelConfigRelocateConfigSourceInterceptor.java
deleted file mode 100644
index e69de29bb2d..00000000000