Skip to content
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
352c7f0
feat: Replace DeclarativeConfigPropertiesBridge with ConfigProperties…
aviralgarg05 Jan 11, 2026
4455375
fix: Resolve build and formatting issues
aviralgarg05 Jan 11, 2026
ceefeb5
Suppress deprecation warnings for backward compatibility
aviralgarg05 Jan 12, 2026
c720a10
Merge upstream/main into fix/issue-15811
aviralgarg05 Feb 15, 2026
fa9133d
Address PR feedback: preserve special mappings and track 3.0 removal
aviralgarg05 Feb 19, 2026
8270514
Merge remote-tracking branch 'upstream/main' into fix/issue-15811
trask Feb 25, 2026
8213aed
Address remaining PR review feedback
aviralgarg05 Mar 30, 2026
b432212
Merge branch 'main' into fix/issue-15811
aviralgarg05 Mar 30, 2026
d02c1de
Merge remote-tracking branch 'upstream/main' into fix/issue-15811
trask May 4, 2026
74b8b25
Address remaining PR review feedback
aviralgarg05 May 5, 2026
346ed3d
Merge remote-tracking branch 'upstream/main' into fix/issue-15811
aviralgarg05 May 5, 2026
151b681
Merge remote-tracking branch 'origin/fix/issue-15811' into fix/issue-…
aviralgarg05 May 5, 2026
aaa02b3
fix: use Java-compatible empty map in config provider test
aviralgarg05 Jul 9, 2026
c1683da
fix: satisfy spotless for config provider test
aviralgarg05 Jul 9, 2026
7a34a99
configurable access path
zeitlinger Jul 14, 2026
15ce857
Merge remote-tracking branch 'origin/main' into cp-bridge-for-distros
zeitlinger Jul 14, 2026
7e7938f
add DeclarativeConfigPropertiesDurationUtil
zeitlinger Jul 14, 2026
2bc1684
Add contrib-facing declarative bridge helpers
zeitlinger Jul 14, 2026
640ea3c
cleanup
zeitlinger Jul 14, 2026
c825e84
Fix component provider example in bridge README
zeitlinger Jul 14, 2026
55f9e56
Update declarative-config-bridge/src/main/java/io/opentelemetry/instr…
zeitlinger Jul 15, 2026
05d1972
Fix declarative config bridge review findings
trask Jul 20, 2026
19e9f58
Rename declarative duration helper
trask Jul 20, 2026
264b8bd
Simplify declarative config bridge API
trask Jul 20, 2026
e8b277f
Scope deprecated API suppression
trask Jul 20, 2026
1aabda1
Address review comment from copilot-pull-request-reviewer: isolate co…
trask Jul 20, 2026
174e659
Address review comment from copilot-pull-request-reviewer: correct pr…
trask Jul 20, 2026
10fda27
Address review comment from copilot-pull-request-reviewer: narrow hel…
trask Jul 20, 2026
5920f40
Address review comment from copilot-pull-request-reviewer: document b…
trask Jul 20, 2026
8c61aa3
Merge remote-tracking branch 'upstream/main' into cp-bridge-for-contrib
trask Jul 20, 2026
eae11a0
spotless
trask Jul 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

### 🚫 Deprecations

- Deprecate `ConfigPropertiesBackedConfigProvider` in favor of `DeclarativeConfigBridge`. It will be
removed in 2.31.0.
- Deprecate `DeclarativeConfigPropertiesBridgeBuilder`. Read declarative component configuration
through `DeclarativeConfigProperties` directly. To expose `ConfigProperties` through the
declarative configuration API, use `ConfigPropertiesBackedConfigProvider`.
declarative configuration API, use `DeclarativeConfigBridge`.

### 📈 Enhancements

Expand Down
66 changes: 37 additions & 29 deletions declarative-config-bridge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,53 @@
> `DeclarativeConfigPropertiesBridgeBuilder` is deprecated and will be removed in 3.0. Read
> declarative component configuration through `DeclarativeConfigProperties` directly. To expose
> `ConfigProperties` through the declarative configuration API, use
> `ConfigPropertiesBackedConfigProvider`.
> `DeclarativeConfigBridge`.

Declarative Config Bridge allows instrumentation authors to access configuration in a uniform way,
regardless of the configuration source.

The bridge allows you to read configuration using the system property style when dealing with
declarative configuration.
The bridge lets callers expose either the complete flat instrumentation configuration or a
component's flat property namespace through the declarative configuration API.

## Example

As an example, let's look at the inferred spans configuration.
First, there is a configuration method that reads the properties and is unaware of the source of the
configuration:
As an example, let's look at the contrib inferred spans configuration.
It reads declarative keys such as `backup_diagnostic_files`, while preserving flat property support
for `otel.inferred.spans.backup.diagnostic.files`.

```java
class InferredSpansConfig {
static SpanProcessor create(ConfigProperties properties) {
// read properties here
boolean backupDiagnosticFiles =
properties.getBoolean("otel.inferred.spans.backup.diagnostic.files", false);
static SpanProcessor createSpanProcessor(DeclarativeConfigProperties properties) {
boolean backupDiagnosticFiles = properties.getBoolean("backup_diagnostic_files", false);
}
}
```

The auto configuration **without declarative config** passes the provided properties directly:
The auto configuration path can bridge flat config into that declarative view:

```java
`createComponentProperties(...)` returns the same root-relative configuration shape that
`ComponentProvider.create(...)` receives for native declarative configuration.

```java
@AutoService(AutoConfigurationCustomizerProvider.class)
public class InferredSpansAutoConfig implements AutoConfigurationCustomizerProvider {

@Override
public void customize(AutoConfigurationCustomizer config) {
config.addTracerProviderCustomizer(
(providerBuilder, properties) -> {
providerBuilder.addSpanProcessor(InferredSpansConfig.create(properties));
DeclarativeConfigProperties declarativeProperties =
DeclarativeConfigBridge.createComponentProperties(
properties, "otel.inferred.spans.");
providerBuilder.addSpanProcessor(
InferredSpansConfig.createSpanProcessor(declarativeProperties));
return providerBuilder;
});
}
}
```

The auto configuration **with declarative config** uses the Declarative Config Bridge to be able to
use common configuration method:
The declarative component provider can use the same config method directly:

Let's first look at the yaml file that is used to configure the inferred spans processor:

Expand All @@ -56,35 +59,40 @@ file_format: 1.1
tracer_provider:
processors:
- inferred_spans:
Comment thread
trask marked this conversation as resolved.
Outdated
backup:
diagnostic:
files: true
backup_diagnostic_files: true
```

And now the component provider that uses the Declarative Config Bridge:
And now the component provider:

```java

@AutoService(ComponentProvider.class)
public class InferredSpansComponentProvider implements ComponentProvider {
public class InferredSpansSpanProcessorProvider implements ComponentProvider {

@Override
public String getName() {
return "inferred_spans";
}

@Override
public SpanProcessor create(DeclarativeConfigProperties config) {
return InferredSpansConfig.create(
new DeclarativeConfigPropertiesBridgeBuilder()
// crop the prefix, because the properties are under the "inferred_spans" processor
.addMapping("otel.inferred.spans.", "")
.build(config));
public Class<SpanProcessor> getType() {
return SpanProcessor.class;
}

@Override
public Class<SpanProcessor> getType() {
return SpanProcessor.class;
public SpanProcessor create(DeclarativeConfigProperties properties) {
return InferredSpansConfig.createSpanProcessor(properties);
}
Comment thread
zeitlinger marked this conversation as resolved.
}
```

For duration properties, contrib's `span-stacktrace` and `inferred-spans` use
`DeclarativeConfigDurationUtil.getDuration(...)`:

```java
Duration minDuration =
DeclarativeConfigDurationUtil.getDuration(properties, "min_duration");
```

String duration values such as `42ms` are supported when the declarative config is backed by flat
`ConfigProperties`. For other declarative-config implementations, durations must already be
normalized to integer milliseconds.
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,30 @@
/**
* A {@link ConfigProvider} implementation backed by {@link ConfigProperties}.
*
* <p>This allows instrumentations to always use {@code ExtendedOpenTelemetry.getConfigProvider()}
* regardless of whether the user started with system properties or YAML.
* @deprecated Use {@link DeclarativeConfigBridge#createInstrumentationConfig(ConfigProperties)}.
* This class will be removed in 2.31.0.
*/
@Deprecated // will be removed in 2.31.0
public final class ConfigPropertiesBackedConfigProvider implements ConfigProvider {

private final DeclarativeConfigProperties instrumentationConfig;
private final ConfigProvider delegate;

/**
* @deprecated Use {@link DeclarativeConfigBridge#createInstrumentationConfig(ConfigProperties)}.
* This method will be removed in 2.31.0.
*/
@Deprecated // will be removed in 2.31.0
public static ConfigProvider create(ConfigProperties configProperties) {
return new ConfigPropertiesBackedConfigProvider(configProperties);
return new ConfigPropertiesBackedConfigProvider(
DeclarativeConfigBridge.createInstrumentationConfig(configProperties));
}

private ConfigPropertiesBackedConfigProvider(ConfigProperties configProperties) {
this.instrumentationConfig =
ConfigPropertiesBackedDeclarativeConfigProperties.createInstrumentationConfig(
configProperties);
private ConfigPropertiesBackedConfigProvider(ConfigProvider delegate) {
this.delegate = delegate;
}

@Override
public DeclarativeConfigProperties getInstrumentationConfig() {
return instrumentationConfig;
return delegate.getInstrumentationConfig();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
final class ConfigPropertiesBackedDeclarativeConfigProperties
implements DeclarativeConfigProperties {

private static final String JAVA_DECLARATIVE_PREFIX = "java.";
private static final String INSTRUMENTATION_PROPERTY_PREFIX = "otel.instrumentation.";
private static final String JAVA_COMMON_SERVICE_PEER_MAPPING = "java.common.service_peer_mapping";

private static final Map<String, String> SPECIAL_MAPPINGS;
Expand Down Expand Up @@ -94,16 +96,30 @@ final class ConfigPropertiesBackedDeclarativeConfigProperties

private final ConfigProperties configProperties;
private final List<String> path;
private final String declarativePrefix;
private final String configPropertyPrefix;

static DeclarativeConfigProperties createInstrumentationConfig(
ConfigProperties configProperties) {
return new ConfigPropertiesBackedDeclarativeConfigProperties(configProperties, emptyList());
return new ConfigPropertiesBackedDeclarativeConfigProperties(
configProperties, emptyList(), JAVA_DECLARATIVE_PREFIX, INSTRUMENTATION_PROPERTY_PREFIX);
}

static DeclarativeConfigProperties createComponentProperties(
ConfigProperties configProperties, String configPropertyPrefix) {
return new ConfigPropertiesBackedDeclarativeConfigProperties(
configProperties, emptyList(), "", configPropertyPrefix);
Comment thread
trask marked this conversation as resolved.
Outdated
}

private ConfigPropertiesBackedDeclarativeConfigProperties(
ConfigProperties configProperties, List<String> path) {
ConfigProperties configProperties,
List<String> path,
String declarativePrefix,
String configPropertyPrefix) {
this.configProperties = configProperties;
this.path = path;
this.declarativePrefix = declarativePrefix;
this.configPropertyPrefix = configPropertyPrefix;
}

@Nullable
Expand Down Expand Up @@ -146,6 +162,11 @@ public Long getLong(String name) {
return configProperties.getLong(resolvePropertyKey(name));
}

@Nullable
Duration getDuration(String name) {
return configProperties.getDuration(resolvePropertyKey(name));
}

@Nullable
@Override
public Double getDouble(String name) {
Expand All @@ -162,7 +183,8 @@ public Double getDouble(String name) {
public DeclarativeConfigProperties getStructured(String name) {
List<String> newPath = new ArrayList<>(path);
newPath.add(name);
return new ConfigPropertiesBackedDeclarativeConfigProperties(configProperties, newPath);
return new ConfigPropertiesBackedDeclarativeConfigProperties(
configProperties, newPath, declarativePrefix, configPropertyPrefix);
}

@Nullable
Expand Down Expand Up @@ -213,12 +235,11 @@ private String resolvePropertyKey(String name) {
return mappedKey;
}

if (!fullPath.startsWith("java.")) {
if (!declarativePrefix.isEmpty() && !fullPath.startsWith(declarativePrefix)) {
return "";
}

// Remove "java." prefix and translate the remaining path
String[] segments = fullPath.substring(5).split("\\.");
String[] segments = fullPath.substring(declarativePrefix.length()).split("\\.");
StringBuilder translatedPath = new StringBuilder();

for (int i = 0; i < segments.length; i++) {
Expand All @@ -228,7 +249,7 @@ private String resolvePropertyKey(String name) {
translatedPath.append(translateName(segments[i]));
Comment thread
trask marked this conversation as resolved.
}

return "otel.instrumentation." + translatedPath;
return configPropertyPrefix + translatedPath;
}

private String pathWithName(String name) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.config.bridge;

import io.opentelemetry.api.incubator.config.ConfigProvider;
import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;

/** Exposes flat {@link ConfigProperties} through the declarative configuration APIs. */
public final class DeclarativeConfigBridge {
Comment thread
trask marked this conversation as resolved.

/**
* Creates the complete declarative instrumentation configuration backed by flat {@link
* ConfigProperties}.
*/
public static ConfigProvider createInstrumentationConfig(ConfigProperties configProperties) {
return createConfigProvider(
ConfigPropertiesBackedDeclarativeConfigProperties.createInstrumentationConfig(
configProperties));
}

/**
* Creates component-local declarative properties backed by flat {@link ConfigProperties}.
*
* <p>The returned properties have the same root-relative shape as the properties passed to a
* declarative {@code ComponentProvider}. For example, a component can read {@code enabled} while
* the bridge resolves the value from {@code configPropertyPrefix + "enabled"}.
*/
Comment thread
trask marked this conversation as resolved.
public static DeclarativeConfigProperties createComponentProperties(
ConfigProperties configProperties, String configPropertyPrefix) {
return ConfigPropertiesBackedDeclarativeConfigProperties.createComponentProperties(
configProperties, configPropertyPrefix);
}

static ConfigProvider createConfigProvider(DeclarativeConfigProperties instrumentationConfig) {
Comment thread
trask marked this conversation as resolved.
Outdated
return new BridgedConfigProvider(instrumentationConfig);
}

private DeclarativeConfigBridge() {}

private static final class BridgedConfigProvider implements ConfigProvider {
private final DeclarativeConfigProperties instrumentationConfig;

private BridgedConfigProvider(DeclarativeConfigProperties instrumentationConfig) {
this.instrumentationConfig = instrumentationConfig;
}

@Override
public DeclarativeConfigProperties getInstrumentationConfig() {
return instrumentationConfig;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.config.bridge;

import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties;
import java.time.Duration;
import javax.annotation.Nullable;

/**
* Helpers for reading duration values from {@link DeclarativeConfigProperties}.
*
* <p>When the config is backed by flat {@link
* io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties}, duration strings such as {@code 42ms}
* are supported by delegating to the SDK's standard duration parser.
*
* <p>For other declarative-config implementations, this utility expects duration values to already
* be normalized to integer milliseconds, which means string durations in declarative YAML are not
* accepted.
*/
public final class DeclarativeConfigDurationUtil {

/**
* Reads a duration from declarative config.
*
* <p>String duration values are only supported when {@code properties} is a {@link
* ConfigPropertiesBackedDeclarativeConfigProperties}. Other implementations must provide integer
* milliseconds for the same key.
*/
@Nullable
public static Duration getDuration(DeclarativeConfigProperties properties, String key) {
if (properties instanceof ConfigPropertiesBackedDeclarativeConfigProperties) {
return ((ConfigPropertiesBackedDeclarativeConfigProperties) properties).getDuration(key);
}

Long rawLongValue = properties.getLong(key);
if (rawLongValue == null) {
return null;
}
return Duration.ofMillis(rawLongValue);
}

private DeclarativeConfigDurationUtil() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
*
* @deprecated Migrate code that reads declarative component configuration to use {@link
* DeclarativeConfigProperties} directly. To expose {@link ConfigProperties} through the
* declarative configuration API, use {@link ConfigPropertiesBackedConfigProvider}. This class
* will be removed in 3.0.
* declarative configuration API, use {@link DeclarativeConfigBridge}. This class will be
* removed in 3.0.
*/
@Deprecated // will be removed in 3.0
final class DeclarativeConfigPropertiesBridge implements ConfigProperties {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* values for properties.
*
* @deprecated Use {@link DeclarativeConfigProperties} directly when reading declarative component
* configuration, or use {@link ConfigPropertiesBackedConfigProvider} when exposing a {@link
* configuration, or use {@link DeclarativeConfigBridge} when exposing a {@link
* io.opentelemetry.api.incubator.config.ConfigProvider} backed by {@link ConfigProperties}.
* This class will be removed in 3.0.
*/
Expand Down
Loading