5353 * <a
5454 * href="https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/data-model.md#yaml-file-format">YAML
5555 * configuration file</a>.
56+ *
57+ * <h2>For Implementers</h2>
58+ *
59+ * <p>External consumers needing to parse OpenTelemetry YAML configuration files should use the same
60+ * Jackson ObjectMapper configuration for compatibility. This configuration is intentionally not
61+ * exposed as API to avoid coupling. Instead, copy the following setup:
62+ *
63+ * <pre>{@code
64+ * ObjectMapper mapper = new ObjectMapper()
65+ * // Create empty object instances for keys which are present but have null values
66+ * .setDefaultSetterInfo(JsonSetter.Value.forValueNulls(Nulls.AS_EMPTY));
67+ * // Boxed primitives which are present but have null values should be set to null,
68+ * // rather than empty instances
69+ * mapper.configOverride(String.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SET));
70+ * mapper.configOverride(Integer.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SET));
71+ * mapper.configOverride(Double.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SET));
72+ * mapper.configOverride(Boolean.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SET));
73+ * }</pre>
74+ *
75+ * <p><b>Why this configuration:</b>
76+ *
77+ * <ul>
78+ * <li>Default behavior creates empty objects for null values to match YAML schema expectations
79+ * <li>Boxed primitives remain null to distinguish between absent and explicitly null values
80+ * </ul>
5681 */
5782public final class DeclarativeConfiguration {
5883
@@ -62,6 +87,19 @@ public final class DeclarativeConfiguration {
6287 private static final ComponentLoader DEFAULT_COMPONENT_LOADER =
6388 ComponentLoader .forClassLoader (DeclarativeConfigProperties .class .getClassLoader ());
6489
90+ /**
91+ * ObjectMapper configured for YAML declarative configuration parsing.
92+ *
93+ * <p>Configuration:
94+ *
95+ * <ul>
96+ * <li>Default: Creates empty objects for present keys with null values
97+ * <li>Boxed primitives (String, Integer, Double, Boolean): Remain null when null
98+ * </ul>
99+ *
100+ * <p>External consumers needing compatible parsing should copy this configuration. See class
101+ * javadoc for details and code example.
102+ */
65103 // Visible for testing
66104 static final ObjectMapper MAPPER ;
67105
0 commit comments