diff --git a/api/incubator/src/testConvertToModel/java/io/opentelemetry/api/incubator/InstrumentationConfigUtilTest.java b/api/incubator/src/testConvertToModel/java/io/opentelemetry/api/incubator/InstrumentationConfigUtilTest.java index 94b6b10f112..2c26063925a 100644 --- a/api/incubator/src/testConvertToModel/java/io/opentelemetry/api/incubator/InstrumentationConfigUtilTest.java +++ b/api/incubator/src/testConvertToModel/java/io/opentelemetry/api/incubator/InstrumentationConfigUtilTest.java @@ -19,6 +19,7 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalInstrumentationModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalLanguageSpecificInstrumentationModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalLanguageSpecificInstrumentationPropertyModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.OpenTelemetryConfigurationModelAccessor; import io.opentelemetry.sdk.internal.SdkConfigProvider; import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; @@ -132,9 +133,9 @@ private static ConfigProvider withInstrumentationConfig( javaConfig.withAdditionalProperty(instrumentationName, instrumentationConfig); DeclarativeConfigProperties modelProperties = DeclarativeConfiguration.toConfigProperties( - new OpenTelemetryConfigurationModel() - .withInstrumentationDevelopment( - new ExperimentalInstrumentationModel().withJava(javaConfig))); + OpenTelemetryConfigurationModelAccessor.withInstrumentation( + new OpenTelemetryConfigurationModel(), + new ExperimentalInstrumentationModel().withJava(javaConfig))); return SdkConfigProvider.create(modelProperties); } diff --git a/buildSrc/src/main/kotlin/io/opentelemetry/gradle/DeclarativeConfigPojoGenerator.kt b/buildSrc/src/main/kotlin/io/opentelemetry/gradle/DeclarativeConfigPojoGenerator.kt index 264697eb7d1..1a5640ab05e 100644 --- a/buildSrc/src/main/kotlin/io/opentelemetry/gradle/DeclarativeConfigPojoGenerator.kt +++ b/buildSrc/src/main/kotlin/io/opentelemetry/gradle/DeclarativeConfigPojoGenerator.kt @@ -21,6 +21,10 @@ import java.io.File * - Properties with object-typed additionalProperties get a synthetic "*PropertyModel" companion * class. When additionalProperties is boolean true (root schema) Map is used * directly. + * - Properties whose JSON key ends with "/development" are experimental. On stable (non- + * Experimental) classes, these properties are not exposed as public getters or builders. + * Instead, their deserialized values are stored in an opaque experimentalProperties map, and + * a generated "*ModelAccessor" class in model.internal provides typed access. * - All $refs are local (#/$defs/...). */ class DeclarativeConfigPojoGenerator( @@ -34,12 +38,11 @@ class DeclarativeConfigPojoGenerator( private lateinit var enumDefNames: Set private lateinit var extensibleDefNames: Set - // Carries resolved type information for a single property. private data class ResolvedType(val expr: String, val imports: Set = emptySet()) - // Carries all derived information about one schema property. private data class FieldInfo( val jsonKey: String, + val constName: String, // SCREAMING_SNAKE_CASE version of jsonKey, used as a Java string constant val javaField: String, val getter: String, val builder: String, @@ -58,7 +61,7 @@ class DeclarativeConfigPojoGenerator( .map { it.key } .toSet() - // Generate root schema as OpenTelemetryConfigurationModel. + // The root schema (title: OpenTelemetryConfiguration) generates OpenTelemetryConfigurationModel. val rootTitle = schema["title"]?.asText() ?: error("Root schema has no title") generateClassFile(rootTitle, schema) @@ -72,6 +75,8 @@ class DeclarativeConfigPojoGenerator( private fun isExperimental(schemaKey: String) = schemaKey.startsWith("Experimental") + private fun isExperimentalProperty(jsonKey: String) = jsonKey.endsWith("/development") + private fun packageForKey(schemaKey: String) = if (isExperimental(schemaKey)) internalPackage else modelPackage @@ -125,8 +130,8 @@ class DeclarativeConfigPojoGenerator( ) } - // Enums are only handled when declared as top-level \$defs (see enumDefNames/generateEnumFile); - // a \$ref to such a def resolves to its generated *Model enum above. An inline enum here would + // Enums are only handled when declared as top-level $defs (see enumDefNames/generateEnumFile); + // a $ref to such a def resolves to its generated *Model enum above. An inline enum here would // otherwise fall through to resolveScalarType and be silently emitted as its base scalar type // (e.g. String), losing type safety. if (propNode.has("enum")) error( @@ -188,7 +193,7 @@ class DeclarativeConfigPojoGenerator( } } - /** Returns true if the type node represents an array (scalar or array-of-types form). */ + // Handles both "type": "array" and "type": ["array", "null"]. private fun isArrayType(typeNode: JsonNode?): Boolean { if (typeNode == null) return false return typeNode.asText() == "array" || (typeNode.isArray && typeNode.any { it.asText() == "array" }) @@ -209,13 +214,33 @@ class DeclarativeConfigPojoGenerator( val isExtensible = defKey in extensibleDefNames val hasOpenAdditionalProperties = defNode["additionalProperties"]?.isBoolean == true && defNode["additionalProperties"].asBoolean() + val isStable = !isExperimental(defKey) writeFile(pkg, className, buildClassSource(pkg, className, defKey, defNode, isExtensible, hasOpenAdditionalProperties)) - if (isExtensible) { + if (isExtensible && !isStable) { val propClassName = "${defKey}PropertyModel" writeFile(pkg, propClassName, buildPropertyModelSource(pkg, propClassName)) } + + if (isStable) { + val experimentalPropPairs = defNode["properties"]?.properties() + ?.filter { isExperimentalProperty(it.key) } + ?.toList() ?: emptyList() + if (experimentalPropPairs.isNotEmpty()) { + generateExperimentalAccessorFile(defKey, pkg, experimentalPropPairs) + } + } + } + + private fun generateExperimentalAccessorFile( + defKey: String, + stablePkg: String, + experimentalPropPairs: List>, + ) { + val accessorClassName = "${classNameForKey(defKey)}Accessor" + writeFile(internalPackage, accessorClassName, + buildExperimentalAccessorSource(defKey, stablePkg, experimentalPropPairs)) } private fun writeFile(pkg: String, className: String, content: String) { @@ -264,12 +289,18 @@ class DeclarativeConfigPojoGenerator( isExtensible: Boolean, hasOpenAdditionalProperties: Boolean, ) = buildString { - val properties = defNode["properties"]?.properties()?.toList() ?: emptyList() + val allProperties = defNode["properties"]?.properties()?.toList() ?: emptyList() + val isStable = !isExperimental(defKey) + val hasAnyAdditional = isExtensible || hasOpenAdditionalProperties + + val stablePropertyPairs = if (isStable) allProperties.filter { !isExperimentalProperty(it.key) } else allProperties + val experimentalPropPairs = if (isStable) allProperties.filter { isExperimentalProperty(it.key) } else emptyList>() - val fields = properties.map { (jsonKey, propNode) -> + val fields = stablePropertyPairs.map { (jsonKey, propNode) -> val resolved = resolvePropertyType(propNode, pkg) FieldInfo( jsonKey = jsonKey, + constName = jsonKey.toScreamingSnakeCase(), javaField = fieldName(jsonKey), getter = getterName(jsonKey), builder = builderName(jsonKey), @@ -279,12 +310,28 @@ class DeclarativeConfigPojoGenerator( ) } - val companionName = if (isExtensible) "${defKey}PropertyModel" else null + // Types from model.internal produce an import; same-package types produce none. + data class ExpPropInfo(val jsonKey: String, val typeExpr: String, val typeImport: String?) + val expProps = if (isStable) experimentalPropPairs.map { (jsonKey, propNode) -> + val resolved = resolvePropertyType(propNode, pkg) + ExpPropInfo(jsonKey, resolved.expr, resolved.imports.firstOrNull()) + } else emptyList() + + // Non-list stable properties are candidates for graduated /development key detection. + val stableObjectProps = if (isStable) fields.filter { !it.typeExpr.startsWith("List<") } else emptyList() + + val companionName = if (isExtensible && !isStable) "${defKey}PropertyModel" else null val additionalPropsType = when { - isExtensible -> "Map" - hasOpenAdditionalProperties -> "Map" + isExtensible && !isStable -> "Map" + hasOpenAdditionalProperties && !isStable -> "Map" else -> null } + val allowsAdditionalProperties = isStable && (isExtensible || hasOpenAdditionalProperties) + // Only generate extension property infrastructure when it serves a purpose: current + // experimental properties to store, stable non-list properties as graduation candidates, + // or an open schema acting as a ComponentProvider extension point. + val needsExtensionProperties = isStable && + (expProps.isNotEmpty() || stableObjectProps.isNotEmpty() || allowsAdditionalProperties) val imports = sortedSetOf( "com.fasterxml.jackson.annotation.JsonInclude", @@ -303,19 +350,49 @@ class DeclarativeConfigPojoGenerator( } if (fields.isNotEmpty()) imports.add("com.fasterxml.jackson.annotation.JsonProperty") for (f in fields) imports.addAll(f.typeImports) + if (isStable) { + for (f in fields) { + imports.add("static $pkg.$className.${f.constName}") + } + } + if (needsExtensionProperties) { + imports.addAll(listOf( + "java.util.HashMap", + "java.util.LinkedHashMap", + "java.util.Map", + "com.fasterxml.jackson.annotation.JsonAnyGetter", + "com.fasterxml.jackson.annotation.JsonAnySetter", + "$internalPackage.ExtensionPropertyUtil", + )) + if (expProps.isNotEmpty()) { + val accessorFqcn = "$internalPackage.${classNameForKey(defKey)}Accessor" + imports.add(accessorFqcn) + imports.add("static $accessorFqcn.EXPERIMENTAL_PROPERTIES") + } + if (expProps.isEmpty() || stableObjectProps.isEmpty()) { + imports.add("java.util.Collections") + } + } appendLicense() append("\npackage $pkg;\n\n") for (imp in imports) append("import $imp;\n") append("\n@JsonInclude(JsonInclude.Include.NON_NULL)\n") - val propKeys = properties.map { "\"${it.key}\"" } - if (propKeys.isEmpty()) { + // @JsonPropertyOrder covers stable properties only — experimental entries are served via + // @JsonAnyGetter and always append last regardless. Static self-imports make the class's + // own package-private constants visible at the class-level annotation site. + val propKeyRefs = if (isStable) { + stablePropertyPairs.map { (jsonKey, _) -> jsonKey.toScreamingSnakeCase() } + } else { + allProperties.map { "\"${it.key}\"" } + } + if (propKeyRefs.isEmpty()) { append("@JsonPropertyOrder({})\n") } else { append("@JsonPropertyOrder({\n") - propKeys.forEachIndexed { i, k -> - append(" $k${if (i < propKeys.size - 1) "," else ""}\n") + propKeyRefs.forEachIndexed { i, k -> + append(" $k${if (i < propKeyRefs.size - 1) "," else ""}\n") } append("})\n") } @@ -323,31 +400,67 @@ class DeclarativeConfigPojoGenerator( append("@Generated(\"io.opentelemetry.gradle.DeclarativeConfigPojoGenerator\")\n") append("public class $className {\n\n") - // Fields + if (isStable) { + for (f in fields) { + append(" static final String ${f.constName} = \"${f.jsonKey}\";\n") + } + if (fields.isNotEmpty()) append("\n") + } + if (needsExtensionProperties) { + // STABLE_PROPERTIES maps non-list stable property names to their types for graduated + // /development key detection. Omitted when empty. + if (stableObjectProps.isNotEmpty()) { + append(" private static final Map> STABLE_PROPERTIES;\n") + append(" static {\n STABLE_PROPERTIES = new HashMap<>();\n") + for (f in stableObjectProps) { + append(" STABLE_PROPERTIES.put(${f.constName}, ${f.typeExpr}.class);\n") + } + append(" }\n") + } + append(" private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = $allowsAdditionalProperties;\n") + append("\n") + } for (f in fields) append(" @Nullable private ${f.typeExpr} ${f.javaField};\n") + // Non-stable extensible types keep their own typed additionalProperties map (unchanged). if (additionalPropsType != null) { - val init = if (isExtensible) "new LinkedHashMap()" + val init = if (companionName != null) "new LinkedHashMap()" else "new LinkedHashMap()" append(" private $additionalPropsType additionalProperties = $init;\n") } - if (fields.isNotEmpty() || additionalPropsType != null) append("\n") + if (needsExtensionProperties) { + append(" private Map extensionProperties = new LinkedHashMap();\n") + } + if (fields.isNotEmpty() || additionalPropsType != null || needsExtensionProperties) append("\n") - // Getters and builders (all fields are nullable) for (f in fields) { if (f.description != null) { append(" /**\n") for (line in formatJavadoc(f.description)) append(" * $line\n") append(" */\n") } - append(" @JsonProperty(\"${f.jsonKey}\")\n") + val jsonPropRef = if (isStable) f.constName else "\"${f.jsonKey}\"" + append(" @JsonProperty($jsonPropRef)\n") append(" @Nullable\n") - append(" public ${f.typeExpr} ${f.getter}() {\n return ${f.javaField};\n }\n\n") - append(" @JsonProperty(\"${f.jsonKey}\")\n") + // Non-list stable getters on classes with extension properties fall back to reading a + // graduated /development value from extensionProperties. The stable field name is passed + // through; ExtensionPropertyUtil.getGraduated internally appends the /development suffix + // to match handleAnySetter's storage key. + if (needsExtensionProperties && !f.typeExpr.startsWith("List<")) { + append(" public ${f.typeExpr} ${f.getter}() {\n") + append(" if (${f.javaField} == null) {\n") + append(" return ExtensionPropertyUtil.getGraduated(${f.constName}, extensionProperties, ${f.typeExpr}.class);\n") + append(" }\n") + append(" return ${f.javaField};\n") + append(" }\n\n") + } else { + append(" public ${f.typeExpr} ${f.getter}() {\n return ${f.javaField};\n }\n\n") + } + append(" @JsonProperty($jsonPropRef)\n") append(" public $className ${f.builder}(${f.typeExpr} ${f.javaField}) {\n") append(" this.${f.javaField} = ${f.javaField};\n return this;\n }\n\n") } - // additionalProperties getter/builder + // Non-stable extensible types: unchanged additionalProperties getter/setter. if (additionalPropsType != null) { val apValueType = companionName ?: "Object" append(" @JsonAnyGetter\n") @@ -357,8 +470,28 @@ class DeclarativeConfigPojoGenerator( append(" this.additionalProperties.put(name, value);\n return this;\n }\n\n") } + if (needsExtensionProperties) { + append(" @JsonAnyGetter\n") + append(" public Map getExtensionProperties() {\n") + if (stableObjectProps.isNotEmpty()) { + append(" return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES);\n") + } else { + append(" return extensionProperties;\n") + } + append(" }\n\n") + append(" @JsonAnySetter\n") + append(" public $className withExtensionProperty(String name, @Nullable Object value) {\n") + append(" ExtensionPropertyUtil.handleAnySetter(\n") + val experimentalPropsArg = if (expProps.isNotEmpty()) "EXPERIMENTAL_PROPERTIES" else "Collections.emptyMap()" + val stablePropsArg = if (stableObjectProps.isNotEmpty()) "STABLE_PROPERTIES" else "Collections.emptyMap()" + append(" name, value, extensionProperties, $experimentalPropsArg, $stablePropsArg,\n") + append(" ALLOWS_ADDITIONAL_PROPERTIES);\n") + append(" return this;\n }\n\n") + } + val allFields = fields.map { it.javaField } + - (if (additionalPropsType != null) listOf("additionalProperties") else emptyList()) + (if (additionalPropsType != null) listOf("additionalProperties") else emptyList()) + + (if (needsExtensionProperties) listOf("extensionProperties") else emptyList()) appendToString(className, allFields) append("\n") @@ -368,6 +501,93 @@ class DeclarativeConfigPojoGenerator( append("}\n") } + private fun buildExperimentalAccessorSource( + defKey: String, + stablePkg: String, + experimentalPropPairs: List>, + ) = buildString { + val stableClassName = classNameForKey(defKey) + val accessorClassName = "${stableClassName}Accessor" + val stableImport = "$stablePkg.$stableClassName" + + data class PropInfo( + val jsonKey: String, + val constName: String, // SCREAMING_SNAKE_CASE key constant, /development suffix stripped + val getter: String, + val builder: String, + val typeExpr: String, + ) + val props = experimentalPropPairs.map { (jsonKey, propNode) -> + val baseKey = jsonKey.removeSuffix("/development") + val typeExpr = resolvePropertyType(propNode, internalPackage).expr + // The accessor emits ${typeExpr}.class in EXPERIMENTAL_PROPERTIES. Parameterized types like + // List would produce non-compiling Java. Fail fast so a schema change adding a + // list-typed /development property is caught at generation time rather than emitting + // broken source. + if (typeExpr.startsWith("List<")) { + error( + "Experimental property '$jsonKey' on '$defKey' has list type '$typeExpr'; the " + + "generator does not support list-typed experimental properties (see " + + "EXPERIMENTAL_PROPERTIES emission in buildExperimentalAccessorSource)." + ) + } + PropInfo( + jsonKey = jsonKey, + constName = baseKey.toScreamingSnakeCase(), + getter = getterName(baseKey), + builder = builderName(baseKey), + typeExpr = typeExpr, + ) + } + + appendLicense() + append("\npackage $internalPackage;\n\n") + append("import $stableImport;\n") + append("import java.util.HashMap;\n") + append("import java.util.Map;\n") + append("import static java.util.Objects.requireNonNull;\n") + append("import javax.annotation.Nullable;\n") + append("\n") + append("/**\n") + append(" * Provides typed access to experimental properties on {@link $stableClassName}.\n") + append(" *\n") + append(" *

This class is internal and experimental. Its APIs are unstable and can change at any\n") + append(" * time. Its APIs (or a version of them) may be promoted to the public stable API in the\n") + append(" * future, but no guarantees are made.\n") + append(" */\n") + append("public final class $accessorClassName {\n\n") + append(" private $accessorClassName() {}\n\n") + + for (p in props) { + append(" static final String ${p.constName} = \"${p.jsonKey}\";\n") + } + append("\n") + + append(" public static final Map> EXPERIMENTAL_PROPERTIES;\n") + append(" static {\n EXPERIMENTAL_PROPERTIES = new HashMap<>();\n") + for (p in props) { + append(" EXPERIMENTAL_PROPERTIES.put(${p.constName}, ${p.typeExpr}.class);\n") + } + append(" }\n\n") + + for (p in props) { + append(" @Nullable\n") + append(" public static ${p.typeExpr} ${p.getter}($stableClassName model) {\n") + append(" return ExtensionPropertyUtil.get(\n") + append(" ${p.constName}, model.getExtensionProperties(), ${p.typeExpr}.class);\n") + append(" }\n\n") + + append(" public static $stableClassName ${p.builder}(\n") + append(" $stableClassName model, ${p.typeExpr} value) {\n") + append(" requireNonNull(value, \"value\");\n") + append(" model.withExtensionProperty(${p.constName}, value);\n") + append(" return model;\n") + append(" }\n\n") + } + + append("}\n") + } + private fun buildPropertyModelSource(pkg: String, className: String) = buildString { appendLicense() append("\npackage $pkg;\n\n") @@ -451,7 +671,9 @@ class DeclarativeConfigPojoGenerator( /** * Formats a schema description string into javadoc lines. Each newline in the schema becomes a - * paragraph break so google-java-format doesn't collapse them into one line. + * paragraph break so google-java-format doesn't collapse them into one line. Empty lines from + * double-newline paragraph separators in the schema are skipped — the following non-empty line + * opens its own paragraph. */ private fun formatJavadoc(description: String): List { val lines = description.trimEnd('\n').split('\n') @@ -460,8 +682,6 @@ class DeclarativeConfigPojoGenerator( lines.forEachIndexed { i, line -> when { i == 0 -> add(line) - // Empty lines arise from \n\n paragraph breaks in the schema. Skip them: the next - // non-empty line will open its own

, so the empty string itself gets no tag. line.isEmpty() -> Unit else -> { add(""); add("

$line") } } diff --git a/sdk-extensions/declarative-config/build.gradle.kts b/sdk-extensions/declarative-config/build.gradle.kts index b55cb460122..941a4155c44 100644 --- a/sdk-extensions/declarative-config/build.gradle.kts +++ b/sdk-extensions/declarative-config/build.gradle.kts @@ -107,8 +107,12 @@ val syncPojoModelsToSrc = tasks.register("syncPojoModelsToSrc") { val modelSrcDir = File(projectDir, "src/main/java") doLast { val modelDir = File(modelSrcDir, modelPackage.replace('.', '/')) - // Delete first so schema type removals don't leave stale classes. - modelDir.deleteRecursively() + // Delete only @Generated files so hand-written files (ModelMapper, ExtensionPropertyUtil) + // in model.internal survive the regeneration cycle. + modelDir.walkTopDown() + .filter { it.isFile && it.extension == "java" } + .filter { it.readText().contains("@Generated(") } + .forEach { it.delete() } DeclarativeConfigPojoGenerator(schemaFile, modelSrcDir, modelPackage).generate() } } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/DeclarativeConfiguration.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/DeclarativeConfiguration.java index 63503d8ba3d..245936f5efe 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/DeclarativeConfiguration.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/DeclarativeConfiguration.java @@ -5,8 +5,6 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import io.opentelemetry.api.incubator.config.DeclarativeConfigException; @@ -15,6 +13,7 @@ import io.opentelemetry.sdk.OpenTelemetrySdk; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OpenTelemetryConfigurationModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SamplerModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ModelMapper; import io.opentelemetry.sdk.autoconfigure.spi.Ordered; import io.opentelemetry.sdk.autoconfigure.spi.internal.AutoConfigureListener; import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider; @@ -56,27 +55,8 @@ *

For Implementers

* *

External consumers needing to parse OpenTelemetry YAML configuration files should use the same - * Jackson ObjectMapper configuration for compatibility. This configuration is intentionally not - * exposed as API to avoid coupling. Instead, copy the following setup: - * - *

{@code
- * ObjectMapper mapper = new ObjectMapper()
- *     // Create empty object instances for keys which are present but have null values
- *     .setDefaultSetterInfo(JsonSetter.Value.forValueNulls(Nulls.AS_EMPTY));
- * // Boxed primitives which are present but have null values should be set to null,
- * // rather than empty instances
- * mapper.configOverride(String.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SET));
- * mapper.configOverride(Integer.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SET));
- * mapper.configOverride(Double.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SET));
- * mapper.configOverride(Boolean.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SET));
- * }
- * - *

Why this configuration: - * - *

    - *
  • Default behavior creates empty objects for null values to match YAML schema expectations - *
  • Boxed primitives remain null to distinguish between absent and explicitly null values - *
+ * Jackson {@code ObjectMapper} configuration for compatibility. See {@link + * io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ModelMapper#MAPPER}. */ public final class DeclarativeConfiguration { @@ -87,34 +67,8 @@ public final class DeclarativeConfiguration { private static final ComponentLoader DEFAULT_COMPONENT_LOADER = ComponentLoader.forClassLoader(DeclarativeConfigProperties.class.getClassLoader()); - /** - * ObjectMapper configured for YAML declarative configuration parsing. - * - *

Configuration: - * - *

    - *
  • Default: Creates empty objects for present keys with null values - *
  • Boxed primitives (String, Integer, Double, Boolean): Remain null when null - *
- * - *

External consumers needing compatible parsing should copy this configuration. See class - * javadoc for details and code example. - */ // Visible for testing - static final ObjectMapper MAPPER; - - static { - MAPPER = - new ObjectMapper() - // Create empty object instances for keys which are present but have null values - .setDefaultSetterInfo(JsonSetter.Value.forValueNulls(Nulls.AS_EMPTY)); - // Boxed primitives which are present but have null values should be set to null, rather than - // empty instances - MAPPER.configOverride(String.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SET)); - MAPPER.configOverride(Integer.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SET)); - MAPPER.configOverride(Double.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SET)); - MAPPER.configOverride(Boolean.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SET)); - } + static final ObjectMapper MAPPER = ModelMapper.MAPPER; private DeclarativeConfiguration() {} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/LogRecordProcessorFactory.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/LogRecordProcessorFactory.java index c1eea4047b1..81cfde81235 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/LogRecordProcessorFactory.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/LogRecordProcessorFactory.java @@ -9,6 +9,7 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LogRecordExporterModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LogRecordProcessorModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SimpleLogRecordProcessorModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.LogRecordProcessorModelAccessor; import io.opentelemetry.sdk.extension.incubator.logs.EventToSpanEventBridge; import io.opentelemetry.sdk.logs.LogRecordProcessor; import io.opentelemetry.sdk.logs.export.BatchLogRecordProcessor; @@ -43,7 +44,7 @@ public LogRecordProcessor create( if (model.getSimple() != null) { return createSimpleLogRecordProcessor(model.getSimple(), context); } - if (model.getEventToSpanEventBridgeDevelopment() != null) { + if (LogRecordProcessorModelAccessor.getEventToSpanEventBridge(model) != null) { return EventToSpanEventBridge.create(); } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/LoggerProviderFactory.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/LoggerProviderFactory.java index 2d09e147ae6..4cceee77991 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/LoggerProviderFactory.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/LoggerProviderFactory.java @@ -14,6 +14,7 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalLoggerConfigModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalLoggerConfiguratorModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalLoggerMatcherAndConfigModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.LoggerProviderModelAccessor; import io.opentelemetry.sdk.common.internal.ScopeConfigurator; import io.opentelemetry.sdk.common.internal.ScopeConfiguratorBuilder; import io.opentelemetry.sdk.logs.LogLimits; @@ -64,7 +65,7 @@ public SdkLoggerProviderBuilder create( } ExperimentalLoggerConfiguratorModel loggerConfiguratorModel = - loggerProviderModel.getLoggerConfiguratorDevelopment(); + LoggerProviderModelAccessor.getLoggerConfigurator(loggerProviderModel); if (loggerConfiguratorModel != null) { ExperimentalLoggerConfigModel defaultConfigModel = loggerConfiguratorModel.getDefaultConfig(); ScopeConfiguratorBuilder configuratorBuilder = ScopeConfigurator.builder(); diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/MeterProviderFactory.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/MeterProviderFactory.java index 919d7130d73..4eb8a061b01 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/MeterProviderFactory.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/MeterProviderFactory.java @@ -16,6 +16,7 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalMeterConfigModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalMeterConfiguratorModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalMeterMatcherAndConfigModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.MeterProviderModelAccessor; import io.opentelemetry.sdk.common.internal.ScopeConfigurator; import io.opentelemetry.sdk.common.internal.ScopeConfiguratorBuilder; import io.opentelemetry.sdk.metrics.SdkMeterProvider; @@ -70,7 +71,7 @@ public SdkMeterProviderBuilder create( } ExperimentalMeterConfiguratorModel meterConfiguratorModel = - model.getMeterConfiguratorDevelopment(); + MeterProviderModelAccessor.getMeterConfigurator(model); if (meterConfiguratorModel != null) { ExperimentalMeterConfigModel defaultConfigModel = meterConfiguratorModel.getDefaultConfig(); ScopeConfiguratorBuilder configuratorBuilder = ScopeConfigurator.builder(); diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/MetricReaderFactory.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/MetricReaderFactory.java index 8fba29e0ad1..4d86c465b04 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/MetricReaderFactory.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/MetricReaderFactory.java @@ -13,6 +13,7 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PullMetricExporterModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PullMetricReaderModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PushMetricExporterModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.PeriodicMetricReaderModelAccessor; import io.opentelemetry.sdk.metrics.export.CardinalityLimitSelector; import io.opentelemetry.sdk.metrics.export.MetricExporter; import io.opentelemetry.sdk.metrics.export.MetricReader; @@ -74,9 +75,9 @@ public MetricReaderAndCardinalityLimits create( cardinalityLimitSelector = CardinalityLimitsFactory.getInstance().create(model.getCardinalityLimits(), context); } - if (model.getMaxExportBatchSizeDevelopment() != null) { - SdkMeterProviderUtil.setMaxExportBatchSize( - builder, model.getMaxExportBatchSizeDevelopment()); + Integer maxExportBatchSize = PeriodicMetricReaderModelAccessor.getMaxExportBatchSize(model); + if (maxExportBatchSize != null) { + SdkMeterProviderUtil.setMaxExportBatchSize(builder, maxExportBatchSize); } MetricReader reader = context.addCloseable(builder.build()); diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/ResourceFactory.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/ResourceFactory.java index 9f670487c28..f17f24cfade 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/ResourceFactory.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/ResourceFactory.java @@ -14,6 +14,7 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ResourceModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalResourceDetectionModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalResourceDetectorModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ResourceModelAccessor; import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties; import io.opentelemetry.sdk.resources.Resource; import io.opentelemetry.sdk.resources.ResourceBuilder; @@ -35,7 +36,7 @@ static ResourceFactory getInstance() { public Resource create(ResourceModel model, DeclarativeConfigContext context) { ResourceBuilder builder = Resource.getDefault().toBuilder(); - ExperimentalResourceDetectionModel detectionModel = model.getDetectionDevelopment(); + ExperimentalResourceDetectionModel detectionModel = ResourceModelAccessor.getDetection(model); if (detectionModel != null) { ResourceBuilder detectedResourceBuilder = Resource.builder(); diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/SamplerFactory.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/SamplerFactory.java index 0c746786b88..5b625a99615 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/SamplerFactory.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/SamplerFactory.java @@ -8,7 +8,9 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ParentBasedSamplerModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SamplerModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.TraceIdRatioBasedSamplerModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalComposableSamplerModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalProbabilitySamplerModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.SamplerModelAccessor; import io.opentelemetry.sdk.extension.incubator.trace.samplers.ComposableSampler; import io.opentelemetry.sdk.extension.incubator.trace.samplers.CompositeSampler; import io.opentelemetry.sdk.trace.samplers.ParentBasedSamplerBuilder; @@ -43,12 +45,16 @@ public Sampler create(SamplerModel model, DeclarativeConfigContext context) { if (model.getParentBased() != null) { return createParedBasedSampler(model.getParentBased(), context); } - if (model.getProbabilityDevelopment() != null) { - return createProbabilitySampler(model.getProbabilityDevelopment()); + ExperimentalProbabilitySamplerModel probabilityDevelopment = + SamplerModelAccessor.getProbability(model); + if (probabilityDevelopment != null) { + return createProbabilitySampler(probabilityDevelopment); } - if (model.getCompositeDevelopment() != null) { + ExperimentalComposableSamplerModel compositeDevelopment = + SamplerModelAccessor.getComposite(model); + if (compositeDevelopment != null) { return CompositeSampler.wrap( - ComposableSamplerFactory.getInstance().create(model.getCompositeDevelopment(), context)); + ComposableSamplerFactory.getInstance().create(compositeDevelopment, context)); } return context.loadComponent(Sampler.class, samplerKeyValue); diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/TracerProviderFactory.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/TracerProviderFactory.java index 78ac20aff26..961ef5c893f 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/TracerProviderFactory.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/TracerProviderFactory.java @@ -12,6 +12,7 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalTracerConfigModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalTracerConfiguratorModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalTracerMatcherAndConfigModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.TracerProviderModelAccessor; import io.opentelemetry.sdk.common.internal.ScopeConfigurator; import io.opentelemetry.sdk.common.internal.ScopeConfiguratorBuilder; import io.opentelemetry.sdk.trace.SdkTracerProvider; @@ -72,7 +73,7 @@ public SdkTracerProviderBuilder create( } ExperimentalTracerConfiguratorModel tracerConfiguratorModel = - tracerProviderModel.getTracerConfiguratorDevelopment(); + TracerProviderModelAccessor.getTracerConfigurator(tracerProviderModel); if (tracerConfiguratorModel != null) { ExperimentalTracerConfigModel defaultConfigModel = tracerConfiguratorModel.getDefaultConfig(); ScopeConfiguratorBuilder configuratorBuilder = ScopeConfigurator.builder(); diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/AggregationModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/AggregationModel.java index 245c3a1ef6a..07f1b0503f5 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/AggregationModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/AggregationModel.java @@ -5,30 +5,67 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.AggregationModel.BASE_2_EXPONENTIAL_BUCKET_HISTOGRAM; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.AggregationModel.DEFAULT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.AggregationModel.DROP; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.AggregationModel.EXPLICIT_BUCKET_HISTOGRAM; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.AggregationModel.LAST_VALUE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.AggregationModel.SUM; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ - "default", - "drop", - "explicit_bucket_histogram", - "base2_exponential_bucket_histogram", - "last_value", - "sum" + DEFAULT, + DROP, + EXPLICIT_BUCKET_HISTOGRAM, + BASE_2_EXPONENTIAL_BUCKET_HISTOGRAM, + LAST_VALUE, + SUM }) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class AggregationModel { + static final String DEFAULT = "default"; + static final String DROP = "drop"; + static final String EXPLICIT_BUCKET_HISTOGRAM = "explicit_bucket_histogram"; + static final String BASE_2_EXPONENTIAL_BUCKET_HISTOGRAM = "base2_exponential_bucket_histogram"; + static final String LAST_VALUE = "last_value"; + static final String SUM = "sum"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(DEFAULT, DefaultAggregationModel.class); + STABLE_PROPERTIES.put(DROP, DropAggregationModel.class); + STABLE_PROPERTIES.put(EXPLICIT_BUCKET_HISTOGRAM, ExplicitBucketHistogramAggregationModel.class); + STABLE_PROPERTIES.put( + BASE_2_EXPONENTIAL_BUCKET_HISTOGRAM, Base2ExponentialBucketHistogramAggregationModel.class); + STABLE_PROPERTIES.put(LAST_VALUE, LastValueAggregationModel.class); + STABLE_PROPERTIES.put(SUM, SumAggregationModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private DefaultAggregationModel _default; @Nullable private DropAggregationModel drop; @Nullable private ExplicitBucketHistogramAggregationModel explicitBucketHistogram; @Nullable private Base2ExponentialBucketHistogramAggregationModel base2ExponentialBucketHistogram; @Nullable private LastValueAggregationModel lastValue; @Nullable private SumAggregationModel sum; + private Map extensionProperties = new LinkedHashMap(); /** * Configures the stream to use the instrument kind to select an aggregation and advisory @@ -38,13 +75,17 @@ public class AggregationModel { * *

If omitted, ignore. */ - @JsonProperty("default") + @JsonProperty(DEFAULT) @Nullable public DefaultAggregationModel getDefault() { + if (_default == null) { + return ExtensionPropertyUtil.getGraduated( + DEFAULT, extensionProperties, DefaultAggregationModel.class); + } return _default; } - @JsonProperty("default") + @JsonProperty(DEFAULT) public AggregationModel withDefault(DefaultAggregationModel _default) { this._default = _default; return this; @@ -57,13 +98,17 @@ public AggregationModel withDefault(DefaultAggregationModel _default) { * *

If omitted, ignore. */ - @JsonProperty("drop") + @JsonProperty(DROP) @Nullable public DropAggregationModel getDrop() { + if (drop == null) { + return ExtensionPropertyUtil.getGraduated( + DROP, extensionProperties, DropAggregationModel.class); + } return drop; } - @JsonProperty("drop") + @JsonProperty(DROP) public AggregationModel withDrop(DropAggregationModel drop) { this.drop = drop; return this; @@ -77,13 +122,19 @@ public AggregationModel withDrop(DropAggregationModel drop) { * *

If omitted, ignore. */ - @JsonProperty("explicit_bucket_histogram") + @JsonProperty(EXPLICIT_BUCKET_HISTOGRAM) @Nullable public ExplicitBucketHistogramAggregationModel getExplicitBucketHistogram() { + if (explicitBucketHistogram == null) { + return ExtensionPropertyUtil.getGraduated( + EXPLICIT_BUCKET_HISTOGRAM, + extensionProperties, + ExplicitBucketHistogramAggregationModel.class); + } return explicitBucketHistogram; } - @JsonProperty("explicit_bucket_histogram") + @JsonProperty(EXPLICIT_BUCKET_HISTOGRAM) public AggregationModel withExplicitBucketHistogram( ExplicitBucketHistogramAggregationModel explicitBucketHistogram) { this.explicitBucketHistogram = explicitBucketHistogram; @@ -99,13 +150,19 @@ public AggregationModel withExplicitBucketHistogram( * *

If omitted, ignore. */ - @JsonProperty("base2_exponential_bucket_histogram") + @JsonProperty(BASE_2_EXPONENTIAL_BUCKET_HISTOGRAM) @Nullable public Base2ExponentialBucketHistogramAggregationModel getBase2ExponentialBucketHistogram() { + if (base2ExponentialBucketHistogram == null) { + return ExtensionPropertyUtil.getGraduated( + BASE_2_EXPONENTIAL_BUCKET_HISTOGRAM, + extensionProperties, + Base2ExponentialBucketHistogramAggregationModel.class); + } return base2ExponentialBucketHistogram; } - @JsonProperty("base2_exponential_bucket_histogram") + @JsonProperty(BASE_2_EXPONENTIAL_BUCKET_HISTOGRAM) public AggregationModel withBase2ExponentialBucketHistogram( Base2ExponentialBucketHistogramAggregationModel base2ExponentialBucketHistogram) { this.base2ExponentialBucketHistogram = base2ExponentialBucketHistogram; @@ -119,13 +176,17 @@ public AggregationModel withBase2ExponentialBucketHistogram( * *

If omitted, ignore. */ - @JsonProperty("last_value") + @JsonProperty(LAST_VALUE) @Nullable public LastValueAggregationModel getLastValue() { + if (lastValue == null) { + return ExtensionPropertyUtil.getGraduated( + LAST_VALUE, extensionProperties, LastValueAggregationModel.class); + } return lastValue; } - @JsonProperty("last_value") + @JsonProperty(LAST_VALUE) public AggregationModel withLastValue(LastValueAggregationModel lastValue) { this.lastValue = lastValue; return this; @@ -138,18 +199,39 @@ public AggregationModel withLastValue(LastValueAggregationModel lastValue) { * *

If omitted, ignore. */ - @JsonProperty("sum") + @JsonProperty(SUM) @Nullable public SumAggregationModel getSum() { + if (sum == null) { + return ExtensionPropertyUtil.getGraduated( + SUM, extensionProperties, SumAggregationModel.class); + } return sum; } - @JsonProperty("sum") + @JsonProperty(SUM) public AggregationModel withSum(SumAggregationModel sum) { this.sum = sum; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public AggregationModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "AggregationModel{" @@ -165,6 +247,8 @@ public String toString() { + lastValue + ", sum=" + sum + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -186,6 +270,8 @@ public int hashCode() { h ^= (this.lastValue == null) ? 0 : this.lastValue.hashCode(); h *= 1000003; h ^= (this.sum == null) ? 0 : this.sum.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -207,7 +293,10 @@ public boolean equals(@Nullable Object o) { && (this.lastValue == null ? that.lastValue == null : this.lastValue.equals(that.lastValue)) - && (this.sum == null ? that.sum == null : this.sum.equals(that.sum)); + && (this.sum == null ? that.sum == null : this.sum.equals(that.sum)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/AttributeLimitsModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/AttributeLimitsModel.java index ccaf1a8c9bd..df202f855c5 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/AttributeLimitsModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/AttributeLimitsModel.java @@ -5,19 +5,43 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.AttributeLimitsModel.ATTRIBUTE_COUNT_LIMIT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.AttributeLimitsModel.ATTRIBUTE_VALUE_LENGTH_LIMIT; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"attribute_value_length_limit", "attribute_count_limit"}) +@JsonPropertyOrder({ATTRIBUTE_VALUE_LENGTH_LIMIT, ATTRIBUTE_COUNT_LIMIT}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class AttributeLimitsModel { + static final String ATTRIBUTE_VALUE_LENGTH_LIMIT = "attribute_value_length_limit"; + static final String ATTRIBUTE_COUNT_LIMIT = "attribute_count_limit"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(ATTRIBUTE_VALUE_LENGTH_LIMIT, Integer.class); + STABLE_PROPERTIES.put(ATTRIBUTE_COUNT_LIMIT, Integer.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private Integer attributeValueLengthLimit; @Nullable private Integer attributeCountLimit; + private Map extensionProperties = new LinkedHashMap(); /** * Configure max attribute value size. @@ -26,13 +50,17 @@ public class AttributeLimitsModel { * *

If omitted or null, there is no limit. */ - @JsonProperty("attribute_value_length_limit") + @JsonProperty(ATTRIBUTE_VALUE_LENGTH_LIMIT) @Nullable public Integer getAttributeValueLengthLimit() { + if (attributeValueLengthLimit == null) { + return ExtensionPropertyUtil.getGraduated( + ATTRIBUTE_VALUE_LENGTH_LIMIT, extensionProperties, Integer.class); + } return attributeValueLengthLimit; } - @JsonProperty("attribute_value_length_limit") + @JsonProperty(ATTRIBUTE_VALUE_LENGTH_LIMIT) public AttributeLimitsModel withAttributeValueLengthLimit(Integer attributeValueLengthLimit) { this.attributeValueLengthLimit = attributeValueLengthLimit; return this; @@ -45,18 +73,39 @@ public AttributeLimitsModel withAttributeValueLengthLimit(Integer attributeValue * *

If omitted or null, 128 is used. */ - @JsonProperty("attribute_count_limit") + @JsonProperty(ATTRIBUTE_COUNT_LIMIT) @Nullable public Integer getAttributeCountLimit() { + if (attributeCountLimit == null) { + return ExtensionPropertyUtil.getGraduated( + ATTRIBUTE_COUNT_LIMIT, extensionProperties, Integer.class); + } return attributeCountLimit; } - @JsonProperty("attribute_count_limit") + @JsonProperty(ATTRIBUTE_COUNT_LIMIT) public AttributeLimitsModel withAttributeCountLimit(Integer attributeCountLimit) { this.attributeCountLimit = attributeCountLimit; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public AttributeLimitsModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "AttributeLimitsModel{" @@ -64,6 +113,8 @@ public String toString() { + attributeValueLengthLimit + ", attributeCountLimit=" + attributeCountLimit + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -74,6 +125,8 @@ public int hashCode() { h ^= (this.attributeValueLengthLimit == null) ? 0 : this.attributeValueLengthLimit.hashCode(); h *= 1000003; h ^= (this.attributeCountLimit == null) ? 0 : this.attributeCountLimit.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -89,7 +142,10 @@ public boolean equals(@Nullable Object o) { : this.attributeValueLengthLimit.equals(that.attributeValueLengthLimit)) && (this.attributeCountLimit == null ? that.attributeCountLimit == null - : this.attributeCountLimit.equals(that.attributeCountLimit)); + : this.attributeCountLimit.equals(that.attributeCountLimit)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/AttributeNameValueModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/AttributeNameValueModel.java index 4c4d0a48ba1..bc386a2ce79 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/AttributeNameValueModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/AttributeNameValueModel.java @@ -5,33 +5,63 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.AttributeNameValueModel.NAME; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.AttributeNameValueModel.TYPE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.AttributeNameValueModel.VALUE; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"name", "value", "type"}) +@JsonPropertyOrder({NAME, VALUE, TYPE}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class AttributeNameValueModel { + static final String NAME = "name"; + static final String VALUE = "value"; + static final String TYPE = "type"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(NAME, String.class); + STABLE_PROPERTIES.put(VALUE, Object.class); + STABLE_PROPERTIES.put(TYPE, AttributeTypeModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private String name; @Nullable private Object value; @Nullable private AttributeTypeModel type; + private Map extensionProperties = new LinkedHashMap(); /** * The attribute name. * *

Property is required and must be non-null. */ - @JsonProperty("name") + @JsonProperty(NAME) @Nullable public String getName() { + if (name == null) { + return ExtensionPropertyUtil.getGraduated(NAME, extensionProperties, String.class); + } return name; } - @JsonProperty("name") + @JsonProperty(NAME) public AttributeNameValueModel withName(String name) { this.name = name; return this; @@ -44,13 +74,16 @@ public AttributeNameValueModel withName(String name) { * *

Property must be present, but if null the entry is ignored. */ - @JsonProperty("value") + @JsonProperty(VALUE) @Nullable public Object getValue() { + if (value == null) { + return ExtensionPropertyUtil.getGraduated(VALUE, extensionProperties, Object.class); + } return value; } - @JsonProperty("value") + @JsonProperty(VALUE) public AttributeNameValueModel withValue(Object value) { this.value = value; return this; @@ -79,18 +112,39 @@ public AttributeNameValueModel withValue(Object value) { * *

If omitted, string is used. */ - @JsonProperty("type") + @JsonProperty(TYPE) @Nullable public AttributeTypeModel getType() { + if (type == null) { + return ExtensionPropertyUtil.getGraduated( + TYPE, extensionProperties, AttributeTypeModel.class); + } return type; } - @JsonProperty("type") + @JsonProperty(TYPE) public AttributeNameValueModel withType(AttributeTypeModel type) { this.type = type; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public AttributeNameValueModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "AttributeNameValueModel{" @@ -100,6 +154,8 @@ public String toString() { + value + ", type=" + type + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -112,6 +168,8 @@ public int hashCode() { h ^= (this.value == null) ? 0 : this.value.hashCode(); h *= 1000003; h ^= (this.type == null) ? 0 : this.type.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -124,7 +182,10 @@ public boolean equals(@Nullable Object o) { AttributeNameValueModel that = (AttributeNameValueModel) o; return (this.name == null ? that.name == null : this.name.equals(that.name)) && (this.value == null ? that.value == null : this.value.equals(that.value)) - && (this.type == null ? that.type == null : this.type.equals(that.type)); + && (this.type == null ? that.type == null : this.type.equals(that.type)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/Base2ExponentialBucketHistogramAggregationModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/Base2ExponentialBucketHistogramAggregationModel.java index e0101f29bd6..b0a856449b0 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/Base2ExponentialBucketHistogramAggregationModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/Base2ExponentialBucketHistogramAggregationModel.java @@ -5,33 +5,63 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.Base2ExponentialBucketHistogramAggregationModel.MAX_SCALE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.Base2ExponentialBucketHistogramAggregationModel.MAX_SIZE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.Base2ExponentialBucketHistogramAggregationModel.RECORD_MIN_MAX; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"max_scale", "max_size", "record_min_max"}) +@JsonPropertyOrder({MAX_SCALE, MAX_SIZE, RECORD_MIN_MAX}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class Base2ExponentialBucketHistogramAggregationModel { + static final String MAX_SCALE = "max_scale"; + static final String MAX_SIZE = "max_size"; + static final String RECORD_MIN_MAX = "record_min_max"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(MAX_SCALE, Integer.class); + STABLE_PROPERTIES.put(MAX_SIZE, Integer.class); + STABLE_PROPERTIES.put(RECORD_MIN_MAX, Boolean.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private Integer maxScale; @Nullable private Integer maxSize; @Nullable private Boolean recordMinMax; + private Map extensionProperties = new LinkedHashMap(); /** * Configure the max scale factor. * *

If omitted or null, 20 is used. */ - @JsonProperty("max_scale") + @JsonProperty(MAX_SCALE) @Nullable public Integer getMaxScale() { + if (maxScale == null) { + return ExtensionPropertyUtil.getGraduated(MAX_SCALE, extensionProperties, Integer.class); + } return maxScale; } - @JsonProperty("max_scale") + @JsonProperty(MAX_SCALE) public Base2ExponentialBucketHistogramAggregationModel withMaxScale(Integer maxScale) { this.maxScale = maxScale; return this; @@ -43,13 +73,16 @@ public Base2ExponentialBucketHistogramAggregationModel withMaxScale(Integer maxS * *

If omitted or null, 160 is used. */ - @JsonProperty("max_size") + @JsonProperty(MAX_SIZE) @Nullable public Integer getMaxSize() { + if (maxSize == null) { + return ExtensionPropertyUtil.getGraduated(MAX_SIZE, extensionProperties, Integer.class); + } return maxSize; } - @JsonProperty("max_size") + @JsonProperty(MAX_SIZE) public Base2ExponentialBucketHistogramAggregationModel withMaxSize(Integer maxSize) { this.maxSize = maxSize; return this; @@ -60,18 +93,39 @@ public Base2ExponentialBucketHistogramAggregationModel withMaxSize(Integer maxSi * *

If omitted or null, true is used. */ - @JsonProperty("record_min_max") + @JsonProperty(RECORD_MIN_MAX) @Nullable public Boolean getRecordMinMax() { + if (recordMinMax == null) { + return ExtensionPropertyUtil.getGraduated(RECORD_MIN_MAX, extensionProperties, Boolean.class); + } return recordMinMax; } - @JsonProperty("record_min_max") + @JsonProperty(RECORD_MIN_MAX) public Base2ExponentialBucketHistogramAggregationModel withRecordMinMax(Boolean recordMinMax) { this.recordMinMax = recordMinMax; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public Base2ExponentialBucketHistogramAggregationModel withExtensionProperty( + String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "Base2ExponentialBucketHistogramAggregationModel{" @@ -81,6 +135,8 @@ public String toString() { + maxSize + ", recordMinMax=" + recordMinMax + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -93,6 +149,8 @@ public int hashCode() { h ^= (this.maxSize == null) ? 0 : this.maxSize.hashCode(); h *= 1000003; h ^= (this.recordMinMax == null) ? 0 : this.recordMinMax.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -108,7 +166,10 @@ public boolean equals(@Nullable Object o) { && (this.maxSize == null ? that.maxSize == null : this.maxSize.equals(that.maxSize)) && (this.recordMinMax == null ? that.recordMinMax == null - : this.recordMinMax.equals(that.recordMinMax)); + : this.recordMinMax.equals(that.recordMinMax)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/BatchLogRecordProcessorModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/BatchLogRecordProcessorModel.java index 3d9ac80a3c2..880647a880e 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/BatchLogRecordProcessorModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/BatchLogRecordProcessorModel.java @@ -5,28 +5,61 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.BatchLogRecordProcessorModel.EXPORTER; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.BatchLogRecordProcessorModel.EXPORT_TIMEOUT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.BatchLogRecordProcessorModel.MAX_EXPORT_BATCH_SIZE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.BatchLogRecordProcessorModel.MAX_QUEUE_SIZE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.BatchLogRecordProcessorModel.SCHEDULE_DELAY; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ - "schedule_delay", - "export_timeout", - "max_queue_size", - "max_export_batch_size", - "exporter" + SCHEDULE_DELAY, + EXPORT_TIMEOUT, + MAX_QUEUE_SIZE, + MAX_EXPORT_BATCH_SIZE, + EXPORTER }) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class BatchLogRecordProcessorModel { + static final String SCHEDULE_DELAY = "schedule_delay"; + static final String EXPORT_TIMEOUT = "export_timeout"; + static final String MAX_QUEUE_SIZE = "max_queue_size"; + static final String MAX_EXPORT_BATCH_SIZE = "max_export_batch_size"; + static final String EXPORTER = "exporter"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(SCHEDULE_DELAY, Integer.class); + STABLE_PROPERTIES.put(EXPORT_TIMEOUT, Integer.class); + STABLE_PROPERTIES.put(MAX_QUEUE_SIZE, Integer.class); + STABLE_PROPERTIES.put(MAX_EXPORT_BATCH_SIZE, Integer.class); + STABLE_PROPERTIES.put(EXPORTER, LogRecordExporterModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private Integer scheduleDelay; @Nullable private Integer exportTimeout; @Nullable private Integer maxQueueSize; @Nullable private Integer maxExportBatchSize; @Nullable private LogRecordExporterModel exporter; + private Map extensionProperties = new LinkedHashMap(); /** * Configure delay interval (in milliseconds) between two consecutive exports. @@ -35,13 +68,16 @@ public class BatchLogRecordProcessorModel { * *

If omitted or null, 1000 is used. */ - @JsonProperty("schedule_delay") + @JsonProperty(SCHEDULE_DELAY) @Nullable public Integer getScheduleDelay() { + if (scheduleDelay == null) { + return ExtensionPropertyUtil.getGraduated(SCHEDULE_DELAY, extensionProperties, Integer.class); + } return scheduleDelay; } - @JsonProperty("schedule_delay") + @JsonProperty(SCHEDULE_DELAY) public BatchLogRecordProcessorModel withScheduleDelay(Integer scheduleDelay) { this.scheduleDelay = scheduleDelay; return this; @@ -54,13 +90,16 @@ public BatchLogRecordProcessorModel withScheduleDelay(Integer scheduleDelay) { * *

If omitted or null, 30000 is used. */ - @JsonProperty("export_timeout") + @JsonProperty(EXPORT_TIMEOUT) @Nullable public Integer getExportTimeout() { + if (exportTimeout == null) { + return ExtensionPropertyUtil.getGraduated(EXPORT_TIMEOUT, extensionProperties, Integer.class); + } return exportTimeout; } - @JsonProperty("export_timeout") + @JsonProperty(EXPORT_TIMEOUT) public BatchLogRecordProcessorModel withExportTimeout(Integer exportTimeout) { this.exportTimeout = exportTimeout; return this; @@ -71,13 +110,16 @@ public BatchLogRecordProcessorModel withExportTimeout(Integer exportTimeout) { * *

If omitted or null, 2048 is used. */ - @JsonProperty("max_queue_size") + @JsonProperty(MAX_QUEUE_SIZE) @Nullable public Integer getMaxQueueSize() { + if (maxQueueSize == null) { + return ExtensionPropertyUtil.getGraduated(MAX_QUEUE_SIZE, extensionProperties, Integer.class); + } return maxQueueSize; } - @JsonProperty("max_queue_size") + @JsonProperty(MAX_QUEUE_SIZE) public BatchLogRecordProcessorModel withMaxQueueSize(Integer maxQueueSize) { this.maxQueueSize = maxQueueSize; return this; @@ -88,13 +130,17 @@ public BatchLogRecordProcessorModel withMaxQueueSize(Integer maxQueueSize) { * *

If omitted or null, 512 is used. */ - @JsonProperty("max_export_batch_size") + @JsonProperty(MAX_EXPORT_BATCH_SIZE) @Nullable public Integer getMaxExportBatchSize() { + if (maxExportBatchSize == null) { + return ExtensionPropertyUtil.getGraduated( + MAX_EXPORT_BATCH_SIZE, extensionProperties, Integer.class); + } return maxExportBatchSize; } - @JsonProperty("max_export_batch_size") + @JsonProperty(MAX_EXPORT_BATCH_SIZE) public BatchLogRecordProcessorModel withMaxExportBatchSize(Integer maxExportBatchSize) { this.maxExportBatchSize = maxExportBatchSize; return this; @@ -105,18 +151,39 @@ public BatchLogRecordProcessorModel withMaxExportBatchSize(Integer maxExportBatc * *

Property is required and must be non-null. */ - @JsonProperty("exporter") + @JsonProperty(EXPORTER) @Nullable public LogRecordExporterModel getExporter() { + if (exporter == null) { + return ExtensionPropertyUtil.getGraduated( + EXPORTER, extensionProperties, LogRecordExporterModel.class); + } return exporter; } - @JsonProperty("exporter") + @JsonProperty(EXPORTER) public BatchLogRecordProcessorModel withExporter(LogRecordExporterModel exporter) { this.exporter = exporter; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public BatchLogRecordProcessorModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "BatchLogRecordProcessorModel{" @@ -130,6 +197,8 @@ public String toString() { + maxExportBatchSize + ", exporter=" + exporter + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -146,6 +215,8 @@ public int hashCode() { h ^= (this.maxExportBatchSize == null) ? 0 : this.maxExportBatchSize.hashCode(); h *= 1000003; h ^= (this.exporter == null) ? 0 : this.exporter.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -168,7 +239,10 @@ public boolean equals(@Nullable Object o) { && (this.maxExportBatchSize == null ? that.maxExportBatchSize == null : this.maxExportBatchSize.equals(that.maxExportBatchSize)) - && (this.exporter == null ? that.exporter == null : this.exporter.equals(that.exporter)); + && (this.exporter == null ? that.exporter == null : this.exporter.equals(that.exporter)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/BatchSpanProcessorModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/BatchSpanProcessorModel.java index 4671acf7957..fae445ee879 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/BatchSpanProcessorModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/BatchSpanProcessorModel.java @@ -5,28 +5,61 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.BatchSpanProcessorModel.EXPORTER; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.BatchSpanProcessorModel.EXPORT_TIMEOUT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.BatchSpanProcessorModel.MAX_EXPORT_BATCH_SIZE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.BatchSpanProcessorModel.MAX_QUEUE_SIZE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.BatchSpanProcessorModel.SCHEDULE_DELAY; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ - "schedule_delay", - "export_timeout", - "max_queue_size", - "max_export_batch_size", - "exporter" + SCHEDULE_DELAY, + EXPORT_TIMEOUT, + MAX_QUEUE_SIZE, + MAX_EXPORT_BATCH_SIZE, + EXPORTER }) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class BatchSpanProcessorModel { + static final String SCHEDULE_DELAY = "schedule_delay"; + static final String EXPORT_TIMEOUT = "export_timeout"; + static final String MAX_QUEUE_SIZE = "max_queue_size"; + static final String MAX_EXPORT_BATCH_SIZE = "max_export_batch_size"; + static final String EXPORTER = "exporter"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(SCHEDULE_DELAY, Integer.class); + STABLE_PROPERTIES.put(EXPORT_TIMEOUT, Integer.class); + STABLE_PROPERTIES.put(MAX_QUEUE_SIZE, Integer.class); + STABLE_PROPERTIES.put(MAX_EXPORT_BATCH_SIZE, Integer.class); + STABLE_PROPERTIES.put(EXPORTER, SpanExporterModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private Integer scheduleDelay; @Nullable private Integer exportTimeout; @Nullable private Integer maxQueueSize; @Nullable private Integer maxExportBatchSize; @Nullable private SpanExporterModel exporter; + private Map extensionProperties = new LinkedHashMap(); /** * Configure delay interval (in milliseconds) between two consecutive exports. @@ -35,13 +68,16 @@ public class BatchSpanProcessorModel { * *

If omitted or null, 5000 is used. */ - @JsonProperty("schedule_delay") + @JsonProperty(SCHEDULE_DELAY) @Nullable public Integer getScheduleDelay() { + if (scheduleDelay == null) { + return ExtensionPropertyUtil.getGraduated(SCHEDULE_DELAY, extensionProperties, Integer.class); + } return scheduleDelay; } - @JsonProperty("schedule_delay") + @JsonProperty(SCHEDULE_DELAY) public BatchSpanProcessorModel withScheduleDelay(Integer scheduleDelay) { this.scheduleDelay = scheduleDelay; return this; @@ -54,13 +90,16 @@ public BatchSpanProcessorModel withScheduleDelay(Integer scheduleDelay) { * *

If omitted or null, 30000 is used. */ - @JsonProperty("export_timeout") + @JsonProperty(EXPORT_TIMEOUT) @Nullable public Integer getExportTimeout() { + if (exportTimeout == null) { + return ExtensionPropertyUtil.getGraduated(EXPORT_TIMEOUT, extensionProperties, Integer.class); + } return exportTimeout; } - @JsonProperty("export_timeout") + @JsonProperty(EXPORT_TIMEOUT) public BatchSpanProcessorModel withExportTimeout(Integer exportTimeout) { this.exportTimeout = exportTimeout; return this; @@ -71,13 +110,16 @@ public BatchSpanProcessorModel withExportTimeout(Integer exportTimeout) { * *

If omitted or null, 2048 is used. */ - @JsonProperty("max_queue_size") + @JsonProperty(MAX_QUEUE_SIZE) @Nullable public Integer getMaxQueueSize() { + if (maxQueueSize == null) { + return ExtensionPropertyUtil.getGraduated(MAX_QUEUE_SIZE, extensionProperties, Integer.class); + } return maxQueueSize; } - @JsonProperty("max_queue_size") + @JsonProperty(MAX_QUEUE_SIZE) public BatchSpanProcessorModel withMaxQueueSize(Integer maxQueueSize) { this.maxQueueSize = maxQueueSize; return this; @@ -88,13 +130,17 @@ public BatchSpanProcessorModel withMaxQueueSize(Integer maxQueueSize) { * *

If omitted or null, 512 is used. */ - @JsonProperty("max_export_batch_size") + @JsonProperty(MAX_EXPORT_BATCH_SIZE) @Nullable public Integer getMaxExportBatchSize() { + if (maxExportBatchSize == null) { + return ExtensionPropertyUtil.getGraduated( + MAX_EXPORT_BATCH_SIZE, extensionProperties, Integer.class); + } return maxExportBatchSize; } - @JsonProperty("max_export_batch_size") + @JsonProperty(MAX_EXPORT_BATCH_SIZE) public BatchSpanProcessorModel withMaxExportBatchSize(Integer maxExportBatchSize) { this.maxExportBatchSize = maxExportBatchSize; return this; @@ -105,18 +151,39 @@ public BatchSpanProcessorModel withMaxExportBatchSize(Integer maxExportBatchSize * *

Property is required and must be non-null. */ - @JsonProperty("exporter") + @JsonProperty(EXPORTER) @Nullable public SpanExporterModel getExporter() { + if (exporter == null) { + return ExtensionPropertyUtil.getGraduated( + EXPORTER, extensionProperties, SpanExporterModel.class); + } return exporter; } - @JsonProperty("exporter") + @JsonProperty(EXPORTER) public BatchSpanProcessorModel withExporter(SpanExporterModel exporter) { this.exporter = exporter; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public BatchSpanProcessorModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "BatchSpanProcessorModel{" @@ -130,6 +197,8 @@ public String toString() { + maxExportBatchSize + ", exporter=" + exporter + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -146,6 +215,8 @@ public int hashCode() { h ^= (this.maxExportBatchSize == null) ? 0 : this.maxExportBatchSize.hashCode(); h *= 1000003; h ^= (this.exporter == null) ? 0 : this.exporter.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -168,7 +239,10 @@ public boolean equals(@Nullable Object o) { && (this.maxExportBatchSize == null ? that.maxExportBatchSize == null : this.maxExportBatchSize.equals(that.maxExportBatchSize)) - && (this.exporter == null ? that.exporter == null : this.exporter.equals(that.exporter)); + && (this.exporter == null ? that.exporter == null : this.exporter.equals(that.exporter)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/CardinalityLimitsModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/CardinalityLimitsModel.java index 8fecb8b00e1..f1210f1d26d 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/CardinalityLimitsModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/CardinalityLimitsModel.java @@ -5,26 +5,67 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.CardinalityLimitsModel.COUNTER; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.CardinalityLimitsModel.DEFAULT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.CardinalityLimitsModel.GAUGE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.CardinalityLimitsModel.HISTOGRAM; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.CardinalityLimitsModel.OBSERVABLE_COUNTER; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.CardinalityLimitsModel.OBSERVABLE_GAUGE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.CardinalityLimitsModel.OBSERVABLE_UP_DOWN_COUNTER; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.CardinalityLimitsModel.UP_DOWN_COUNTER; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ - "default", - "counter", - "gauge", - "histogram", - "observable_counter", - "observable_gauge", - "observable_up_down_counter", - "up_down_counter" + DEFAULT, + COUNTER, + GAUGE, + HISTOGRAM, + OBSERVABLE_COUNTER, + OBSERVABLE_GAUGE, + OBSERVABLE_UP_DOWN_COUNTER, + UP_DOWN_COUNTER }) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class CardinalityLimitsModel { + static final String DEFAULT = "default"; + static final String COUNTER = "counter"; + static final String GAUGE = "gauge"; + static final String HISTOGRAM = "histogram"; + static final String OBSERVABLE_COUNTER = "observable_counter"; + static final String OBSERVABLE_GAUGE = "observable_gauge"; + static final String OBSERVABLE_UP_DOWN_COUNTER = "observable_up_down_counter"; + static final String UP_DOWN_COUNTER = "up_down_counter"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(DEFAULT, Integer.class); + STABLE_PROPERTIES.put(COUNTER, Integer.class); + STABLE_PROPERTIES.put(GAUGE, Integer.class); + STABLE_PROPERTIES.put(HISTOGRAM, Integer.class); + STABLE_PROPERTIES.put(OBSERVABLE_COUNTER, Integer.class); + STABLE_PROPERTIES.put(OBSERVABLE_GAUGE, Integer.class); + STABLE_PROPERTIES.put(OBSERVABLE_UP_DOWN_COUNTER, Integer.class); + STABLE_PROPERTIES.put(UP_DOWN_COUNTER, Integer.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private Integer _default; @Nullable private Integer counter; @Nullable private Integer gauge; @@ -33,6 +74,7 @@ public class CardinalityLimitsModel { @Nullable private Integer observableGauge; @Nullable private Integer observableUpDownCounter; @Nullable private Integer upDownCounter; + private Map extensionProperties = new LinkedHashMap(); /** * Configure default cardinality limit for all instrument types. @@ -41,13 +83,16 @@ public class CardinalityLimitsModel { * *

If omitted or null, 2000 is used. */ - @JsonProperty("default") + @JsonProperty(DEFAULT) @Nullable public Integer getDefault() { + if (_default == null) { + return ExtensionPropertyUtil.getGraduated(DEFAULT, extensionProperties, Integer.class); + } return _default; } - @JsonProperty("default") + @JsonProperty(DEFAULT) public CardinalityLimitsModel withDefault(Integer _default) { this._default = _default; return this; @@ -58,13 +103,16 @@ public CardinalityLimitsModel withDefault(Integer _default) { * *

If omitted or null, the value from .default is used. */ - @JsonProperty("counter") + @JsonProperty(COUNTER) @Nullable public Integer getCounter() { + if (counter == null) { + return ExtensionPropertyUtil.getGraduated(COUNTER, extensionProperties, Integer.class); + } return counter; } - @JsonProperty("counter") + @JsonProperty(COUNTER) public CardinalityLimitsModel withCounter(Integer counter) { this.counter = counter; return this; @@ -75,13 +123,16 @@ public CardinalityLimitsModel withCounter(Integer counter) { * *

If omitted or null, the value from .default is used. */ - @JsonProperty("gauge") + @JsonProperty(GAUGE) @Nullable public Integer getGauge() { + if (gauge == null) { + return ExtensionPropertyUtil.getGraduated(GAUGE, extensionProperties, Integer.class); + } return gauge; } - @JsonProperty("gauge") + @JsonProperty(GAUGE) public CardinalityLimitsModel withGauge(Integer gauge) { this.gauge = gauge; return this; @@ -92,13 +143,16 @@ public CardinalityLimitsModel withGauge(Integer gauge) { * *

If omitted or null, the value from .default is used. */ - @JsonProperty("histogram") + @JsonProperty(HISTOGRAM) @Nullable public Integer getHistogram() { + if (histogram == null) { + return ExtensionPropertyUtil.getGraduated(HISTOGRAM, extensionProperties, Integer.class); + } return histogram; } - @JsonProperty("histogram") + @JsonProperty(HISTOGRAM) public CardinalityLimitsModel withHistogram(Integer histogram) { this.histogram = histogram; return this; @@ -109,13 +163,17 @@ public CardinalityLimitsModel withHistogram(Integer histogram) { * *

If omitted or null, the value from .default is used. */ - @JsonProperty("observable_counter") + @JsonProperty(OBSERVABLE_COUNTER) @Nullable public Integer getObservableCounter() { + if (observableCounter == null) { + return ExtensionPropertyUtil.getGraduated( + OBSERVABLE_COUNTER, extensionProperties, Integer.class); + } return observableCounter; } - @JsonProperty("observable_counter") + @JsonProperty(OBSERVABLE_COUNTER) public CardinalityLimitsModel withObservableCounter(Integer observableCounter) { this.observableCounter = observableCounter; return this; @@ -126,13 +184,17 @@ public CardinalityLimitsModel withObservableCounter(Integer observableCounter) { * *

If omitted or null, the value from .default is used. */ - @JsonProperty("observable_gauge") + @JsonProperty(OBSERVABLE_GAUGE) @Nullable public Integer getObservableGauge() { + if (observableGauge == null) { + return ExtensionPropertyUtil.getGraduated( + OBSERVABLE_GAUGE, extensionProperties, Integer.class); + } return observableGauge; } - @JsonProperty("observable_gauge") + @JsonProperty(OBSERVABLE_GAUGE) public CardinalityLimitsModel withObservableGauge(Integer observableGauge) { this.observableGauge = observableGauge; return this; @@ -143,13 +205,17 @@ public CardinalityLimitsModel withObservableGauge(Integer observableGauge) { * *

If omitted or null, the value from .default is used. */ - @JsonProperty("observable_up_down_counter") + @JsonProperty(OBSERVABLE_UP_DOWN_COUNTER) @Nullable public Integer getObservableUpDownCounter() { + if (observableUpDownCounter == null) { + return ExtensionPropertyUtil.getGraduated( + OBSERVABLE_UP_DOWN_COUNTER, extensionProperties, Integer.class); + } return observableUpDownCounter; } - @JsonProperty("observable_up_down_counter") + @JsonProperty(OBSERVABLE_UP_DOWN_COUNTER) public CardinalityLimitsModel withObservableUpDownCounter(Integer observableUpDownCounter) { this.observableUpDownCounter = observableUpDownCounter; return this; @@ -160,18 +226,39 @@ public CardinalityLimitsModel withObservableUpDownCounter(Integer observableUpDo * *

If omitted or null, the value from .default is used. */ - @JsonProperty("up_down_counter") + @JsonProperty(UP_DOWN_COUNTER) @Nullable public Integer getUpDownCounter() { + if (upDownCounter == null) { + return ExtensionPropertyUtil.getGraduated( + UP_DOWN_COUNTER, extensionProperties, Integer.class); + } return upDownCounter; } - @JsonProperty("up_down_counter") + @JsonProperty(UP_DOWN_COUNTER) public CardinalityLimitsModel withUpDownCounter(Integer upDownCounter) { this.upDownCounter = upDownCounter; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public CardinalityLimitsModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "CardinalityLimitsModel{" @@ -191,6 +278,8 @@ public String toString() { + observableUpDownCounter + ", upDownCounter=" + upDownCounter + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -213,6 +302,8 @@ public int hashCode() { h ^= (this.observableUpDownCounter == null) ? 0 : this.observableUpDownCounter.hashCode(); h *= 1000003; h ^= (this.upDownCounter == null) ? 0 : this.upDownCounter.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -240,7 +331,10 @@ public boolean equals(@Nullable Object o) { : this.observableUpDownCounter.equals(that.observableUpDownCounter)) && (this.upDownCounter == null ? that.upDownCounter == null - : this.upDownCounter.equals(that.upDownCounter)); + : this.upDownCounter.equals(that.upDownCounter)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ConsoleMetricExporterModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ConsoleMetricExporterModel.java index 2b5992ae800..d6a06622936 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ConsoleMetricExporterModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ConsoleMetricExporterModel.java @@ -5,19 +5,44 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ConsoleMetricExporterModel.DEFAULT_HISTOGRAM_AGGREGATION; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ConsoleMetricExporterModel.TEMPORALITY_PREFERENCE; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"temporality_preference", "default_histogram_aggregation"}) +@JsonPropertyOrder({TEMPORALITY_PREFERENCE, DEFAULT_HISTOGRAM_AGGREGATION}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class ConsoleMetricExporterModel { + static final String TEMPORALITY_PREFERENCE = "temporality_preference"; + static final String DEFAULT_HISTOGRAM_AGGREGATION = "default_histogram_aggregation"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(TEMPORALITY_PREFERENCE, ExporterTemporalityPreferenceModel.class); + STABLE_PROPERTIES.put( + DEFAULT_HISTOGRAM_AGGREGATION, ExporterDefaultHistogramAggregationModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private ExporterTemporalityPreferenceModel temporalityPreference; @Nullable private ExporterDefaultHistogramAggregationModel defaultHistogramAggregation; + private Map extensionProperties = new LinkedHashMap(); /** * Configure temporality preference. @@ -34,13 +59,17 @@ public class ConsoleMetricExporterModel { * *

If omitted, cumulative is used. */ - @JsonProperty("temporality_preference") + @JsonProperty(TEMPORALITY_PREFERENCE) @Nullable public ExporterTemporalityPreferenceModel getTemporalityPreference() { + if (temporalityPreference == null) { + return ExtensionPropertyUtil.getGraduated( + TEMPORALITY_PREFERENCE, extensionProperties, ExporterTemporalityPreferenceModel.class); + } return temporalityPreference; } - @JsonProperty("temporality_preference") + @JsonProperty(TEMPORALITY_PREFERENCE) public ConsoleMetricExporterModel withTemporalityPreference( ExporterTemporalityPreferenceModel temporalityPreference) { this.temporalityPreference = temporalityPreference; @@ -60,19 +89,42 @@ public ConsoleMetricExporterModel withTemporalityPreference( * *

If omitted, explicit_bucket_histogram is used. */ - @JsonProperty("default_histogram_aggregation") + @JsonProperty(DEFAULT_HISTOGRAM_AGGREGATION) @Nullable public ExporterDefaultHistogramAggregationModel getDefaultHistogramAggregation() { + if (defaultHistogramAggregation == null) { + return ExtensionPropertyUtil.getGraduated( + DEFAULT_HISTOGRAM_AGGREGATION, + extensionProperties, + ExporterDefaultHistogramAggregationModel.class); + } return defaultHistogramAggregation; } - @JsonProperty("default_histogram_aggregation") + @JsonProperty(DEFAULT_HISTOGRAM_AGGREGATION) public ConsoleMetricExporterModel withDefaultHistogramAggregation( ExporterDefaultHistogramAggregationModel defaultHistogramAggregation) { this.defaultHistogramAggregation = defaultHistogramAggregation; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public ConsoleMetricExporterModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "ConsoleMetricExporterModel{" @@ -80,6 +132,8 @@ public String toString() { + temporalityPreference + ", defaultHistogramAggregation=" + defaultHistogramAggregation + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -93,6 +147,8 @@ public int hashCode() { (this.defaultHistogramAggregation == null) ? 0 : this.defaultHistogramAggregation.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -108,7 +164,10 @@ public boolean equals(@Nullable Object o) { : this.temporalityPreference.equals(that.temporalityPreference)) && (this.defaultHistogramAggregation == null ? that.defaultHistogramAggregation == null - : this.defaultHistogramAggregation.equals(that.defaultHistogramAggregation)); + : this.defaultHistogramAggregation.equals(that.defaultHistogramAggregation)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/DistributionModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/DistributionModel.java index b5960eeae3c..5d3bccf53fc 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/DistributionModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/DistributionModel.java @@ -9,6 +9,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import javax.annotation.Generated; @@ -19,30 +21,37 @@ @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class DistributionModel { - private Map additionalProperties = - new LinkedHashMap(); + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = true; + + private Map extensionProperties = new LinkedHashMap(); @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; + public Map getExtensionProperties() { + return extensionProperties; } @JsonAnySetter - public DistributionModel withAdditionalProperty(String name, DistributionPropertyModel value) { - this.additionalProperties.put(name, value); + public DistributionModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + Collections.emptyMap(), + ALLOWS_ADDITIONAL_PROPERTIES); return this; } @Override public String toString() { - return "DistributionModel{" + "additionalProperties=" + additionalProperties + "}"; + return "DistributionModel{" + "extensionProperties=" + extensionProperties + "}"; } @Override public int hashCode() { int h = 1; h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -53,9 +62,9 @@ public boolean equals(@Nullable Object o) { } if (o instanceof DistributionModel) { DistributionModel that = (DistributionModel) o; - return (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); + return (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/DistributionPropertyModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/DistributionPropertyModel.java deleted file mode 100644 index 321e484d8b5..00000000000 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/DistributionPropertyModel.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.util.LinkedHashMap; -import java.util.Map; -import javax.annotation.Generated; -import javax.annotation.Nullable; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({}) -@Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") -public class DistributionPropertyModel { - - private Map additionalProperties = new LinkedHashMap(); - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public DistributionPropertyModel withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - - @Override - public String toString() { - return "DistributionPropertyModel{" + "additionalProperties=" + additionalProperties + "}"; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); - return h; - } - - @Override - public boolean equals(@Nullable Object o) { - if (o == this) { - return true; - } - if (o instanceof DistributionPropertyModel) { - DistributionPropertyModel that = (DistributionPropertyModel) o; - return (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); - } - return false; - } -} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ExplicitBucketHistogramAggregationModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ExplicitBucketHistogramAggregationModel.java index 87c083d22b3..9c839ca89ed 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ExplicitBucketHistogramAggregationModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ExplicitBucketHistogramAggregationModel.java @@ -5,20 +5,43 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ExplicitBucketHistogramAggregationModel.BOUNDARIES; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ExplicitBucketHistogramAggregationModel.RECORD_MIN_MAX; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"boundaries", "record_min_max"}) +@JsonPropertyOrder({BOUNDARIES, RECORD_MIN_MAX}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class ExplicitBucketHistogramAggregationModel { + static final String BOUNDARIES = "boundaries"; + static final String RECORD_MIN_MAX = "record_min_max"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(RECORD_MIN_MAX, Boolean.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private List boundaries; @Nullable private Boolean recordMinMax; + private Map extensionProperties = new LinkedHashMap(); /** * Configure bucket boundaries. @@ -26,13 +49,13 @@ public class ExplicitBucketHistogramAggregationModel { *

If omitted, [0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000] is * used. */ - @JsonProperty("boundaries") + @JsonProperty(BOUNDARIES) @Nullable public List getBoundaries() { return boundaries; } - @JsonProperty("boundaries") + @JsonProperty(BOUNDARIES) public ExplicitBucketHistogramAggregationModel withBoundaries(List boundaries) { this.boundaries = boundaries; return this; @@ -43,18 +66,39 @@ public ExplicitBucketHistogramAggregationModel withBoundaries(List bound * *

If omitted or null, true is used. */ - @JsonProperty("record_min_max") + @JsonProperty(RECORD_MIN_MAX) @Nullable public Boolean getRecordMinMax() { + if (recordMinMax == null) { + return ExtensionPropertyUtil.getGraduated(RECORD_MIN_MAX, extensionProperties, Boolean.class); + } return recordMinMax; } - @JsonProperty("record_min_max") + @JsonProperty(RECORD_MIN_MAX) public ExplicitBucketHistogramAggregationModel withRecordMinMax(Boolean recordMinMax) { this.recordMinMax = recordMinMax; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public ExplicitBucketHistogramAggregationModel withExtensionProperty( + String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "ExplicitBucketHistogramAggregationModel{" @@ -62,6 +106,8 @@ public String toString() { + boundaries + ", recordMinMax=" + recordMinMax + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -72,6 +118,8 @@ public int hashCode() { h ^= (this.boundaries == null) ? 0 : this.boundaries.hashCode(); h *= 1000003; h ^= (this.recordMinMax == null) ? 0 : this.recordMinMax.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -87,7 +135,10 @@ public boolean equals(@Nullable Object o) { : this.boundaries.equals(that.boundaries)) && (this.recordMinMax == null ? that.recordMinMax == null - : this.recordMinMax.equals(that.recordMinMax)); + : this.recordMinMax.equals(that.recordMinMax)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/GrpcTlsModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/GrpcTlsModel.java index f74ef2effc2..45d306f3c35 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/GrpcTlsModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/GrpcTlsModel.java @@ -5,21 +5,51 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.GrpcTlsModel.CA_FILE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.GrpcTlsModel.CERT_FILE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.GrpcTlsModel.INSECURE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.GrpcTlsModel.KEY_FILE; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"ca_file", "key_file", "cert_file", "insecure"}) +@JsonPropertyOrder({CA_FILE, KEY_FILE, CERT_FILE, INSECURE}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class GrpcTlsModel { + static final String CA_FILE = "ca_file"; + static final String KEY_FILE = "key_file"; + static final String CERT_FILE = "cert_file"; + static final String INSECURE = "insecure"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(CA_FILE, String.class); + STABLE_PROPERTIES.put(KEY_FILE, String.class); + STABLE_PROPERTIES.put(CERT_FILE, String.class); + STABLE_PROPERTIES.put(INSECURE, Boolean.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private String caFile; @Nullable private String keyFile; @Nullable private String certFile; @Nullable private Boolean insecure; + private Map extensionProperties = new LinkedHashMap(); /** * Configure certificate used to verify a server's TLS credentials. @@ -28,13 +58,16 @@ public class GrpcTlsModel { * *

If omitted or null, system default certificate verification is used for secure connections. */ - @JsonProperty("ca_file") + @JsonProperty(CA_FILE) @Nullable public String getCaFile() { + if (caFile == null) { + return ExtensionPropertyUtil.getGraduated(CA_FILE, extensionProperties, String.class); + } return caFile; } - @JsonProperty("ca_file") + @JsonProperty(CA_FILE) public GrpcTlsModel withCaFile(String caFile) { this.caFile = caFile; return this; @@ -48,13 +81,16 @@ public GrpcTlsModel withCaFile(String caFile) { * *

If omitted or null, mTLS is not used. */ - @JsonProperty("key_file") + @JsonProperty(KEY_FILE) @Nullable public String getKeyFile() { + if (keyFile == null) { + return ExtensionPropertyUtil.getGraduated(KEY_FILE, extensionProperties, String.class); + } return keyFile; } - @JsonProperty("key_file") + @JsonProperty(KEY_FILE) public GrpcTlsModel withKeyFile(String keyFile) { this.keyFile = keyFile; return this; @@ -68,13 +104,16 @@ public GrpcTlsModel withKeyFile(String keyFile) { * *

If omitted or null, mTLS is not used. */ - @JsonProperty("cert_file") + @JsonProperty(CERT_FILE) @Nullable public String getCertFile() { + if (certFile == null) { + return ExtensionPropertyUtil.getGraduated(CERT_FILE, extensionProperties, String.class); + } return certFile; } - @JsonProperty("cert_file") + @JsonProperty(CERT_FILE) public GrpcTlsModel withCertFile(String certFile) { this.certFile = certFile; return this; @@ -88,18 +127,38 @@ public GrpcTlsModel withCertFile(String certFile) { * *

If omitted or null, false is used. */ - @JsonProperty("insecure") + @JsonProperty(INSECURE) @Nullable public Boolean getInsecure() { + if (insecure == null) { + return ExtensionPropertyUtil.getGraduated(INSECURE, extensionProperties, Boolean.class); + } return insecure; } - @JsonProperty("insecure") + @JsonProperty(INSECURE) public GrpcTlsModel withInsecure(Boolean insecure) { this.insecure = insecure; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public GrpcTlsModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "GrpcTlsModel{" @@ -111,6 +170,8 @@ public String toString() { + certFile + ", insecure=" + insecure + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -125,6 +186,8 @@ public int hashCode() { h ^= (this.certFile == null) ? 0 : this.certFile.hashCode(); h *= 1000003; h ^= (this.insecure == null) ? 0 : this.insecure.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -138,7 +201,10 @@ public boolean equals(@Nullable Object o) { return (this.caFile == null ? that.caFile == null : this.caFile.equals(that.caFile)) && (this.keyFile == null ? that.keyFile == null : this.keyFile.equals(that.keyFile)) && (this.certFile == null ? that.certFile == null : this.certFile.equals(that.certFile)) - && (this.insecure == null ? that.insecure == null : this.insecure.equals(that.insecure)); + && (this.insecure == null ? that.insecure == null : this.insecure.equals(that.insecure)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/HttpTlsModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/HttpTlsModel.java index b87893d3f0c..3d7f27590d8 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/HttpTlsModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/HttpTlsModel.java @@ -5,20 +5,47 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.HttpTlsModel.CA_FILE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.HttpTlsModel.CERT_FILE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.HttpTlsModel.KEY_FILE; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"ca_file", "key_file", "cert_file"}) +@JsonPropertyOrder({CA_FILE, KEY_FILE, CERT_FILE}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class HttpTlsModel { + static final String CA_FILE = "ca_file"; + static final String KEY_FILE = "key_file"; + static final String CERT_FILE = "cert_file"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(CA_FILE, String.class); + STABLE_PROPERTIES.put(KEY_FILE, String.class); + STABLE_PROPERTIES.put(CERT_FILE, String.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private String caFile; @Nullable private String keyFile; @Nullable private String certFile; + private Map extensionProperties = new LinkedHashMap(); /** * Configure certificate used to verify a server's TLS credentials. @@ -27,13 +54,16 @@ public class HttpTlsModel { * *

If omitted or null, system default certificate verification is used for secure connections. */ - @JsonProperty("ca_file") + @JsonProperty(CA_FILE) @Nullable public String getCaFile() { + if (caFile == null) { + return ExtensionPropertyUtil.getGraduated(CA_FILE, extensionProperties, String.class); + } return caFile; } - @JsonProperty("ca_file") + @JsonProperty(CA_FILE) public HttpTlsModel withCaFile(String caFile) { this.caFile = caFile; return this; @@ -47,13 +77,16 @@ public HttpTlsModel withCaFile(String caFile) { * *

If omitted or null, mTLS is not used. */ - @JsonProperty("key_file") + @JsonProperty(KEY_FILE) @Nullable public String getKeyFile() { + if (keyFile == null) { + return ExtensionPropertyUtil.getGraduated(KEY_FILE, extensionProperties, String.class); + } return keyFile; } - @JsonProperty("key_file") + @JsonProperty(KEY_FILE) public HttpTlsModel withKeyFile(String keyFile) { this.keyFile = keyFile; return this; @@ -67,18 +100,38 @@ public HttpTlsModel withKeyFile(String keyFile) { * *

If omitted or null, mTLS is not used. */ - @JsonProperty("cert_file") + @JsonProperty(CERT_FILE) @Nullable public String getCertFile() { + if (certFile == null) { + return ExtensionPropertyUtil.getGraduated(CERT_FILE, extensionProperties, String.class); + } return certFile; } - @JsonProperty("cert_file") + @JsonProperty(CERT_FILE) public HttpTlsModel withCertFile(String certFile) { this.certFile = certFile; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public HttpTlsModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "HttpTlsModel{" @@ -88,6 +141,8 @@ public String toString() { + keyFile + ", certFile=" + certFile + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -100,6 +155,8 @@ public int hashCode() { h ^= (this.keyFile == null) ? 0 : this.keyFile.hashCode(); h *= 1000003; h ^= (this.certFile == null) ? 0 : this.certFile.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -112,7 +169,10 @@ public boolean equals(@Nullable Object o) { HttpTlsModel that = (HttpTlsModel) o; return (this.caFile == null ? that.caFile == null : this.caFile.equals(that.caFile)) && (this.keyFile == null ? that.keyFile == null : this.keyFile.equals(that.keyFile)) - && (this.certFile == null ? that.certFile == null : this.certFile.equals(that.certFile)); + && (this.certFile == null ? that.certFile == null : this.certFile.equals(that.certFile)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/IdGeneratorModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/IdGeneratorModel.java index fb60f7df2ee..8b0cfcce916 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/IdGeneratorModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/IdGeneratorModel.java @@ -5,50 +5,75 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.IdGeneratorModel.RANDOM; + import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"random"}) +@JsonPropertyOrder({RANDOM}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class IdGeneratorModel { + static final String RANDOM = "random"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(RANDOM, RandomIdGeneratorModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = true; + @Nullable private RandomIdGeneratorModel random; - private Map additionalProperties = - new LinkedHashMap(); + private Map extensionProperties = new LinkedHashMap(); /** * Configure the ID generator to randomly generate TraceIds and SpanIds (spec default). * *

If omitted, ignore. */ - @JsonProperty("random") + @JsonProperty(RANDOM) @Nullable public RandomIdGeneratorModel getRandom() { + if (random == null) { + return ExtensionPropertyUtil.getGraduated( + RANDOM, extensionProperties, RandomIdGeneratorModel.class); + } return random; } - @JsonProperty("random") + @JsonProperty(RANDOM) public IdGeneratorModel withRandom(RandomIdGeneratorModel random) { this.random = random; return this; } @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); } @JsonAnySetter - public IdGeneratorModel withAdditionalProperty(String name, IdGeneratorPropertyModel value) { - this.additionalProperties.put(name, value); + public IdGeneratorModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); return this; } @@ -57,8 +82,8 @@ public String toString() { return "IdGeneratorModel{" + "random=" + random - + ", additionalProperties=" - + additionalProperties + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -68,7 +93,7 @@ public int hashCode() { h *= 1000003; h ^= (this.random == null) ? 0 : this.random.hashCode(); h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -80,9 +105,9 @@ public boolean equals(@Nullable Object o) { if (o instanceof IdGeneratorModel) { IdGeneratorModel that = (IdGeneratorModel) o; return (this.random == null ? that.random == null : this.random.equals(that.random)) - && (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/IdGeneratorPropertyModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/IdGeneratorPropertyModel.java deleted file mode 100644 index abb1bee2693..00000000000 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/IdGeneratorPropertyModel.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.util.LinkedHashMap; -import java.util.Map; -import javax.annotation.Generated; -import javax.annotation.Nullable; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({}) -@Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") -public class IdGeneratorPropertyModel { - - private Map additionalProperties = new LinkedHashMap(); - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public IdGeneratorPropertyModel withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - - @Override - public String toString() { - return "IdGeneratorPropertyModel{" + "additionalProperties=" + additionalProperties + "}"; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); - return h; - } - - @Override - public boolean equals(@Nullable Object o) { - if (o == this) { - return true; - } - if (o instanceof IdGeneratorPropertyModel) { - IdGeneratorPropertyModel that = (IdGeneratorPropertyModel) o; - return (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); - } - return false; - } -} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/IncludeExcludeModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/IncludeExcludeModel.java index 7f46b883948..a61bf4a573a 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/IncludeExcludeModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/IncludeExcludeModel.java @@ -5,6 +5,9 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.IncludeExcludeModel.EXCLUDED; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.IncludeExcludeModel.INCLUDED; + import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -13,10 +16,13 @@ import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"included", "excluded"}) +@JsonPropertyOrder({INCLUDED, EXCLUDED}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class IncludeExcludeModel { + static final String INCLUDED = "included"; + static final String EXCLUDED = "excluded"; + @Nullable private List included; @Nullable private List excluded; @@ -32,13 +38,13 @@ public class IncludeExcludeModel { * *

If omitted, all values are included. */ - @JsonProperty("included") + @JsonProperty(INCLUDED) @Nullable public List getIncluded() { return included; } - @JsonProperty("included") + @JsonProperty(INCLUDED) public IncludeExcludeModel withIncluded(List included) { this.included = included; return this; @@ -57,13 +63,13 @@ public IncludeExcludeModel withIncluded(List included) { * *

If omitted, .included attributes are included. */ - @JsonProperty("excluded") + @JsonProperty(EXCLUDED) @Nullable public List getExcluded() { return excluded; } - @JsonProperty("excluded") + @JsonProperty(EXCLUDED) public IncludeExcludeModel withExcluded(List excluded) { this.excluded = excluded; return this; diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LogRecordExporterModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LogRecordExporterModel.java index aa34ebe0f89..01b0a6b7c38 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LogRecordExporterModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LogRecordExporterModel.java @@ -5,41 +5,64 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LogRecordExporterModel.CONSOLE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LogRecordExporterModel.OTLP_GRPC; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LogRecordExporterModel.OTLP_HTTP; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.LogRecordExporterModelAccessor.EXPERIMENTAL_PROPERTIES; + import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalOtlpFileExporterModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"otlp_http", "otlp_grpc", "otlp_file/development", "console"}) +@JsonPropertyOrder({OTLP_HTTP, OTLP_GRPC, CONSOLE}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class LogRecordExporterModel { + static final String OTLP_HTTP = "otlp_http"; + static final String OTLP_GRPC = "otlp_grpc"; + static final String CONSOLE = "console"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(OTLP_HTTP, OtlpHttpExporterModel.class); + STABLE_PROPERTIES.put(OTLP_GRPC, OtlpGrpcExporterModel.class); + STABLE_PROPERTIES.put(CONSOLE, ConsoleExporterModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = true; + @Nullable private OtlpHttpExporterModel otlpHttp; @Nullable private OtlpGrpcExporterModel otlpGrpc; - @Nullable private ExperimentalOtlpFileExporterModel otlpFileDevelopment; @Nullable private ConsoleExporterModel console; - private Map additionalProperties = - new LinkedHashMap(); + private Map extensionProperties = new LinkedHashMap(); /** * Configure exporter to be OTLP with HTTP transport. * *

If omitted, ignore. */ - @JsonProperty("otlp_http") + @JsonProperty(OTLP_HTTP) @Nullable public OtlpHttpExporterModel getOtlpHttp() { + if (otlpHttp == null) { + return ExtensionPropertyUtil.getGraduated( + OTLP_HTTP, extensionProperties, OtlpHttpExporterModel.class); + } return otlpHttp; } - @JsonProperty("otlp_http") + @JsonProperty(OTLP_HTTP) public LogRecordExporterModel withOtlpHttp(OtlpHttpExporterModel otlpHttp) { this.otlpHttp = otlpHttp; return this; @@ -50,62 +73,57 @@ public LogRecordExporterModel withOtlpHttp(OtlpHttpExporterModel otlpHttp) { * *

If omitted, ignore. */ - @JsonProperty("otlp_grpc") + @JsonProperty(OTLP_GRPC) @Nullable public OtlpGrpcExporterModel getOtlpGrpc() { + if (otlpGrpc == null) { + return ExtensionPropertyUtil.getGraduated( + OTLP_GRPC, extensionProperties, OtlpGrpcExporterModel.class); + } return otlpGrpc; } - @JsonProperty("otlp_grpc") + @JsonProperty(OTLP_GRPC) public LogRecordExporterModel withOtlpGrpc(OtlpGrpcExporterModel otlpGrpc) { this.otlpGrpc = otlpGrpc; return this; } - /** - * Configure exporter to be OTLP with file transport. - * - *

If omitted, ignore. - */ - @JsonProperty("otlp_file/development") - @Nullable - public ExperimentalOtlpFileExporterModel getOtlpFileDevelopment() { - return otlpFileDevelopment; - } - - @JsonProperty("otlp_file/development") - public LogRecordExporterModel withOtlpFileDevelopment( - ExperimentalOtlpFileExporterModel otlpFileDevelopment) { - this.otlpFileDevelopment = otlpFileDevelopment; - return this; - } - /** * Configure exporter to be console. * *

If omitted, ignore. */ - @JsonProperty("console") + @JsonProperty(CONSOLE) @Nullable public ConsoleExporterModel getConsole() { + if (console == null) { + return ExtensionPropertyUtil.getGraduated( + CONSOLE, extensionProperties, ConsoleExporterModel.class); + } return console; } - @JsonProperty("console") + @JsonProperty(CONSOLE) public LogRecordExporterModel withConsole(ConsoleExporterModel console) { this.console = console; return this; } @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); } @JsonAnySetter - public LogRecordExporterModel withAdditionalProperty( - String name, LogRecordExporterPropertyModel value) { - this.additionalProperties.put(name, value); + public LogRecordExporterModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + EXPERIMENTAL_PROPERTIES, + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); return this; } @@ -116,12 +134,10 @@ public String toString() { + otlpHttp + ", otlpGrpc=" + otlpGrpc - + ", otlpFileDevelopment=" - + otlpFileDevelopment + ", console=" + console - + ", additionalProperties=" - + additionalProperties + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -133,11 +149,9 @@ public int hashCode() { h *= 1000003; h ^= (this.otlpGrpc == null) ? 0 : this.otlpGrpc.hashCode(); h *= 1000003; - h ^= (this.otlpFileDevelopment == null) ? 0 : this.otlpFileDevelopment.hashCode(); - h *= 1000003; h ^= (this.console == null) ? 0 : this.console.hashCode(); h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -150,13 +164,10 @@ public boolean equals(@Nullable Object o) { LogRecordExporterModel that = (LogRecordExporterModel) o; return (this.otlpHttp == null ? that.otlpHttp == null : this.otlpHttp.equals(that.otlpHttp)) && (this.otlpGrpc == null ? that.otlpGrpc == null : this.otlpGrpc.equals(that.otlpGrpc)) - && (this.otlpFileDevelopment == null - ? that.otlpFileDevelopment == null - : this.otlpFileDevelopment.equals(that.otlpFileDevelopment)) && (this.console == null ? that.console == null : this.console.equals(that.console)) - && (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LogRecordExporterPropertyModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LogRecordExporterPropertyModel.java deleted file mode 100644 index 5a462047081..00000000000 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LogRecordExporterPropertyModel.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.util.LinkedHashMap; -import java.util.Map; -import javax.annotation.Generated; -import javax.annotation.Nullable; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({}) -@Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") -public class LogRecordExporterPropertyModel { - - private Map additionalProperties = new LinkedHashMap(); - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public LogRecordExporterPropertyModel withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - - @Override - public String toString() { - return "LogRecordExporterPropertyModel{" + "additionalProperties=" + additionalProperties + "}"; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); - return h; - } - - @Override - public boolean equals(@Nullable Object o) { - if (o == this) { - return true; - } - if (o instanceof LogRecordExporterPropertyModel) { - LogRecordExporterPropertyModel that = (LogRecordExporterPropertyModel) o; - return (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); - } - return false; - } -} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LogRecordLimitsModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LogRecordLimitsModel.java index 24e13258133..e2319a88847 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LogRecordLimitsModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LogRecordLimitsModel.java @@ -5,19 +5,43 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LogRecordLimitsModel.ATTRIBUTE_COUNT_LIMIT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LogRecordLimitsModel.ATTRIBUTE_VALUE_LENGTH_LIMIT; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"attribute_value_length_limit", "attribute_count_limit"}) +@JsonPropertyOrder({ATTRIBUTE_VALUE_LENGTH_LIMIT, ATTRIBUTE_COUNT_LIMIT}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class LogRecordLimitsModel { + static final String ATTRIBUTE_VALUE_LENGTH_LIMIT = "attribute_value_length_limit"; + static final String ATTRIBUTE_COUNT_LIMIT = "attribute_count_limit"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(ATTRIBUTE_VALUE_LENGTH_LIMIT, Integer.class); + STABLE_PROPERTIES.put(ATTRIBUTE_COUNT_LIMIT, Integer.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private Integer attributeValueLengthLimit; @Nullable private Integer attributeCountLimit; + private Map extensionProperties = new LinkedHashMap(); /** * Configure max attribute value size. Overrides .attribute_limits.attribute_value_length_limit. @@ -26,13 +50,17 @@ public class LogRecordLimitsModel { * *

If omitted or null, there is no limit. */ - @JsonProperty("attribute_value_length_limit") + @JsonProperty(ATTRIBUTE_VALUE_LENGTH_LIMIT) @Nullable public Integer getAttributeValueLengthLimit() { + if (attributeValueLengthLimit == null) { + return ExtensionPropertyUtil.getGraduated( + ATTRIBUTE_VALUE_LENGTH_LIMIT, extensionProperties, Integer.class); + } return attributeValueLengthLimit; } - @JsonProperty("attribute_value_length_limit") + @JsonProperty(ATTRIBUTE_VALUE_LENGTH_LIMIT) public LogRecordLimitsModel withAttributeValueLengthLimit(Integer attributeValueLengthLimit) { this.attributeValueLengthLimit = attributeValueLengthLimit; return this; @@ -45,18 +73,39 @@ public LogRecordLimitsModel withAttributeValueLengthLimit(Integer attributeValue * *

If omitted or null, 128 is used. */ - @JsonProperty("attribute_count_limit") + @JsonProperty(ATTRIBUTE_COUNT_LIMIT) @Nullable public Integer getAttributeCountLimit() { + if (attributeCountLimit == null) { + return ExtensionPropertyUtil.getGraduated( + ATTRIBUTE_COUNT_LIMIT, extensionProperties, Integer.class); + } return attributeCountLimit; } - @JsonProperty("attribute_count_limit") + @JsonProperty(ATTRIBUTE_COUNT_LIMIT) public LogRecordLimitsModel withAttributeCountLimit(Integer attributeCountLimit) { this.attributeCountLimit = attributeCountLimit; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public LogRecordLimitsModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "LogRecordLimitsModel{" @@ -64,6 +113,8 @@ public String toString() { + attributeValueLengthLimit + ", attributeCountLimit=" + attributeCountLimit + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -74,6 +125,8 @@ public int hashCode() { h ^= (this.attributeValueLengthLimit == null) ? 0 : this.attributeValueLengthLimit.hashCode(); h *= 1000003; h ^= (this.attributeCountLimit == null) ? 0 : this.attributeCountLimit.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -89,7 +142,10 @@ public boolean equals(@Nullable Object o) { : this.attributeValueLengthLimit.equals(that.attributeValueLengthLimit)) && (this.attributeCountLimit == null ? that.attributeCountLimit == null - : this.attributeCountLimit.equals(that.attributeCountLimit)); + : this.attributeCountLimit.equals(that.attributeCountLimit)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LogRecordProcessorModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LogRecordProcessorModel.java index f20ebdd30f2..1f3bc89ba8d 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LogRecordProcessorModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LogRecordProcessorModel.java @@ -5,44 +5,60 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LogRecordProcessorModel.BATCH; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LogRecordProcessorModel.SIMPLE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.LogRecordProcessorModelAccessor.EXPERIMENTAL_PROPERTIES; + import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalEventToSpanEventBridgeLogRecordProcessorModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"batch", "simple", "event_to_span_event_bridge/development"}) +@JsonPropertyOrder({BATCH, SIMPLE}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class LogRecordProcessorModel { - @Nullable private BatchLogRecordProcessorModel batch; - @Nullable private SimpleLogRecordProcessorModel simple; + static final String BATCH = "batch"; + static final String SIMPLE = "simple"; - @Nullable - private ExperimentalEventToSpanEventBridgeLogRecordProcessorModel - eventToSpanEventBridgeDevelopment; + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(BATCH, BatchLogRecordProcessorModel.class); + STABLE_PROPERTIES.put(SIMPLE, SimpleLogRecordProcessorModel.class); + } - private Map additionalProperties = - new LinkedHashMap(); + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = true; + + @Nullable private BatchLogRecordProcessorModel batch; + @Nullable private SimpleLogRecordProcessorModel simple; + private Map extensionProperties = new LinkedHashMap(); /** * Configure a batch log record processor. * *

If omitted, ignore. */ - @JsonProperty("batch") + @JsonProperty(BATCH) @Nullable public BatchLogRecordProcessorModel getBatch() { + if (batch == null) { + return ExtensionPropertyUtil.getGraduated( + BATCH, extensionProperties, BatchLogRecordProcessorModel.class); + } return batch; } - @JsonProperty("batch") + @JsonProperty(BATCH) public LogRecordProcessorModel withBatch(BatchLogRecordProcessorModel batch) { this.batch = batch; return this; @@ -53,46 +69,36 @@ public LogRecordProcessorModel withBatch(BatchLogRecordProcessorModel batch) { * *

If omitted, ignore. */ - @JsonProperty("simple") + @JsonProperty(SIMPLE) @Nullable public SimpleLogRecordProcessorModel getSimple() { + if (simple == null) { + return ExtensionPropertyUtil.getGraduated( + SIMPLE, extensionProperties, SimpleLogRecordProcessorModel.class); + } return simple; } - @JsonProperty("simple") + @JsonProperty(SIMPLE) public LogRecordProcessorModel withSimple(SimpleLogRecordProcessorModel simple) { this.simple = simple; return this; } - /** - * Configure an event to span event bridge log record processor. - * - *

If omitted, ignore. - */ - @JsonProperty("event_to_span_event_bridge/development") - @Nullable - public ExperimentalEventToSpanEventBridgeLogRecordProcessorModel - getEventToSpanEventBridgeDevelopment() { - return eventToSpanEventBridgeDevelopment; - } - - @JsonProperty("event_to_span_event_bridge/development") - public LogRecordProcessorModel withEventToSpanEventBridgeDevelopment( - ExperimentalEventToSpanEventBridgeLogRecordProcessorModel eventToSpanEventBridgeDevelopment) { - this.eventToSpanEventBridgeDevelopment = eventToSpanEventBridgeDevelopment; - return this; - } - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); } @JsonAnySetter - public LogRecordProcessorModel withAdditionalProperty( - String name, LogRecordProcessorPropertyModel value) { - this.additionalProperties.put(name, value); + public LogRecordProcessorModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + EXPERIMENTAL_PROPERTIES, + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); return this; } @@ -103,10 +109,8 @@ public String toString() { + batch + ", simple=" + simple - + ", eventToSpanEventBridgeDevelopment=" - + eventToSpanEventBridgeDevelopment - + ", additionalProperties=" - + additionalProperties + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -118,12 +122,7 @@ public int hashCode() { h *= 1000003; h ^= (this.simple == null) ? 0 : this.simple.hashCode(); h *= 1000003; - h ^= - (this.eventToSpanEventBridgeDevelopment == null) - ? 0 - : this.eventToSpanEventBridgeDevelopment.hashCode(); - h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -136,13 +135,9 @@ public boolean equals(@Nullable Object o) { LogRecordProcessorModel that = (LogRecordProcessorModel) o; return (this.batch == null ? that.batch == null : this.batch.equals(that.batch)) && (this.simple == null ? that.simple == null : this.simple.equals(that.simple)) - && (this.eventToSpanEventBridgeDevelopment == null - ? that.eventToSpanEventBridgeDevelopment == null - : this.eventToSpanEventBridgeDevelopment.equals( - that.eventToSpanEventBridgeDevelopment)) - && (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LogRecordProcessorPropertyModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LogRecordProcessorPropertyModel.java deleted file mode 100644 index 5ebf23bc184..00000000000 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LogRecordProcessorPropertyModel.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.util.LinkedHashMap; -import java.util.Map; -import javax.annotation.Generated; -import javax.annotation.Nullable; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({}) -@Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") -public class LogRecordProcessorPropertyModel { - - private Map additionalProperties = new LinkedHashMap(); - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public LogRecordProcessorPropertyModel withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - - @Override - public String toString() { - return "LogRecordProcessorPropertyModel{" - + "additionalProperties=" - + additionalProperties - + "}"; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); - return h; - } - - @Override - public boolean equals(@Nullable Object o) { - if (o == this) { - return true; - } - if (o instanceof LogRecordProcessorPropertyModel) { - LogRecordProcessorPropertyModel that = (LogRecordProcessorPropertyModel) o; - return (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); - } - return false; - } -} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LoggerProviderModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LoggerProviderModel.java index ae5a722a1fe..22212329d0d 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LoggerProviderModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/LoggerProviderModel.java @@ -5,35 +5,56 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LoggerProviderModel.LIMITS; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LoggerProviderModel.PROCESSORS; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.LoggerProviderModelAccessor.EXPERIMENTAL_PROPERTIES; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalLoggerConfiguratorModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"processors", "limits", "logger_configurator/development"}) +@JsonPropertyOrder({PROCESSORS, LIMITS}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class LoggerProviderModel { + static final String PROCESSORS = "processors"; + static final String LIMITS = "limits"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(LIMITS, LogRecordLimitsModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private List processors; @Nullable private LogRecordLimitsModel limits; - @Nullable private ExperimentalLoggerConfiguratorModel loggerConfiguratorDevelopment; + private Map extensionProperties = new LinkedHashMap(); /** * Configure log record processors. * *

Property is required and must be non-null. */ - @JsonProperty("processors") + @JsonProperty(PROCESSORS) @Nullable public List getProcessors() { return processors; } - @JsonProperty("processors") + @JsonProperty(PROCESSORS) public LoggerProviderModel withProcessors(List processors) { this.processors = processors; return this; @@ -44,33 +65,36 @@ public LoggerProviderModel withProcessors(List processo * *

If omitted, default values as described in LogRecordLimits are used. */ - @JsonProperty("limits") + @JsonProperty(LIMITS) @Nullable public LogRecordLimitsModel getLimits() { + if (limits == null) { + return ExtensionPropertyUtil.getGraduated( + LIMITS, extensionProperties, LogRecordLimitsModel.class); + } return limits; } - @JsonProperty("limits") + @JsonProperty(LIMITS) public LoggerProviderModel withLimits(LogRecordLimitsModel limits) { this.limits = limits; return this; } - /** - * Configure loggers. - * - *

If omitted, all loggers use default values as described in ExperimentalLoggerConfig. - */ - @JsonProperty("logger_configurator/development") - @Nullable - public ExperimentalLoggerConfiguratorModel getLoggerConfiguratorDevelopment() { - return loggerConfiguratorDevelopment; + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); } - @JsonProperty("logger_configurator/development") - public LoggerProviderModel withLoggerConfiguratorDevelopment( - ExperimentalLoggerConfiguratorModel loggerConfiguratorDevelopment) { - this.loggerConfiguratorDevelopment = loggerConfiguratorDevelopment; + @JsonAnySetter + public LoggerProviderModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + EXPERIMENTAL_PROPERTIES, + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); return this; } @@ -81,8 +105,8 @@ public String toString() { + processors + ", limits=" + limits - + ", loggerConfiguratorDevelopment=" - + loggerConfiguratorDevelopment + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -94,10 +118,7 @@ public int hashCode() { h *= 1000003; h ^= (this.limits == null) ? 0 : this.limits.hashCode(); h *= 1000003; - h ^= - (this.loggerConfiguratorDevelopment == null) - ? 0 - : this.loggerConfiguratorDevelopment.hashCode(); + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -112,9 +133,9 @@ public boolean equals(@Nullable Object o) { ? that.processors == null : this.processors.equals(that.processors)) && (this.limits == null ? that.limits == null : this.limits.equals(that.limits)) - && (this.loggerConfiguratorDevelopment == null - ? that.loggerConfiguratorDevelopment == null - : this.loggerConfiguratorDevelopment.equals(that.loggerConfiguratorDevelopment)); + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/MeterProviderModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/MeterProviderModel.java index 0bb90d10df6..8cc2e784413 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/MeterProviderModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/MeterProviderModel.java @@ -5,36 +5,59 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.MeterProviderModel.EXEMPLAR_FILTER; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.MeterProviderModel.READERS; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.MeterProviderModel.VIEWS; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.MeterProviderModelAccessor.EXPERIMENTAL_PROPERTIES; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalMeterConfiguratorModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"readers", "views", "exemplar_filter", "meter_configurator/development"}) +@JsonPropertyOrder({READERS, VIEWS, EXEMPLAR_FILTER}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class MeterProviderModel { + static final String READERS = "readers"; + static final String VIEWS = "views"; + static final String EXEMPLAR_FILTER = "exemplar_filter"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(EXEMPLAR_FILTER, ExemplarFilterModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private List readers; @Nullable private List views; @Nullable private ExemplarFilterModel exemplarFilter; - @Nullable private ExperimentalMeterConfiguratorModel meterConfiguratorDevelopment; + private Map extensionProperties = new LinkedHashMap(); /** * Configure metric readers. * *

Property is required and must be non-null. */ - @JsonProperty("readers") + @JsonProperty(READERS) @Nullable public List getReaders() { return readers; } - @JsonProperty("readers") + @JsonProperty(READERS) public MeterProviderModel withReaders(List readers) { this.readers = readers; return this; @@ -48,13 +71,13 @@ public MeterProviderModel withReaders(List readers) { * *

If omitted, no views are registered. */ - @JsonProperty("views") + @JsonProperty(VIEWS) @Nullable public List getViews() { return views; } - @JsonProperty("views") + @JsonProperty(VIEWS) public MeterProviderModel withViews(List views) { this.views = views; return this; @@ -74,33 +97,36 @@ public MeterProviderModel withViews(List views) { * *

If omitted, trace_based is used. */ - @JsonProperty("exemplar_filter") + @JsonProperty(EXEMPLAR_FILTER) @Nullable public ExemplarFilterModel getExemplarFilter() { + if (exemplarFilter == null) { + return ExtensionPropertyUtil.getGraduated( + EXEMPLAR_FILTER, extensionProperties, ExemplarFilterModel.class); + } return exemplarFilter; } - @JsonProperty("exemplar_filter") + @JsonProperty(EXEMPLAR_FILTER) public MeterProviderModel withExemplarFilter(ExemplarFilterModel exemplarFilter) { this.exemplarFilter = exemplarFilter; return this; } - /** - * Configure meters. - * - *

If omitted, all meters use default values as described in ExperimentalMeterConfig. - */ - @JsonProperty("meter_configurator/development") - @Nullable - public ExperimentalMeterConfiguratorModel getMeterConfiguratorDevelopment() { - return meterConfiguratorDevelopment; + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); } - @JsonProperty("meter_configurator/development") - public MeterProviderModel withMeterConfiguratorDevelopment( - ExperimentalMeterConfiguratorModel meterConfiguratorDevelopment) { - this.meterConfiguratorDevelopment = meterConfiguratorDevelopment; + @JsonAnySetter + public MeterProviderModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + EXPERIMENTAL_PROPERTIES, + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); return this; } @@ -113,8 +139,8 @@ public String toString() { + views + ", exemplarFilter=" + exemplarFilter - + ", meterConfiguratorDevelopment=" - + meterConfiguratorDevelopment + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -128,10 +154,7 @@ public int hashCode() { h *= 1000003; h ^= (this.exemplarFilter == null) ? 0 : this.exemplarFilter.hashCode(); h *= 1000003; - h ^= - (this.meterConfiguratorDevelopment == null) - ? 0 - : this.meterConfiguratorDevelopment.hashCode(); + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -147,9 +170,9 @@ public boolean equals(@Nullable Object o) { && (this.exemplarFilter == null ? that.exemplarFilter == null : this.exemplarFilter.equals(that.exemplarFilter)) - && (this.meterConfiguratorDevelopment == null - ? that.meterConfiguratorDevelopment == null - : this.meterConfiguratorDevelopment.equals(that.meterConfiguratorDevelopment)); + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/MetricProducerModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/MetricProducerModel.java index ca6109b59b1..1c80bc704c5 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/MetricProducerModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/MetricProducerModel.java @@ -5,51 +5,75 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.MetricProducerModel.OPENCENSUS; + import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"opencensus"}) +@JsonPropertyOrder({OPENCENSUS}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class MetricProducerModel { + static final String OPENCENSUS = "opencensus"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(OPENCENSUS, OpenCensusMetricProducerModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = true; + @Nullable private OpenCensusMetricProducerModel opencensus; - private Map additionalProperties = - new LinkedHashMap(); + private Map extensionProperties = new LinkedHashMap(); /** * Configure metric producer to be opencensus. * *

If omitted, ignore. */ - @JsonProperty("opencensus") + @JsonProperty(OPENCENSUS) @Nullable public OpenCensusMetricProducerModel getOpencensus() { + if (opencensus == null) { + return ExtensionPropertyUtil.getGraduated( + OPENCENSUS, extensionProperties, OpenCensusMetricProducerModel.class); + } return opencensus; } - @JsonProperty("opencensus") + @JsonProperty(OPENCENSUS) public MetricProducerModel withOpencensus(OpenCensusMetricProducerModel opencensus) { this.opencensus = opencensus; return this; } @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); } @JsonAnySetter - public MetricProducerModel withAdditionalProperty( - String name, MetricProducerPropertyModel value) { - this.additionalProperties.put(name, value); + public MetricProducerModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); return this; } @@ -58,8 +82,8 @@ public String toString() { return "MetricProducerModel{" + "opencensus=" + opencensus - + ", additionalProperties=" - + additionalProperties + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -69,7 +93,7 @@ public int hashCode() { h *= 1000003; h ^= (this.opencensus == null) ? 0 : this.opencensus.hashCode(); h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -83,9 +107,9 @@ public boolean equals(@Nullable Object o) { return (this.opencensus == null ? that.opencensus == null : this.opencensus.equals(that.opencensus)) - && (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/MetricProducerPropertyModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/MetricProducerPropertyModel.java deleted file mode 100644 index 0155f409308..00000000000 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/MetricProducerPropertyModel.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.util.LinkedHashMap; -import java.util.Map; -import javax.annotation.Generated; -import javax.annotation.Nullable; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({}) -@Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") -public class MetricProducerPropertyModel { - - private Map additionalProperties = new LinkedHashMap(); - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public MetricProducerPropertyModel withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - - @Override - public String toString() { - return "MetricProducerPropertyModel{" + "additionalProperties=" + additionalProperties + "}"; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); - return h; - } - - @Override - public boolean equals(@Nullable Object o) { - if (o == this) { - return true; - } - if (o instanceof MetricProducerPropertyModel) { - MetricProducerPropertyModel that = (MetricProducerPropertyModel) o; - return (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); - } - return false; - } -} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/MetricReaderModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/MetricReaderModel.java index 8ff3ab90743..18ce4d78b4c 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/MetricReaderModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/MetricReaderModel.java @@ -5,32 +5,60 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.MetricReaderModel.PERIODIC; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.MetricReaderModel.PULL; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"periodic", "pull"}) +@JsonPropertyOrder({PERIODIC, PULL}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class MetricReaderModel { + static final String PERIODIC = "periodic"; + static final String PULL = "pull"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(PERIODIC, PeriodicMetricReaderModel.class); + STABLE_PROPERTIES.put(PULL, PullMetricReaderModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private PeriodicMetricReaderModel periodic; @Nullable private PullMetricReaderModel pull; + private Map extensionProperties = new LinkedHashMap(); /** * Configure a periodic metric reader. * *

If omitted, ignore. */ - @JsonProperty("periodic") + @JsonProperty(PERIODIC) @Nullable public PeriodicMetricReaderModel getPeriodic() { + if (periodic == null) { + return ExtensionPropertyUtil.getGraduated( + PERIODIC, extensionProperties, PeriodicMetricReaderModel.class); + } return periodic; } - @JsonProperty("periodic") + @JsonProperty(PERIODIC) public MetricReaderModel withPeriodic(PeriodicMetricReaderModel periodic) { this.periodic = periodic; return this; @@ -41,21 +69,49 @@ public MetricReaderModel withPeriodic(PeriodicMetricReaderModel periodic) { * *

If omitted, ignore. */ - @JsonProperty("pull") + @JsonProperty(PULL) @Nullable public PullMetricReaderModel getPull() { + if (pull == null) { + return ExtensionPropertyUtil.getGraduated( + PULL, extensionProperties, PullMetricReaderModel.class); + } return pull; } - @JsonProperty("pull") + @JsonProperty(PULL) public MetricReaderModel withPull(PullMetricReaderModel pull) { this.pull = pull; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public MetricReaderModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { - return "MetricReaderModel{" + "periodic=" + periodic + ", pull=" + pull + "}"; + return "MetricReaderModel{" + + "periodic=" + + periodic + + ", pull=" + + pull + + ", extensionProperties=" + + extensionProperties + + "}"; } @Override @@ -65,6 +121,8 @@ public int hashCode() { h ^= (this.periodic == null) ? 0 : this.periodic.hashCode(); h *= 1000003; h ^= (this.pull == null) ? 0 : this.pull.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -76,7 +134,10 @@ public boolean equals(@Nullable Object o) { if (o instanceof MetricReaderModel) { MetricReaderModel that = (MetricReaderModel) o; return (this.periodic == null ? that.periodic == null : this.periodic.equals(that.periodic)) - && (this.pull == null ? that.pull == null : this.pull.equals(that.pull)); + && (this.pull == null ? that.pull == null : this.pull.equals(that.pull)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/NameStringValuePairModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/NameStringValuePairModel.java index 87c62310810..7158d6e375b 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/NameStringValuePairModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/NameStringValuePairModel.java @@ -5,32 +5,59 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.NameStringValuePairModel.NAME; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.NameStringValuePairModel.VALUE; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"name", "value"}) +@JsonPropertyOrder({NAME, VALUE}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class NameStringValuePairModel { + static final String NAME = "name"; + static final String VALUE = "value"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(NAME, String.class); + STABLE_PROPERTIES.put(VALUE, String.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private String name; @Nullable private String value; + private Map extensionProperties = new LinkedHashMap(); /** * The name of the pair. * *

Property is required and must be non-null. */ - @JsonProperty("name") + @JsonProperty(NAME) @Nullable public String getName() { + if (name == null) { + return ExtensionPropertyUtil.getGraduated(NAME, extensionProperties, String.class); + } return name; } - @JsonProperty("name") + @JsonProperty(NAME) public NameStringValuePairModel withName(String name) { this.name = name; return this; @@ -41,21 +68,48 @@ public NameStringValuePairModel withName(String name) { * *

Property must be present, but if null the behavior is dependent on usage context. */ - @JsonProperty("value") + @JsonProperty(VALUE) @Nullable public String getValue() { + if (value == null) { + return ExtensionPropertyUtil.getGraduated(VALUE, extensionProperties, String.class); + } return value; } - @JsonProperty("value") + @JsonProperty(VALUE) public NameStringValuePairModel withValue(String value) { this.value = value; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public NameStringValuePairModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { - return "NameStringValuePairModel{" + "name=" + name + ", value=" + value + "}"; + return "NameStringValuePairModel{" + + "name=" + + name + + ", value=" + + value + + ", extensionProperties=" + + extensionProperties + + "}"; } @Override @@ -65,6 +119,8 @@ public int hashCode() { h ^= (this.name == null) ? 0 : this.name.hashCode(); h *= 1000003; h ^= (this.value == null) ? 0 : this.value.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -76,7 +132,10 @@ public boolean equals(@Nullable Object o) { if (o instanceof NameStringValuePairModel) { NameStringValuePairModel that = (NameStringValuePairModel) o; return (this.name == null ? that.name == null : this.name.equals(that.name)) - && (this.value == null ? that.value == null : this.value.equals(that.value)); + && (this.value == null ? that.value == null : this.value.equals(that.value)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/OpenTelemetryConfigurationModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/OpenTelemetryConfigurationModel.java index 1e73faf5968..8e1bff18318 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/OpenTelemetryConfigurationModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/OpenTelemetryConfigurationModel.java @@ -5,12 +5,25 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OpenTelemetryConfigurationModel.ATTRIBUTE_LIMITS; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OpenTelemetryConfigurationModel.DISABLED; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OpenTelemetryConfigurationModel.DISTRIBUTION; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OpenTelemetryConfigurationModel.FILE_FORMAT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OpenTelemetryConfigurationModel.LOGGER_PROVIDER; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OpenTelemetryConfigurationModel.LOG_LEVEL; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OpenTelemetryConfigurationModel.METER_PROVIDER; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OpenTelemetryConfigurationModel.PROPAGATOR; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OpenTelemetryConfigurationModel.RESOURCE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OpenTelemetryConfigurationModel.TRACER_PROVIDER; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.OpenTelemetryConfigurationModelAccessor.EXPERIMENTAL_PROPERTIES; + import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalInstrumentationModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import javax.annotation.Generated; @@ -18,21 +31,49 @@ @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ - "file_format", - "disabled", - "log_level", - "attribute_limits", - "logger_provider", - "meter_provider", - "propagator", - "tracer_provider", - "resource", - "instrumentation/development", - "distribution" + FILE_FORMAT, + DISABLED, + LOG_LEVEL, + ATTRIBUTE_LIMITS, + LOGGER_PROVIDER, + METER_PROVIDER, + PROPAGATOR, + TRACER_PROVIDER, + RESOURCE, + DISTRIBUTION }) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class OpenTelemetryConfigurationModel { + static final String FILE_FORMAT = "file_format"; + static final String DISABLED = "disabled"; + static final String LOG_LEVEL = "log_level"; + static final String ATTRIBUTE_LIMITS = "attribute_limits"; + static final String LOGGER_PROVIDER = "logger_provider"; + static final String METER_PROVIDER = "meter_provider"; + static final String PROPAGATOR = "propagator"; + static final String TRACER_PROVIDER = "tracer_provider"; + static final String RESOURCE = "resource"; + static final String DISTRIBUTION = "distribution"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(FILE_FORMAT, String.class); + STABLE_PROPERTIES.put(DISABLED, Boolean.class); + STABLE_PROPERTIES.put(LOG_LEVEL, SeverityNumberModel.class); + STABLE_PROPERTIES.put(ATTRIBUTE_LIMITS, AttributeLimitsModel.class); + STABLE_PROPERTIES.put(LOGGER_PROVIDER, LoggerProviderModel.class); + STABLE_PROPERTIES.put(METER_PROVIDER, MeterProviderModel.class); + STABLE_PROPERTIES.put(PROPAGATOR, PropagatorModel.class); + STABLE_PROPERTIES.put(TRACER_PROVIDER, TracerProviderModel.class); + STABLE_PROPERTIES.put(RESOURCE, ResourceModel.class); + STABLE_PROPERTIES.put(DISTRIBUTION, DistributionModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = true; + @Nullable private String fileFormat; @Nullable private Boolean disabled; @Nullable private SeverityNumberModel logLevel; @@ -42,9 +83,8 @@ public class OpenTelemetryConfigurationModel { @Nullable private PropagatorModel propagator; @Nullable private TracerProviderModel tracerProvider; @Nullable private ResourceModel resource; - @Nullable private ExperimentalInstrumentationModel instrumentationDevelopment; @Nullable private DistributionModel distribution; - private Map additionalProperties = new LinkedHashMap(); + private Map extensionProperties = new LinkedHashMap(); /** * The file format version. @@ -60,13 +100,16 @@ public class OpenTelemetryConfigurationModel { * *

Property is required and must be non-null. */ - @JsonProperty("file_format") + @JsonProperty(FILE_FORMAT) @Nullable public String getFileFormat() { + if (fileFormat == null) { + return ExtensionPropertyUtil.getGraduated(FILE_FORMAT, extensionProperties, String.class); + } return fileFormat; } - @JsonProperty("file_format") + @JsonProperty(FILE_FORMAT) public OpenTelemetryConfigurationModel withFileFormat(String fileFormat) { this.fileFormat = fileFormat; return this; @@ -77,13 +120,16 @@ public OpenTelemetryConfigurationModel withFileFormat(String fileFormat) { * *

If omitted or null, false is used. */ - @JsonProperty("disabled") + @JsonProperty(DISABLED) @Nullable public Boolean getDisabled() { + if (disabled == null) { + return ExtensionPropertyUtil.getGraduated(DISABLED, extensionProperties, Boolean.class); + } return disabled; } - @JsonProperty("disabled") + @JsonProperty(DISABLED) public OpenTelemetryConfigurationModel withDisabled(Boolean disabled) { this.disabled = disabled; return this; @@ -144,13 +190,17 @@ public OpenTelemetryConfigurationModel withDisabled(Boolean disabled) { * *

If omitted, INFO is used. */ - @JsonProperty("log_level") + @JsonProperty(LOG_LEVEL) @Nullable public SeverityNumberModel getLogLevel() { + if (logLevel == null) { + return ExtensionPropertyUtil.getGraduated( + LOG_LEVEL, extensionProperties, SeverityNumberModel.class); + } return logLevel; } - @JsonProperty("log_level") + @JsonProperty(LOG_LEVEL) public OpenTelemetryConfigurationModel withLogLevel(SeverityNumberModel logLevel) { this.logLevel = logLevel; return this; @@ -161,13 +211,17 @@ public OpenTelemetryConfigurationModel withLogLevel(SeverityNumberModel logLevel * *

If omitted, default values as described in AttributeLimits are used. */ - @JsonProperty("attribute_limits") + @JsonProperty(ATTRIBUTE_LIMITS) @Nullable public AttributeLimitsModel getAttributeLimits() { + if (attributeLimits == null) { + return ExtensionPropertyUtil.getGraduated( + ATTRIBUTE_LIMITS, extensionProperties, AttributeLimitsModel.class); + } return attributeLimits; } - @JsonProperty("attribute_limits") + @JsonProperty(ATTRIBUTE_LIMITS) public OpenTelemetryConfigurationModel withAttributeLimits(AttributeLimitsModel attributeLimits) { this.attributeLimits = attributeLimits; return this; @@ -178,13 +232,17 @@ public OpenTelemetryConfigurationModel withAttributeLimits(AttributeLimitsModel * *

If omitted, a noop logger provider is used. */ - @JsonProperty("logger_provider") + @JsonProperty(LOGGER_PROVIDER) @Nullable public LoggerProviderModel getLoggerProvider() { + if (loggerProvider == null) { + return ExtensionPropertyUtil.getGraduated( + LOGGER_PROVIDER, extensionProperties, LoggerProviderModel.class); + } return loggerProvider; } - @JsonProperty("logger_provider") + @JsonProperty(LOGGER_PROVIDER) public OpenTelemetryConfigurationModel withLoggerProvider(LoggerProviderModel loggerProvider) { this.loggerProvider = loggerProvider; return this; @@ -195,13 +253,17 @@ public OpenTelemetryConfigurationModel withLoggerProvider(LoggerProviderModel lo * *

If omitted, a noop meter provider is used. */ - @JsonProperty("meter_provider") + @JsonProperty(METER_PROVIDER) @Nullable public MeterProviderModel getMeterProvider() { + if (meterProvider == null) { + return ExtensionPropertyUtil.getGraduated( + METER_PROVIDER, extensionProperties, MeterProviderModel.class); + } return meterProvider; } - @JsonProperty("meter_provider") + @JsonProperty(METER_PROVIDER) public OpenTelemetryConfigurationModel withMeterProvider(MeterProviderModel meterProvider) { this.meterProvider = meterProvider; return this; @@ -212,13 +274,17 @@ public OpenTelemetryConfigurationModel withMeterProvider(MeterProviderModel mete * *

If omitted, a noop propagator is used. */ - @JsonProperty("propagator") + @JsonProperty(PROPAGATOR) @Nullable public PropagatorModel getPropagator() { + if (propagator == null) { + return ExtensionPropertyUtil.getGraduated( + PROPAGATOR, extensionProperties, PropagatorModel.class); + } return propagator; } - @JsonProperty("propagator") + @JsonProperty(PROPAGATOR) public OpenTelemetryConfigurationModel withPropagator(PropagatorModel propagator) { this.propagator = propagator; return this; @@ -229,13 +295,17 @@ public OpenTelemetryConfigurationModel withPropagator(PropagatorModel propagator * *

If omitted, a noop tracer provider is used. */ - @JsonProperty("tracer_provider") + @JsonProperty(TRACER_PROVIDER) @Nullable public TracerProviderModel getTracerProvider() { + if (tracerProvider == null) { + return ExtensionPropertyUtil.getGraduated( + TRACER_PROVIDER, extensionProperties, TracerProviderModel.class); + } return tracerProvider; } - @JsonProperty("tracer_provider") + @JsonProperty(TRACER_PROVIDER) public OpenTelemetryConfigurationModel withTracerProvider(TracerProviderModel tracerProvider) { this.tracerProvider = tracerProvider; return this; @@ -246,36 +316,21 @@ public OpenTelemetryConfigurationModel withTracerProvider(TracerProviderModel tr * *

If omitted, the default resource is used. */ - @JsonProperty("resource") + @JsonProperty(RESOURCE) @Nullable public ResourceModel getResource() { + if (resource == null) { + return ExtensionPropertyUtil.getGraduated(RESOURCE, extensionProperties, ResourceModel.class); + } return resource; } - @JsonProperty("resource") + @JsonProperty(RESOURCE) public OpenTelemetryConfigurationModel withResource(ResourceModel resource) { this.resource = resource; return this; } - /** - * Configure instrumentation. - * - *

If omitted, instrumentation defaults are used. - */ - @JsonProperty("instrumentation/development") - @Nullable - public ExperimentalInstrumentationModel getInstrumentationDevelopment() { - return instrumentationDevelopment; - } - - @JsonProperty("instrumentation/development") - public OpenTelemetryConfigurationModel withInstrumentationDevelopment( - ExperimentalInstrumentationModel instrumentationDevelopment) { - this.instrumentationDevelopment = instrumentationDevelopment; - return this; - } - /** * Defines configuration parameters specific to a particular OpenTelemetry distribution or vendor. * @@ -287,26 +342,37 @@ public OpenTelemetryConfigurationModel withInstrumentationDevelopment( * *

If omitted, distribution defaults are used. */ - @JsonProperty("distribution") + @JsonProperty(DISTRIBUTION) @Nullable public DistributionModel getDistribution() { + if (distribution == null) { + return ExtensionPropertyUtil.getGraduated( + DISTRIBUTION, extensionProperties, DistributionModel.class); + } return distribution; } - @JsonProperty("distribution") + @JsonProperty(DISTRIBUTION) public OpenTelemetryConfigurationModel withDistribution(DistributionModel distribution) { this.distribution = distribution; return this; } @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); } @JsonAnySetter - public OpenTelemetryConfigurationModel withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); + public OpenTelemetryConfigurationModel withExtensionProperty( + String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + EXPERIMENTAL_PROPERTIES, + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); return this; } @@ -331,12 +397,10 @@ public String toString() { + tracerProvider + ", resource=" + resource - + ", instrumentationDevelopment=" - + instrumentationDevelopment + ", distribution=" + distribution - + ", additionalProperties=" - + additionalProperties + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -362,11 +426,9 @@ public int hashCode() { h *= 1000003; h ^= (this.resource == null) ? 0 : this.resource.hashCode(); h *= 1000003; - h ^= (this.instrumentationDevelopment == null) ? 0 : this.instrumentationDevelopment.hashCode(); - h *= 1000003; h ^= (this.distribution == null) ? 0 : this.distribution.hashCode(); h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -398,15 +460,12 @@ public boolean equals(@Nullable Object o) { ? that.tracerProvider == null : this.tracerProvider.equals(that.tracerProvider)) && (this.resource == null ? that.resource == null : this.resource.equals(that.resource)) - && (this.instrumentationDevelopment == null - ? that.instrumentationDevelopment == null - : this.instrumentationDevelopment.equals(that.instrumentationDevelopment)) && (this.distribution == null ? that.distribution == null : this.distribution.equals(that.distribution)) - && (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/OtlpGrpcExporterModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/OtlpGrpcExporterModel.java index fd9dce77176..a833c6e5de5 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/OtlpGrpcExporterModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/OtlpGrpcExporterModel.java @@ -5,37 +5,75 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpGrpcExporterModel.COMPRESSION; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpGrpcExporterModel.ENDPOINT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpGrpcExporterModel.HEADERS; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpGrpcExporterModel.HEADERS_LIST; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpGrpcExporterModel.TIMEOUT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpGrpcExporterModel.TLS; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"endpoint", "tls", "headers", "headers_list", "compression", "timeout"}) +@JsonPropertyOrder({ENDPOINT, TLS, HEADERS, HEADERS_LIST, COMPRESSION, TIMEOUT}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class OtlpGrpcExporterModel { + static final String ENDPOINT = "endpoint"; + static final String TLS = "tls"; + static final String HEADERS = "headers"; + static final String HEADERS_LIST = "headers_list"; + static final String COMPRESSION = "compression"; + static final String TIMEOUT = "timeout"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(ENDPOINT, String.class); + STABLE_PROPERTIES.put(TLS, GrpcTlsModel.class); + STABLE_PROPERTIES.put(HEADERS_LIST, String.class); + STABLE_PROPERTIES.put(COMPRESSION, String.class); + STABLE_PROPERTIES.put(TIMEOUT, Integer.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private String endpoint; @Nullable private GrpcTlsModel tls; @Nullable private List headers; @Nullable private String headersList; @Nullable private String compression; @Nullable private Integer timeout; + private Map extensionProperties = new LinkedHashMap(); /** * Configure endpoint. * *

If omitted or null, http://localhost:4317 is used. */ - @JsonProperty("endpoint") + @JsonProperty(ENDPOINT) @Nullable public String getEndpoint() { + if (endpoint == null) { + return ExtensionPropertyUtil.getGraduated(ENDPOINT, extensionProperties, String.class); + } return endpoint; } - @JsonProperty("endpoint") + @JsonProperty(ENDPOINT) public OtlpGrpcExporterModel withEndpoint(String endpoint) { this.endpoint = endpoint; return this; @@ -46,13 +84,16 @@ public OtlpGrpcExporterModel withEndpoint(String endpoint) { * *

If omitted, system default TLS settings are used. */ - @JsonProperty("tls") + @JsonProperty(TLS) @Nullable public GrpcTlsModel getTls() { + if (tls == null) { + return ExtensionPropertyUtil.getGraduated(TLS, extensionProperties, GrpcTlsModel.class); + } return tls; } - @JsonProperty("tls") + @JsonProperty(TLS) public OtlpGrpcExporterModel withTls(GrpcTlsModel tls) { this.tls = tls; return this; @@ -65,13 +106,13 @@ public OtlpGrpcExporterModel withTls(GrpcTlsModel tls) { * *

If omitted, no headers are added. */ - @JsonProperty("headers") + @JsonProperty(HEADERS) @Nullable public List getHeaders() { return headers; } - @JsonProperty("headers") + @JsonProperty(HEADERS) public OtlpGrpcExporterModel withHeaders(List headers) { this.headers = headers; return this; @@ -87,13 +128,16 @@ public OtlpGrpcExporterModel withHeaders(List headers) * *

If omitted or null, no headers are added. */ - @JsonProperty("headers_list") + @JsonProperty(HEADERS_LIST) @Nullable public String getHeadersList() { + if (headersList == null) { + return ExtensionPropertyUtil.getGraduated(HEADERS_LIST, extensionProperties, String.class); + } return headersList; } - @JsonProperty("headers_list") + @JsonProperty(HEADERS_LIST) public OtlpGrpcExporterModel withHeadersList(String headersList) { this.headersList = headersList; return this; @@ -106,13 +150,16 @@ public OtlpGrpcExporterModel withHeadersList(String headersList) { * *

If omitted or null, none is used. */ - @JsonProperty("compression") + @JsonProperty(COMPRESSION) @Nullable public String getCompression() { + if (compression == null) { + return ExtensionPropertyUtil.getGraduated(COMPRESSION, extensionProperties, String.class); + } return compression; } - @JsonProperty("compression") + @JsonProperty(COMPRESSION) public OtlpGrpcExporterModel withCompression(String compression) { this.compression = compression; return this; @@ -125,18 +172,38 @@ public OtlpGrpcExporterModel withCompression(String compression) { * *

If omitted or null, 10000 is used. */ - @JsonProperty("timeout") + @JsonProperty(TIMEOUT) @Nullable public Integer getTimeout() { + if (timeout == null) { + return ExtensionPropertyUtil.getGraduated(TIMEOUT, extensionProperties, Integer.class); + } return timeout; } - @JsonProperty("timeout") + @JsonProperty(TIMEOUT) public OtlpGrpcExporterModel withTimeout(Integer timeout) { this.timeout = timeout; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public OtlpGrpcExporterModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "OtlpGrpcExporterModel{" @@ -152,6 +219,8 @@ public String toString() { + compression + ", timeout=" + timeout + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -170,6 +239,8 @@ public int hashCode() { h ^= (this.compression == null) ? 0 : this.compression.hashCode(); h *= 1000003; h ^= (this.timeout == null) ? 0 : this.timeout.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -189,7 +260,10 @@ public boolean equals(@Nullable Object o) { && (this.compression == null ? that.compression == null : this.compression.equals(that.compression)) - && (this.timeout == null ? that.timeout == null : this.timeout.equals(that.timeout)); + && (this.timeout == null ? that.timeout == null : this.timeout.equals(that.timeout)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/OtlpGrpcMetricExporterModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/OtlpGrpcMetricExporterModel.java index dadb13fd661..ae11985377f 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/OtlpGrpcMetricExporterModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/OtlpGrpcMetricExporterModel.java @@ -5,27 +5,68 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpGrpcMetricExporterModel.COMPRESSION; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpGrpcMetricExporterModel.DEFAULT_HISTOGRAM_AGGREGATION; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpGrpcMetricExporterModel.ENDPOINT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpGrpcMetricExporterModel.HEADERS; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpGrpcMetricExporterModel.HEADERS_LIST; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpGrpcMetricExporterModel.TEMPORALITY_PREFERENCE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpGrpcMetricExporterModel.TIMEOUT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpGrpcMetricExporterModel.TLS; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ - "endpoint", - "tls", - "headers", - "headers_list", - "compression", - "timeout", - "temporality_preference", - "default_histogram_aggregation" + ENDPOINT, + TLS, + HEADERS, + HEADERS_LIST, + COMPRESSION, + TIMEOUT, + TEMPORALITY_PREFERENCE, + DEFAULT_HISTOGRAM_AGGREGATION }) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class OtlpGrpcMetricExporterModel { + static final String ENDPOINT = "endpoint"; + static final String TLS = "tls"; + static final String HEADERS = "headers"; + static final String HEADERS_LIST = "headers_list"; + static final String COMPRESSION = "compression"; + static final String TIMEOUT = "timeout"; + static final String TEMPORALITY_PREFERENCE = "temporality_preference"; + static final String DEFAULT_HISTOGRAM_AGGREGATION = "default_histogram_aggregation"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(ENDPOINT, String.class); + STABLE_PROPERTIES.put(TLS, GrpcTlsModel.class); + STABLE_PROPERTIES.put(HEADERS_LIST, String.class); + STABLE_PROPERTIES.put(COMPRESSION, String.class); + STABLE_PROPERTIES.put(TIMEOUT, Integer.class); + STABLE_PROPERTIES.put(TEMPORALITY_PREFERENCE, ExporterTemporalityPreferenceModel.class); + STABLE_PROPERTIES.put( + DEFAULT_HISTOGRAM_AGGREGATION, ExporterDefaultHistogramAggregationModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private String endpoint; @Nullable private GrpcTlsModel tls; @Nullable private List headers; @@ -34,19 +75,23 @@ public class OtlpGrpcMetricExporterModel { @Nullable private Integer timeout; @Nullable private ExporterTemporalityPreferenceModel temporalityPreference; @Nullable private ExporterDefaultHistogramAggregationModel defaultHistogramAggregation; + private Map extensionProperties = new LinkedHashMap(); /** * Configure endpoint. * *

If omitted or null, http://localhost:4317 is used. */ - @JsonProperty("endpoint") + @JsonProperty(ENDPOINT) @Nullable public String getEndpoint() { + if (endpoint == null) { + return ExtensionPropertyUtil.getGraduated(ENDPOINT, extensionProperties, String.class); + } return endpoint; } - @JsonProperty("endpoint") + @JsonProperty(ENDPOINT) public OtlpGrpcMetricExporterModel withEndpoint(String endpoint) { this.endpoint = endpoint; return this; @@ -57,13 +102,16 @@ public OtlpGrpcMetricExporterModel withEndpoint(String endpoint) { * *

If omitted, system default TLS settings are used. */ - @JsonProperty("tls") + @JsonProperty(TLS) @Nullable public GrpcTlsModel getTls() { + if (tls == null) { + return ExtensionPropertyUtil.getGraduated(TLS, extensionProperties, GrpcTlsModel.class); + } return tls; } - @JsonProperty("tls") + @JsonProperty(TLS) public OtlpGrpcMetricExporterModel withTls(GrpcTlsModel tls) { this.tls = tls; return this; @@ -76,13 +124,13 @@ public OtlpGrpcMetricExporterModel withTls(GrpcTlsModel tls) { * *

If omitted, no headers are added. */ - @JsonProperty("headers") + @JsonProperty(HEADERS) @Nullable public List getHeaders() { return headers; } - @JsonProperty("headers") + @JsonProperty(HEADERS) public OtlpGrpcMetricExporterModel withHeaders(List headers) { this.headers = headers; return this; @@ -98,13 +146,16 @@ public OtlpGrpcMetricExporterModel withHeaders(List he * *

If omitted or null, no headers are added. */ - @JsonProperty("headers_list") + @JsonProperty(HEADERS_LIST) @Nullable public String getHeadersList() { + if (headersList == null) { + return ExtensionPropertyUtil.getGraduated(HEADERS_LIST, extensionProperties, String.class); + } return headersList; } - @JsonProperty("headers_list") + @JsonProperty(HEADERS_LIST) public OtlpGrpcMetricExporterModel withHeadersList(String headersList) { this.headersList = headersList; return this; @@ -117,13 +168,16 @@ public OtlpGrpcMetricExporterModel withHeadersList(String headersList) { * *

If omitted or null, none is used. */ - @JsonProperty("compression") + @JsonProperty(COMPRESSION) @Nullable public String getCompression() { + if (compression == null) { + return ExtensionPropertyUtil.getGraduated(COMPRESSION, extensionProperties, String.class); + } return compression; } - @JsonProperty("compression") + @JsonProperty(COMPRESSION) public OtlpGrpcMetricExporterModel withCompression(String compression) { this.compression = compression; return this; @@ -136,13 +190,16 @@ public OtlpGrpcMetricExporterModel withCompression(String compression) { * *

If omitted or null, 10000 is used. */ - @JsonProperty("timeout") + @JsonProperty(TIMEOUT) @Nullable public Integer getTimeout() { + if (timeout == null) { + return ExtensionPropertyUtil.getGraduated(TIMEOUT, extensionProperties, Integer.class); + } return timeout; } - @JsonProperty("timeout") + @JsonProperty(TIMEOUT) public OtlpGrpcMetricExporterModel withTimeout(Integer timeout) { this.timeout = timeout; return this; @@ -163,13 +220,17 @@ public OtlpGrpcMetricExporterModel withTimeout(Integer timeout) { * *

If omitted, cumulative is used. */ - @JsonProperty("temporality_preference") + @JsonProperty(TEMPORALITY_PREFERENCE) @Nullable public ExporterTemporalityPreferenceModel getTemporalityPreference() { + if (temporalityPreference == null) { + return ExtensionPropertyUtil.getGraduated( + TEMPORALITY_PREFERENCE, extensionProperties, ExporterTemporalityPreferenceModel.class); + } return temporalityPreference; } - @JsonProperty("temporality_preference") + @JsonProperty(TEMPORALITY_PREFERENCE) public OtlpGrpcMetricExporterModel withTemporalityPreference( ExporterTemporalityPreferenceModel temporalityPreference) { this.temporalityPreference = temporalityPreference; @@ -189,19 +250,42 @@ public OtlpGrpcMetricExporterModel withTemporalityPreference( * *

If omitted, explicit_bucket_histogram is used. */ - @JsonProperty("default_histogram_aggregation") + @JsonProperty(DEFAULT_HISTOGRAM_AGGREGATION) @Nullable public ExporterDefaultHistogramAggregationModel getDefaultHistogramAggregation() { + if (defaultHistogramAggregation == null) { + return ExtensionPropertyUtil.getGraduated( + DEFAULT_HISTOGRAM_AGGREGATION, + extensionProperties, + ExporterDefaultHistogramAggregationModel.class); + } return defaultHistogramAggregation; } - @JsonProperty("default_histogram_aggregation") + @JsonProperty(DEFAULT_HISTOGRAM_AGGREGATION) public OtlpGrpcMetricExporterModel withDefaultHistogramAggregation( ExporterDefaultHistogramAggregationModel defaultHistogramAggregation) { this.defaultHistogramAggregation = defaultHistogramAggregation; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public OtlpGrpcMetricExporterModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "OtlpGrpcMetricExporterModel{" @@ -221,6 +305,8 @@ public String toString() { + temporalityPreference + ", defaultHistogramAggregation=" + defaultHistogramAggregation + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -246,6 +332,8 @@ public int hashCode() { (this.defaultHistogramAggregation == null) ? 0 : this.defaultHistogramAggregation.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -271,7 +359,10 @@ public boolean equals(@Nullable Object o) { : this.temporalityPreference.equals(that.temporalityPreference)) && (this.defaultHistogramAggregation == null ? that.defaultHistogramAggregation == null - : this.defaultHistogramAggregation.equals(that.defaultHistogramAggregation)); + : this.defaultHistogramAggregation.equals(that.defaultHistogramAggregation)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/OtlpHttpExporterModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/OtlpHttpExporterModel.java index 4a197e093f4..7d2b0db5e6e 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/OtlpHttpExporterModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/OtlpHttpExporterModel.java @@ -5,26 +5,55 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpHttpExporterModel.COMPRESSION; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpHttpExporterModel.ENCODING; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpHttpExporterModel.ENDPOINT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpHttpExporterModel.HEADERS; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpHttpExporterModel.HEADERS_LIST; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpHttpExporterModel.TIMEOUT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpHttpExporterModel.TLS; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "endpoint", - "tls", - "headers", - "headers_list", - "compression", - "timeout", - "encoding" -}) +@JsonPropertyOrder({ENDPOINT, TLS, HEADERS, HEADERS_LIST, COMPRESSION, TIMEOUT, ENCODING}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class OtlpHttpExporterModel { + static final String ENDPOINT = "endpoint"; + static final String TLS = "tls"; + static final String HEADERS = "headers"; + static final String HEADERS_LIST = "headers_list"; + static final String COMPRESSION = "compression"; + static final String TIMEOUT = "timeout"; + static final String ENCODING = "encoding"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(ENDPOINT, String.class); + STABLE_PROPERTIES.put(TLS, HttpTlsModel.class); + STABLE_PROPERTIES.put(HEADERS_LIST, String.class); + STABLE_PROPERTIES.put(COMPRESSION, String.class); + STABLE_PROPERTIES.put(TIMEOUT, Integer.class); + STABLE_PROPERTIES.put(ENCODING, OtlpHttpEncodingModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private String endpoint; @Nullable private HttpTlsModel tls; @Nullable private List headers; @@ -32,6 +61,7 @@ public class OtlpHttpExporterModel { @Nullable private String compression; @Nullable private Integer timeout; @Nullable private OtlpHttpEncodingModel encoding; + private Map extensionProperties = new LinkedHashMap(); /** * Configure endpoint, including the signal specific path. @@ -39,13 +69,16 @@ public class OtlpHttpExporterModel { *

If omitted or null, the http://localhost:4318/v1/{signal} (where signal is 'traces', 'logs', * or 'metrics') is used. */ - @JsonProperty("endpoint") + @JsonProperty(ENDPOINT) @Nullable public String getEndpoint() { + if (endpoint == null) { + return ExtensionPropertyUtil.getGraduated(ENDPOINT, extensionProperties, String.class); + } return endpoint; } - @JsonProperty("endpoint") + @JsonProperty(ENDPOINT) public OtlpHttpExporterModel withEndpoint(String endpoint) { this.endpoint = endpoint; return this; @@ -56,13 +89,16 @@ public OtlpHttpExporterModel withEndpoint(String endpoint) { * *

If omitted, system default TLS settings are used. */ - @JsonProperty("tls") + @JsonProperty(TLS) @Nullable public HttpTlsModel getTls() { + if (tls == null) { + return ExtensionPropertyUtil.getGraduated(TLS, extensionProperties, HttpTlsModel.class); + } return tls; } - @JsonProperty("tls") + @JsonProperty(TLS) public OtlpHttpExporterModel withTls(HttpTlsModel tls) { this.tls = tls; return this; @@ -75,13 +111,13 @@ public OtlpHttpExporterModel withTls(HttpTlsModel tls) { * *

If omitted, no headers are added. */ - @JsonProperty("headers") + @JsonProperty(HEADERS) @Nullable public List getHeaders() { return headers; } - @JsonProperty("headers") + @JsonProperty(HEADERS) public OtlpHttpExporterModel withHeaders(List headers) { this.headers = headers; return this; @@ -97,13 +133,16 @@ public OtlpHttpExporterModel withHeaders(List headers) * *

If omitted or null, no headers are added. */ - @JsonProperty("headers_list") + @JsonProperty(HEADERS_LIST) @Nullable public String getHeadersList() { + if (headersList == null) { + return ExtensionPropertyUtil.getGraduated(HEADERS_LIST, extensionProperties, String.class); + } return headersList; } - @JsonProperty("headers_list") + @JsonProperty(HEADERS_LIST) public OtlpHttpExporterModel withHeadersList(String headersList) { this.headersList = headersList; return this; @@ -116,13 +155,16 @@ public OtlpHttpExporterModel withHeadersList(String headersList) { * *

If omitted or null, none is used. */ - @JsonProperty("compression") + @JsonProperty(COMPRESSION) @Nullable public String getCompression() { + if (compression == null) { + return ExtensionPropertyUtil.getGraduated(COMPRESSION, extensionProperties, String.class); + } return compression; } - @JsonProperty("compression") + @JsonProperty(COMPRESSION) public OtlpHttpExporterModel withCompression(String compression) { this.compression = compression; return this; @@ -135,13 +177,16 @@ public OtlpHttpExporterModel withCompression(String compression) { * *

If omitted or null, 10000 is used. */ - @JsonProperty("timeout") + @JsonProperty(TIMEOUT) @Nullable public Integer getTimeout() { + if (timeout == null) { + return ExtensionPropertyUtil.getGraduated(TIMEOUT, extensionProperties, Integer.class); + } return timeout; } - @JsonProperty("timeout") + @JsonProperty(TIMEOUT) public OtlpHttpExporterModel withTimeout(Integer timeout) { this.timeout = timeout; return this; @@ -160,18 +205,39 @@ public OtlpHttpExporterModel withTimeout(Integer timeout) { * *

If omitted, protobuf is used. */ - @JsonProperty("encoding") + @JsonProperty(ENCODING) @Nullable public OtlpHttpEncodingModel getEncoding() { + if (encoding == null) { + return ExtensionPropertyUtil.getGraduated( + ENCODING, extensionProperties, OtlpHttpEncodingModel.class); + } return encoding; } - @JsonProperty("encoding") + @JsonProperty(ENCODING) public OtlpHttpExporterModel withEncoding(OtlpHttpEncodingModel encoding) { this.encoding = encoding; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public OtlpHttpExporterModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "OtlpHttpExporterModel{" @@ -189,6 +255,8 @@ public String toString() { + timeout + ", encoding=" + encoding + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -209,6 +277,8 @@ public int hashCode() { h ^= (this.timeout == null) ? 0 : this.timeout.hashCode(); h *= 1000003; h ^= (this.encoding == null) ? 0 : this.encoding.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -229,7 +299,10 @@ public boolean equals(@Nullable Object o) { ? that.compression == null : this.compression.equals(that.compression)) && (this.timeout == null ? that.timeout == null : this.timeout.equals(that.timeout)) - && (this.encoding == null ? that.encoding == null : this.encoding.equals(that.encoding)); + && (this.encoding == null ? that.encoding == null : this.encoding.equals(that.encoding)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/OtlpHttpMetricExporterModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/OtlpHttpMetricExporterModel.java index 39f49036940..7611551cb52 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/OtlpHttpMetricExporterModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/OtlpHttpMetricExporterModel.java @@ -5,28 +5,72 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpHttpMetricExporterModel.COMPRESSION; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpHttpMetricExporterModel.DEFAULT_HISTOGRAM_AGGREGATION; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpHttpMetricExporterModel.ENCODING; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpHttpMetricExporterModel.ENDPOINT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpHttpMetricExporterModel.HEADERS; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpHttpMetricExporterModel.HEADERS_LIST; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpHttpMetricExporterModel.TEMPORALITY_PREFERENCE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpHttpMetricExporterModel.TIMEOUT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpHttpMetricExporterModel.TLS; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ - "endpoint", - "tls", - "headers", - "headers_list", - "compression", - "timeout", - "encoding", - "temporality_preference", - "default_histogram_aggregation" + ENDPOINT, + TLS, + HEADERS, + HEADERS_LIST, + COMPRESSION, + TIMEOUT, + ENCODING, + TEMPORALITY_PREFERENCE, + DEFAULT_HISTOGRAM_AGGREGATION }) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class OtlpHttpMetricExporterModel { + static final String ENDPOINT = "endpoint"; + static final String TLS = "tls"; + static final String HEADERS = "headers"; + static final String HEADERS_LIST = "headers_list"; + static final String COMPRESSION = "compression"; + static final String TIMEOUT = "timeout"; + static final String ENCODING = "encoding"; + static final String TEMPORALITY_PREFERENCE = "temporality_preference"; + static final String DEFAULT_HISTOGRAM_AGGREGATION = "default_histogram_aggregation"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(ENDPOINT, String.class); + STABLE_PROPERTIES.put(TLS, HttpTlsModel.class); + STABLE_PROPERTIES.put(HEADERS_LIST, String.class); + STABLE_PROPERTIES.put(COMPRESSION, String.class); + STABLE_PROPERTIES.put(TIMEOUT, Integer.class); + STABLE_PROPERTIES.put(ENCODING, OtlpHttpEncodingModel.class); + STABLE_PROPERTIES.put(TEMPORALITY_PREFERENCE, ExporterTemporalityPreferenceModel.class); + STABLE_PROPERTIES.put( + DEFAULT_HISTOGRAM_AGGREGATION, ExporterDefaultHistogramAggregationModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private String endpoint; @Nullable private HttpTlsModel tls; @Nullable private List headers; @@ -36,19 +80,23 @@ public class OtlpHttpMetricExporterModel { @Nullable private OtlpHttpEncodingModel encoding; @Nullable private ExporterTemporalityPreferenceModel temporalityPreference; @Nullable private ExporterDefaultHistogramAggregationModel defaultHistogramAggregation; + private Map extensionProperties = new LinkedHashMap(); /** * Configure endpoint. * *

If omitted or null, http://localhost:4318/v1/metrics is used. */ - @JsonProperty("endpoint") + @JsonProperty(ENDPOINT) @Nullable public String getEndpoint() { + if (endpoint == null) { + return ExtensionPropertyUtil.getGraduated(ENDPOINT, extensionProperties, String.class); + } return endpoint; } - @JsonProperty("endpoint") + @JsonProperty(ENDPOINT) public OtlpHttpMetricExporterModel withEndpoint(String endpoint) { this.endpoint = endpoint; return this; @@ -59,13 +107,16 @@ public OtlpHttpMetricExporterModel withEndpoint(String endpoint) { * *

If omitted, system default TLS settings are used. */ - @JsonProperty("tls") + @JsonProperty(TLS) @Nullable public HttpTlsModel getTls() { + if (tls == null) { + return ExtensionPropertyUtil.getGraduated(TLS, extensionProperties, HttpTlsModel.class); + } return tls; } - @JsonProperty("tls") + @JsonProperty(TLS) public OtlpHttpMetricExporterModel withTls(HttpTlsModel tls) { this.tls = tls; return this; @@ -78,13 +129,13 @@ public OtlpHttpMetricExporterModel withTls(HttpTlsModel tls) { * *

If omitted, no headers are added. */ - @JsonProperty("headers") + @JsonProperty(HEADERS) @Nullable public List getHeaders() { return headers; } - @JsonProperty("headers") + @JsonProperty(HEADERS) public OtlpHttpMetricExporterModel withHeaders(List headers) { this.headers = headers; return this; @@ -100,13 +151,16 @@ public OtlpHttpMetricExporterModel withHeaders(List he * *

If omitted or null, no headers are added. */ - @JsonProperty("headers_list") + @JsonProperty(HEADERS_LIST) @Nullable public String getHeadersList() { + if (headersList == null) { + return ExtensionPropertyUtil.getGraduated(HEADERS_LIST, extensionProperties, String.class); + } return headersList; } - @JsonProperty("headers_list") + @JsonProperty(HEADERS_LIST) public OtlpHttpMetricExporterModel withHeadersList(String headersList) { this.headersList = headersList; return this; @@ -119,13 +173,16 @@ public OtlpHttpMetricExporterModel withHeadersList(String headersList) { * *

If omitted or null, none is used. */ - @JsonProperty("compression") + @JsonProperty(COMPRESSION) @Nullable public String getCompression() { + if (compression == null) { + return ExtensionPropertyUtil.getGraduated(COMPRESSION, extensionProperties, String.class); + } return compression; } - @JsonProperty("compression") + @JsonProperty(COMPRESSION) public OtlpHttpMetricExporterModel withCompression(String compression) { this.compression = compression; return this; @@ -138,13 +195,16 @@ public OtlpHttpMetricExporterModel withCompression(String compression) { * *

If omitted or null, 10000 is used. */ - @JsonProperty("timeout") + @JsonProperty(TIMEOUT) @Nullable public Integer getTimeout() { + if (timeout == null) { + return ExtensionPropertyUtil.getGraduated(TIMEOUT, extensionProperties, Integer.class); + } return timeout; } - @JsonProperty("timeout") + @JsonProperty(TIMEOUT) public OtlpHttpMetricExporterModel withTimeout(Integer timeout) { this.timeout = timeout; return this; @@ -163,13 +223,17 @@ public OtlpHttpMetricExporterModel withTimeout(Integer timeout) { * *

If omitted, protobuf is used. */ - @JsonProperty("encoding") + @JsonProperty(ENCODING) @Nullable public OtlpHttpEncodingModel getEncoding() { + if (encoding == null) { + return ExtensionPropertyUtil.getGraduated( + ENCODING, extensionProperties, OtlpHttpEncodingModel.class); + } return encoding; } - @JsonProperty("encoding") + @JsonProperty(ENCODING) public OtlpHttpMetricExporterModel withEncoding(OtlpHttpEncodingModel encoding) { this.encoding = encoding; return this; @@ -190,13 +254,17 @@ public OtlpHttpMetricExporterModel withEncoding(OtlpHttpEncodingModel encoding) * *

If omitted, cumulative is used. */ - @JsonProperty("temporality_preference") + @JsonProperty(TEMPORALITY_PREFERENCE) @Nullable public ExporterTemporalityPreferenceModel getTemporalityPreference() { + if (temporalityPreference == null) { + return ExtensionPropertyUtil.getGraduated( + TEMPORALITY_PREFERENCE, extensionProperties, ExporterTemporalityPreferenceModel.class); + } return temporalityPreference; } - @JsonProperty("temporality_preference") + @JsonProperty(TEMPORALITY_PREFERENCE) public OtlpHttpMetricExporterModel withTemporalityPreference( ExporterTemporalityPreferenceModel temporalityPreference) { this.temporalityPreference = temporalityPreference; @@ -216,19 +284,42 @@ public OtlpHttpMetricExporterModel withTemporalityPreference( * *

If omitted, explicit_bucket_histogram is used. */ - @JsonProperty("default_histogram_aggregation") + @JsonProperty(DEFAULT_HISTOGRAM_AGGREGATION) @Nullable public ExporterDefaultHistogramAggregationModel getDefaultHistogramAggregation() { + if (defaultHistogramAggregation == null) { + return ExtensionPropertyUtil.getGraduated( + DEFAULT_HISTOGRAM_AGGREGATION, + extensionProperties, + ExporterDefaultHistogramAggregationModel.class); + } return defaultHistogramAggregation; } - @JsonProperty("default_histogram_aggregation") + @JsonProperty(DEFAULT_HISTOGRAM_AGGREGATION) public OtlpHttpMetricExporterModel withDefaultHistogramAggregation( ExporterDefaultHistogramAggregationModel defaultHistogramAggregation) { this.defaultHistogramAggregation = defaultHistogramAggregation; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public OtlpHttpMetricExporterModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "OtlpHttpMetricExporterModel{" @@ -250,6 +341,8 @@ public String toString() { + temporalityPreference + ", defaultHistogramAggregation=" + defaultHistogramAggregation + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -277,6 +370,8 @@ public int hashCode() { (this.defaultHistogramAggregation == null) ? 0 : this.defaultHistogramAggregation.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -303,7 +398,10 @@ public boolean equals(@Nullable Object o) { : this.temporalityPreference.equals(that.temporalityPreference)) && (this.defaultHistogramAggregation == null ? that.defaultHistogramAggregation == null - : this.defaultHistogramAggregation.equals(that.defaultHistogramAggregation)); + : this.defaultHistogramAggregation.equals(that.defaultHistogramAggregation)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ParentBasedSamplerModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ParentBasedSamplerModel.java index f01f9aa5c9d..2f1f8d81bee 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ParentBasedSamplerModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ParentBasedSamplerModel.java @@ -5,41 +5,77 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ParentBasedSamplerModel.LOCAL_PARENT_NOT_SAMPLED; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ParentBasedSamplerModel.LOCAL_PARENT_SAMPLED; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ParentBasedSamplerModel.REMOTE_PARENT_NOT_SAMPLED; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ParentBasedSamplerModel.REMOTE_PARENT_SAMPLED; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ParentBasedSamplerModel.ROOT; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ - "root", - "remote_parent_sampled", - "remote_parent_not_sampled", - "local_parent_sampled", - "local_parent_not_sampled" + ROOT, + REMOTE_PARENT_SAMPLED, + REMOTE_PARENT_NOT_SAMPLED, + LOCAL_PARENT_SAMPLED, + LOCAL_PARENT_NOT_SAMPLED }) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class ParentBasedSamplerModel { + static final String ROOT = "root"; + static final String REMOTE_PARENT_SAMPLED = "remote_parent_sampled"; + static final String REMOTE_PARENT_NOT_SAMPLED = "remote_parent_not_sampled"; + static final String LOCAL_PARENT_SAMPLED = "local_parent_sampled"; + static final String LOCAL_PARENT_NOT_SAMPLED = "local_parent_not_sampled"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(ROOT, SamplerModel.class); + STABLE_PROPERTIES.put(REMOTE_PARENT_SAMPLED, SamplerModel.class); + STABLE_PROPERTIES.put(REMOTE_PARENT_NOT_SAMPLED, SamplerModel.class); + STABLE_PROPERTIES.put(LOCAL_PARENT_SAMPLED, SamplerModel.class); + STABLE_PROPERTIES.put(LOCAL_PARENT_NOT_SAMPLED, SamplerModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private SamplerModel root; @Nullable private SamplerModel remoteParentSampled; @Nullable private SamplerModel remoteParentNotSampled; @Nullable private SamplerModel localParentSampled; @Nullable private SamplerModel localParentNotSampled; + private Map extensionProperties = new LinkedHashMap(); /** * Configure root sampler. * *

If omitted, always_on is used. */ - @JsonProperty("root") + @JsonProperty(ROOT) @Nullable public SamplerModel getRoot() { + if (root == null) { + return ExtensionPropertyUtil.getGraduated(ROOT, extensionProperties, SamplerModel.class); + } return root; } - @JsonProperty("root") + @JsonProperty(ROOT) public ParentBasedSamplerModel withRoot(SamplerModel root) { this.root = root; return this; @@ -50,13 +86,17 @@ public ParentBasedSamplerModel withRoot(SamplerModel root) { * *

If omitted, always_on is used. */ - @JsonProperty("remote_parent_sampled") + @JsonProperty(REMOTE_PARENT_SAMPLED) @Nullable public SamplerModel getRemoteParentSampled() { + if (remoteParentSampled == null) { + return ExtensionPropertyUtil.getGraduated( + REMOTE_PARENT_SAMPLED, extensionProperties, SamplerModel.class); + } return remoteParentSampled; } - @JsonProperty("remote_parent_sampled") + @JsonProperty(REMOTE_PARENT_SAMPLED) public ParentBasedSamplerModel withRemoteParentSampled(SamplerModel remoteParentSampled) { this.remoteParentSampled = remoteParentSampled; return this; @@ -67,13 +107,17 @@ public ParentBasedSamplerModel withRemoteParentSampled(SamplerModel remoteParent * *

If omitted, always_off is used. */ - @JsonProperty("remote_parent_not_sampled") + @JsonProperty(REMOTE_PARENT_NOT_SAMPLED) @Nullable public SamplerModel getRemoteParentNotSampled() { + if (remoteParentNotSampled == null) { + return ExtensionPropertyUtil.getGraduated( + REMOTE_PARENT_NOT_SAMPLED, extensionProperties, SamplerModel.class); + } return remoteParentNotSampled; } - @JsonProperty("remote_parent_not_sampled") + @JsonProperty(REMOTE_PARENT_NOT_SAMPLED) public ParentBasedSamplerModel withRemoteParentNotSampled(SamplerModel remoteParentNotSampled) { this.remoteParentNotSampled = remoteParentNotSampled; return this; @@ -84,13 +128,17 @@ public ParentBasedSamplerModel withRemoteParentNotSampled(SamplerModel remotePar * *

If omitted, always_on is used. */ - @JsonProperty("local_parent_sampled") + @JsonProperty(LOCAL_PARENT_SAMPLED) @Nullable public SamplerModel getLocalParentSampled() { + if (localParentSampled == null) { + return ExtensionPropertyUtil.getGraduated( + LOCAL_PARENT_SAMPLED, extensionProperties, SamplerModel.class); + } return localParentSampled; } - @JsonProperty("local_parent_sampled") + @JsonProperty(LOCAL_PARENT_SAMPLED) public ParentBasedSamplerModel withLocalParentSampled(SamplerModel localParentSampled) { this.localParentSampled = localParentSampled; return this; @@ -101,18 +149,39 @@ public ParentBasedSamplerModel withLocalParentSampled(SamplerModel localParentSa * *

If omitted, always_off is used. */ - @JsonProperty("local_parent_not_sampled") + @JsonProperty(LOCAL_PARENT_NOT_SAMPLED) @Nullable public SamplerModel getLocalParentNotSampled() { + if (localParentNotSampled == null) { + return ExtensionPropertyUtil.getGraduated( + LOCAL_PARENT_NOT_SAMPLED, extensionProperties, SamplerModel.class); + } return localParentNotSampled; } - @JsonProperty("local_parent_not_sampled") + @JsonProperty(LOCAL_PARENT_NOT_SAMPLED) public ParentBasedSamplerModel withLocalParentNotSampled(SamplerModel localParentNotSampled) { this.localParentNotSampled = localParentNotSampled; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public ParentBasedSamplerModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "ParentBasedSamplerModel{" @@ -126,6 +195,8 @@ public String toString() { + localParentSampled + ", localParentNotSampled=" + localParentNotSampled + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -142,6 +213,8 @@ public int hashCode() { h ^= (this.localParentSampled == null) ? 0 : this.localParentSampled.hashCode(); h *= 1000003; h ^= (this.localParentNotSampled == null) ? 0 : this.localParentNotSampled.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -164,7 +237,10 @@ public boolean equals(@Nullable Object o) { : this.localParentSampled.equals(that.localParentSampled)) && (this.localParentNotSampled == null ? that.localParentNotSampled == null - : this.localParentNotSampled.equals(that.localParentNotSampled)); + : this.localParentNotSampled.equals(that.localParentNotSampled)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PeriodicMetricReaderModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PeriodicMetricReaderModel.java index dd57f519a4f..3ee25f37057 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PeriodicMetricReaderModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PeriodicMetricReaderModel.java @@ -5,31 +5,55 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PeriodicMetricReaderModel.CARDINALITY_LIMITS; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PeriodicMetricReaderModel.EXPORTER; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PeriodicMetricReaderModel.INTERVAL; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PeriodicMetricReaderModel.PRODUCERS; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PeriodicMetricReaderModel.TIMEOUT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.PeriodicMetricReaderModelAccessor.EXPERIMENTAL_PROPERTIES; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "interval", - "timeout", - "max_export_batch_size/development", - "exporter", - "producers", - "cardinality_limits" -}) +@JsonPropertyOrder({INTERVAL, TIMEOUT, EXPORTER, PRODUCERS, CARDINALITY_LIMITS}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class PeriodicMetricReaderModel { + static final String INTERVAL = "interval"; + static final String TIMEOUT = "timeout"; + static final String EXPORTER = "exporter"; + static final String PRODUCERS = "producers"; + static final String CARDINALITY_LIMITS = "cardinality_limits"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(INTERVAL, Integer.class); + STABLE_PROPERTIES.put(TIMEOUT, Integer.class); + STABLE_PROPERTIES.put(EXPORTER, PushMetricExporterModel.class); + STABLE_PROPERTIES.put(CARDINALITY_LIMITS, CardinalityLimitsModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private Integer interval; @Nullable private Integer timeout; - @Nullable private Integer maxExportBatchSizeDevelopment; @Nullable private PushMetricExporterModel exporter; @Nullable private List producers; @Nullable private CardinalityLimitsModel cardinalityLimits; + private Map extensionProperties = new LinkedHashMap(); /** * Configure delay interval (in milliseconds) between start of two consecutive exports. @@ -38,13 +62,16 @@ public class PeriodicMetricReaderModel { * *

If omitted or null, 60000 is used. */ - @JsonProperty("interval") + @JsonProperty(INTERVAL) @Nullable public Integer getInterval() { + if (interval == null) { + return ExtensionPropertyUtil.getGraduated(INTERVAL, extensionProperties, Integer.class); + } return interval; } - @JsonProperty("interval") + @JsonProperty(INTERVAL) public PeriodicMetricReaderModel withInterval(Integer interval) { this.interval = interval; return this; @@ -57,48 +84,37 @@ public PeriodicMetricReaderModel withInterval(Integer interval) { * *

If omitted or null, 30000 is used. */ - @JsonProperty("timeout") + @JsonProperty(TIMEOUT) @Nullable public Integer getTimeout() { + if (timeout == null) { + return ExtensionPropertyUtil.getGraduated(TIMEOUT, extensionProperties, Integer.class); + } return timeout; } - @JsonProperty("timeout") + @JsonProperty(TIMEOUT) public PeriodicMetricReaderModel withTimeout(Integer timeout) { this.timeout = timeout; return this; } - /** - * Configure maximum export batch size. - * - *

If omitted or null, no limit is used. - */ - @JsonProperty("max_export_batch_size/development") - @Nullable - public Integer getMaxExportBatchSizeDevelopment() { - return maxExportBatchSizeDevelopment; - } - - @JsonProperty("max_export_batch_size/development") - public PeriodicMetricReaderModel withMaxExportBatchSizeDevelopment( - Integer maxExportBatchSizeDevelopment) { - this.maxExportBatchSizeDevelopment = maxExportBatchSizeDevelopment; - return this; - } - /** * Configure exporter. * *

Property is required and must be non-null. */ - @JsonProperty("exporter") + @JsonProperty(EXPORTER) @Nullable public PushMetricExporterModel getExporter() { + if (exporter == null) { + return ExtensionPropertyUtil.getGraduated( + EXPORTER, extensionProperties, PushMetricExporterModel.class); + } return exporter; } - @JsonProperty("exporter") + @JsonProperty(EXPORTER) public PeriodicMetricReaderModel withExporter(PushMetricExporterModel exporter) { this.exporter = exporter; return this; @@ -109,13 +125,13 @@ public PeriodicMetricReaderModel withExporter(PushMetricExporterModel exporter) * *

If omitted, no metric producers are added. */ - @JsonProperty("producers") + @JsonProperty(PRODUCERS) @Nullable public List getProducers() { return producers; } - @JsonProperty("producers") + @JsonProperty(PRODUCERS) public PeriodicMetricReaderModel withProducers(List producers) { this.producers = producers; return this; @@ -126,18 +142,39 @@ public PeriodicMetricReaderModel withProducers(List produce * *

If omitted, default values as described in CardinalityLimits are used. */ - @JsonProperty("cardinality_limits") + @JsonProperty(CARDINALITY_LIMITS) @Nullable public CardinalityLimitsModel getCardinalityLimits() { + if (cardinalityLimits == null) { + return ExtensionPropertyUtil.getGraduated( + CARDINALITY_LIMITS, extensionProperties, CardinalityLimitsModel.class); + } return cardinalityLimits; } - @JsonProperty("cardinality_limits") + @JsonProperty(CARDINALITY_LIMITS) public PeriodicMetricReaderModel withCardinalityLimits(CardinalityLimitsModel cardinalityLimits) { this.cardinalityLimits = cardinalityLimits; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public PeriodicMetricReaderModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + EXPERIMENTAL_PROPERTIES, + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "PeriodicMetricReaderModel{" @@ -145,14 +182,14 @@ public String toString() { + interval + ", timeout=" + timeout - + ", maxExportBatchSizeDevelopment=" - + maxExportBatchSizeDevelopment + ", exporter=" + exporter + ", producers=" + producers + ", cardinalityLimits=" + cardinalityLimits + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -164,16 +201,13 @@ public int hashCode() { h *= 1000003; h ^= (this.timeout == null) ? 0 : this.timeout.hashCode(); h *= 1000003; - h ^= - (this.maxExportBatchSizeDevelopment == null) - ? 0 - : this.maxExportBatchSizeDevelopment.hashCode(); - h *= 1000003; h ^= (this.exporter == null) ? 0 : this.exporter.hashCode(); h *= 1000003; h ^= (this.producers == null) ? 0 : this.producers.hashCode(); h *= 1000003; h ^= (this.cardinalityLimits == null) ? 0 : this.cardinalityLimits.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -186,16 +220,16 @@ public boolean equals(@Nullable Object o) { PeriodicMetricReaderModel that = (PeriodicMetricReaderModel) o; return (this.interval == null ? that.interval == null : this.interval.equals(that.interval)) && (this.timeout == null ? that.timeout == null : this.timeout.equals(that.timeout)) - && (this.maxExportBatchSizeDevelopment == null - ? that.maxExportBatchSizeDevelopment == null - : this.maxExportBatchSizeDevelopment.equals(that.maxExportBatchSizeDevelopment)) && (this.exporter == null ? that.exporter == null : this.exporter.equals(that.exporter)) && (this.producers == null ? that.producers == null : this.producers.equals(that.producers)) && (this.cardinalityLimits == null ? that.cardinalityLimits == null - : this.cardinalityLimits.equals(that.cardinalityLimits)); + : this.cardinalityLimits.equals(that.cardinalityLimits)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PropagatorModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PropagatorModel.java index b33f84f1963..a651c3b4c97 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PropagatorModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PropagatorModel.java @@ -5,20 +5,43 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PropagatorModel.COMPOSITE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PropagatorModel.COMPOSITE_LIST; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"composite", "composite_list"}) +@JsonPropertyOrder({COMPOSITE, COMPOSITE_LIST}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class PropagatorModel { + static final String COMPOSITE = "composite"; + static final String COMPOSITE_LIST = "composite_list"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(COMPOSITE_LIST, String.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private List composite; @Nullable private String compositeList; + private Map extensionProperties = new LinkedHashMap(); /** * Configure the propagators in the composite text map propagator. Entries from .composite_list @@ -29,13 +52,13 @@ public class PropagatorModel { * *

If omitted, and .composite_list is omitted or null, a noop propagator is used. */ - @JsonProperty("composite") + @JsonProperty(COMPOSITE) @Nullable public List getComposite() { return composite; } - @JsonProperty("composite") + @JsonProperty(COMPOSITE) public PropagatorModel withComposite(List composite) { this.composite = composite; return this; @@ -55,21 +78,48 @@ public PropagatorModel withComposite(List composite) { * *

If omitted or null, and .composite is omitted or null, a noop propagator is used. */ - @JsonProperty("composite_list") + @JsonProperty(COMPOSITE_LIST) @Nullable public String getCompositeList() { + if (compositeList == null) { + return ExtensionPropertyUtil.getGraduated(COMPOSITE_LIST, extensionProperties, String.class); + } return compositeList; } - @JsonProperty("composite_list") + @JsonProperty(COMPOSITE_LIST) public PropagatorModel withCompositeList(String compositeList) { this.compositeList = compositeList; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public PropagatorModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { - return "PropagatorModel{" + "composite=" + composite + ", compositeList=" + compositeList + "}"; + return "PropagatorModel{" + + "composite=" + + composite + + ", compositeList=" + + compositeList + + ", extensionProperties=" + + extensionProperties + + "}"; } @Override @@ -79,6 +129,8 @@ public int hashCode() { h ^= (this.composite == null) ? 0 : this.composite.hashCode(); h *= 1000003; h ^= (this.compositeList == null) ? 0 : this.compositeList.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -94,7 +146,10 @@ public boolean equals(@Nullable Object o) { : this.composite.equals(that.composite)) && (this.compositeList == null ? that.compositeList == null - : this.compositeList.equals(that.compositeList)); + : this.compositeList.equals(that.compositeList)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PullMetricExporterModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PullMetricExporterModel.java index a726171f0fb..211eb34b8e7 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PullMetricExporterModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PullMetricExporterModel.java @@ -5,73 +5,55 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.PullMetricExporterModelAccessor.EXPERIMENTAL_PROPERTIES; + import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalPrometheusMetricExporterModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"prometheus/development"}) +@JsonPropertyOrder({}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class PullMetricExporterModel { - @Nullable private ExperimentalPrometheusMetricExporterModel prometheusDevelopment; - private Map additionalProperties = - new LinkedHashMap(); - - /** - * Configure exporter to be prometheus. - * - *

If omitted, ignore. - */ - @JsonProperty("prometheus/development") - @Nullable - public ExperimentalPrometheusMetricExporterModel getPrometheusDevelopment() { - return prometheusDevelopment; - } + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = true; - @JsonProperty("prometheus/development") - public PullMetricExporterModel withPrometheusDevelopment( - ExperimentalPrometheusMetricExporterModel prometheusDevelopment) { - this.prometheusDevelopment = prometheusDevelopment; - return this; - } + private Map extensionProperties = new LinkedHashMap(); @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; + public Map getExtensionProperties() { + return extensionProperties; } @JsonAnySetter - public PullMetricExporterModel withAdditionalProperty( - String name, PullMetricExporterPropertyModel value) { - this.additionalProperties.put(name, value); + public PullMetricExporterModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + EXPERIMENTAL_PROPERTIES, + Collections.emptyMap(), + ALLOWS_ADDITIONAL_PROPERTIES); return this; } @Override public String toString() { - return "PullMetricExporterModel{" - + "prometheusDevelopment=" - + prometheusDevelopment - + ", additionalProperties=" - + additionalProperties - + "}"; + return "PullMetricExporterModel{" + "extensionProperties=" + extensionProperties + "}"; } @Override public int hashCode() { int h = 1; h *= 1000003; - h ^= (this.prometheusDevelopment == null) ? 0 : this.prometheusDevelopment.hashCode(); - h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -82,12 +64,9 @@ public boolean equals(@Nullable Object o) { } if (o instanceof PullMetricExporterModel) { PullMetricExporterModel that = (PullMetricExporterModel) o; - return (this.prometheusDevelopment == null - ? that.prometheusDevelopment == null - : this.prometheusDevelopment.equals(that.prometheusDevelopment)) - && (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); + return (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PullMetricExporterPropertyModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PullMetricExporterPropertyModel.java deleted file mode 100644 index 31f63b61f57..00000000000 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PullMetricExporterPropertyModel.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.util.LinkedHashMap; -import java.util.Map; -import javax.annotation.Generated; -import javax.annotation.Nullable; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({}) -@Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") -public class PullMetricExporterPropertyModel { - - private Map additionalProperties = new LinkedHashMap(); - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public PullMetricExporterPropertyModel withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - - @Override - public String toString() { - return "PullMetricExporterPropertyModel{" - + "additionalProperties=" - + additionalProperties - + "}"; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); - return h; - } - - @Override - public boolean equals(@Nullable Object o) { - if (o == this) { - return true; - } - if (o instanceof PullMetricExporterPropertyModel) { - PullMetricExporterPropertyModel that = (PullMetricExporterPropertyModel) o; - return (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); - } - return false; - } -} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PullMetricReaderModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PullMetricReaderModel.java index 0f42674be09..6cde4d331d3 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PullMetricReaderModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PullMetricReaderModel.java @@ -5,34 +5,64 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PullMetricReaderModel.CARDINALITY_LIMITS; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PullMetricReaderModel.EXPORTER; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PullMetricReaderModel.PRODUCERS; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"exporter", "producers", "cardinality_limits"}) +@JsonPropertyOrder({EXPORTER, PRODUCERS, CARDINALITY_LIMITS}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class PullMetricReaderModel { + static final String EXPORTER = "exporter"; + static final String PRODUCERS = "producers"; + static final String CARDINALITY_LIMITS = "cardinality_limits"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(EXPORTER, PullMetricExporterModel.class); + STABLE_PROPERTIES.put(CARDINALITY_LIMITS, CardinalityLimitsModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private PullMetricExporterModel exporter; @Nullable private List producers; @Nullable private CardinalityLimitsModel cardinalityLimits; + private Map extensionProperties = new LinkedHashMap(); /** * Configure exporter. * *

Property is required and must be non-null. */ - @JsonProperty("exporter") + @JsonProperty(EXPORTER) @Nullable public PullMetricExporterModel getExporter() { + if (exporter == null) { + return ExtensionPropertyUtil.getGraduated( + EXPORTER, extensionProperties, PullMetricExporterModel.class); + } return exporter; } - @JsonProperty("exporter") + @JsonProperty(EXPORTER) public PullMetricReaderModel withExporter(PullMetricExporterModel exporter) { this.exporter = exporter; return this; @@ -43,13 +73,13 @@ public PullMetricReaderModel withExporter(PullMetricExporterModel exporter) { * *

If omitted, no metric producers are added. */ - @JsonProperty("producers") + @JsonProperty(PRODUCERS) @Nullable public List getProducers() { return producers; } - @JsonProperty("producers") + @JsonProperty(PRODUCERS) public PullMetricReaderModel withProducers(List producers) { this.producers = producers; return this; @@ -60,18 +90,39 @@ public PullMetricReaderModel withProducers(List producers) * *

If omitted, default values as described in CardinalityLimits are used. */ - @JsonProperty("cardinality_limits") + @JsonProperty(CARDINALITY_LIMITS) @Nullable public CardinalityLimitsModel getCardinalityLimits() { + if (cardinalityLimits == null) { + return ExtensionPropertyUtil.getGraduated( + CARDINALITY_LIMITS, extensionProperties, CardinalityLimitsModel.class); + } return cardinalityLimits; } - @JsonProperty("cardinality_limits") + @JsonProperty(CARDINALITY_LIMITS) public PullMetricReaderModel withCardinalityLimits(CardinalityLimitsModel cardinalityLimits) { this.cardinalityLimits = cardinalityLimits; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public PullMetricReaderModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "PullMetricReaderModel{" @@ -81,6 +132,8 @@ public String toString() { + producers + ", cardinalityLimits=" + cardinalityLimits + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -93,6 +146,8 @@ public int hashCode() { h ^= (this.producers == null) ? 0 : this.producers.hashCode(); h *= 1000003; h ^= (this.cardinalityLimits == null) ? 0 : this.cardinalityLimits.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -109,7 +164,10 @@ public boolean equals(@Nullable Object o) { : this.producers.equals(that.producers)) && (this.cardinalityLimits == null ? that.cardinalityLimits == null - : this.cardinalityLimits.equals(that.cardinalityLimits)); + : this.cardinalityLimits.equals(that.cardinalityLimits)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PushMetricExporterModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PushMetricExporterModel.java index bbccec6a37f..a0e78f47b3c 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PushMetricExporterModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PushMetricExporterModel.java @@ -5,41 +5,64 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PushMetricExporterModel.CONSOLE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PushMetricExporterModel.OTLP_GRPC; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PushMetricExporterModel.OTLP_HTTP; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.PushMetricExporterModelAccessor.EXPERIMENTAL_PROPERTIES; + import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalOtlpFileMetricExporterModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"otlp_http", "otlp_grpc", "otlp_file/development", "console"}) +@JsonPropertyOrder({OTLP_HTTP, OTLP_GRPC, CONSOLE}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class PushMetricExporterModel { + static final String OTLP_HTTP = "otlp_http"; + static final String OTLP_GRPC = "otlp_grpc"; + static final String CONSOLE = "console"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(OTLP_HTTP, OtlpHttpMetricExporterModel.class); + STABLE_PROPERTIES.put(OTLP_GRPC, OtlpGrpcMetricExporterModel.class); + STABLE_PROPERTIES.put(CONSOLE, ConsoleMetricExporterModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = true; + @Nullable private OtlpHttpMetricExporterModel otlpHttp; @Nullable private OtlpGrpcMetricExporterModel otlpGrpc; - @Nullable private ExperimentalOtlpFileMetricExporterModel otlpFileDevelopment; @Nullable private ConsoleMetricExporterModel console; - private Map additionalProperties = - new LinkedHashMap(); + private Map extensionProperties = new LinkedHashMap(); /** * Configure exporter to be OTLP with HTTP transport. * *

If omitted, ignore. */ - @JsonProperty("otlp_http") + @JsonProperty(OTLP_HTTP) @Nullable public OtlpHttpMetricExporterModel getOtlpHttp() { + if (otlpHttp == null) { + return ExtensionPropertyUtil.getGraduated( + OTLP_HTTP, extensionProperties, OtlpHttpMetricExporterModel.class); + } return otlpHttp; } - @JsonProperty("otlp_http") + @JsonProperty(OTLP_HTTP) public PushMetricExporterModel withOtlpHttp(OtlpHttpMetricExporterModel otlpHttp) { this.otlpHttp = otlpHttp; return this; @@ -50,62 +73,57 @@ public PushMetricExporterModel withOtlpHttp(OtlpHttpMetricExporterModel otlpHttp * *

If omitted, ignore. */ - @JsonProperty("otlp_grpc") + @JsonProperty(OTLP_GRPC) @Nullable public OtlpGrpcMetricExporterModel getOtlpGrpc() { + if (otlpGrpc == null) { + return ExtensionPropertyUtil.getGraduated( + OTLP_GRPC, extensionProperties, OtlpGrpcMetricExporterModel.class); + } return otlpGrpc; } - @JsonProperty("otlp_grpc") + @JsonProperty(OTLP_GRPC) public PushMetricExporterModel withOtlpGrpc(OtlpGrpcMetricExporterModel otlpGrpc) { this.otlpGrpc = otlpGrpc; return this; } - /** - * Configure exporter to be OTLP with file transport. - * - *

If omitted, ignore. - */ - @JsonProperty("otlp_file/development") - @Nullable - public ExperimentalOtlpFileMetricExporterModel getOtlpFileDevelopment() { - return otlpFileDevelopment; - } - - @JsonProperty("otlp_file/development") - public PushMetricExporterModel withOtlpFileDevelopment( - ExperimentalOtlpFileMetricExporterModel otlpFileDevelopment) { - this.otlpFileDevelopment = otlpFileDevelopment; - return this; - } - /** * Configure exporter to be console. * *

If omitted, ignore. */ - @JsonProperty("console") + @JsonProperty(CONSOLE) @Nullable public ConsoleMetricExporterModel getConsole() { + if (console == null) { + return ExtensionPropertyUtil.getGraduated( + CONSOLE, extensionProperties, ConsoleMetricExporterModel.class); + } return console; } - @JsonProperty("console") + @JsonProperty(CONSOLE) public PushMetricExporterModel withConsole(ConsoleMetricExporterModel console) { this.console = console; return this; } @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); } @JsonAnySetter - public PushMetricExporterModel withAdditionalProperty( - String name, PushMetricExporterPropertyModel value) { - this.additionalProperties.put(name, value); + public PushMetricExporterModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + EXPERIMENTAL_PROPERTIES, + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); return this; } @@ -116,12 +134,10 @@ public String toString() { + otlpHttp + ", otlpGrpc=" + otlpGrpc - + ", otlpFileDevelopment=" - + otlpFileDevelopment + ", console=" + console - + ", additionalProperties=" - + additionalProperties + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -133,11 +149,9 @@ public int hashCode() { h *= 1000003; h ^= (this.otlpGrpc == null) ? 0 : this.otlpGrpc.hashCode(); h *= 1000003; - h ^= (this.otlpFileDevelopment == null) ? 0 : this.otlpFileDevelopment.hashCode(); - h *= 1000003; h ^= (this.console == null) ? 0 : this.console.hashCode(); h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -150,13 +164,10 @@ public boolean equals(@Nullable Object o) { PushMetricExporterModel that = (PushMetricExporterModel) o; return (this.otlpHttp == null ? that.otlpHttp == null : this.otlpHttp.equals(that.otlpHttp)) && (this.otlpGrpc == null ? that.otlpGrpc == null : this.otlpGrpc.equals(that.otlpGrpc)) - && (this.otlpFileDevelopment == null - ? that.otlpFileDevelopment == null - : this.otlpFileDevelopment.equals(that.otlpFileDevelopment)) && (this.console == null ? that.console == null : this.console.equals(that.console)) - && (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PushMetricExporterPropertyModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PushMetricExporterPropertyModel.java deleted file mode 100644 index be108906ead..00000000000 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/PushMetricExporterPropertyModel.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.util.LinkedHashMap; -import java.util.Map; -import javax.annotation.Generated; -import javax.annotation.Nullable; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({}) -@Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") -public class PushMetricExporterPropertyModel { - - private Map additionalProperties = new LinkedHashMap(); - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public PushMetricExporterPropertyModel withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - - @Override - public String toString() { - return "PushMetricExporterPropertyModel{" - + "additionalProperties=" - + additionalProperties - + "}"; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); - return h; - } - - @Override - public boolean equals(@Nullable Object o) { - if (o == this) { - return true; - } - if (o instanceof PushMetricExporterPropertyModel) { - PushMetricExporterPropertyModel that = (PushMetricExporterPropertyModel) o; - return (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); - } - return false; - } -} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ResourceModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ResourceModel.java index 2fdbe659927..a9c71837edc 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ResourceModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ResourceModel.java @@ -5,23 +5,47 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ResourceModel.ATTRIBUTES; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ResourceModel.ATTRIBUTES_LIST; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ResourceModel.SCHEMA_URL; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ResourceModelAccessor.EXPERIMENTAL_PROPERTIES; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalResourceDetectionModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"attributes", "detection/development", "schema_url", "attributes_list"}) +@JsonPropertyOrder({ATTRIBUTES, SCHEMA_URL, ATTRIBUTES_LIST}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class ResourceModel { + static final String ATTRIBUTES = "attributes"; + static final String SCHEMA_URL = "schema_url"; + static final String ATTRIBUTES_LIST = "attributes_list"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(SCHEMA_URL, String.class); + STABLE_PROPERTIES.put(ATTRIBUTES_LIST, String.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private List attributes; - @Nullable private ExperimentalResourceDetectionModel detectionDevelopment; @Nullable private String schemaUrl; @Nullable private String attributesList; + private Map extensionProperties = new LinkedHashMap(); /** * Configure resource attributes. Entries have higher priority than entries from @@ -29,48 +53,33 @@ public class ResourceModel { * *

If omitted, no resource attributes are added. */ - @JsonProperty("attributes") + @JsonProperty(ATTRIBUTES) @Nullable public List getAttributes() { return attributes; } - @JsonProperty("attributes") + @JsonProperty(ATTRIBUTES) public ResourceModel withAttributes(List attributes) { this.attributes = attributes; return this; } - /** - * Configure resource detection. - * - *

If omitted, resource detection is disabled. - */ - @JsonProperty("detection/development") - @Nullable - public ExperimentalResourceDetectionModel getDetectionDevelopment() { - return detectionDevelopment; - } - - @JsonProperty("detection/development") - public ResourceModel withDetectionDevelopment( - ExperimentalResourceDetectionModel detectionDevelopment) { - this.detectionDevelopment = detectionDevelopment; - return this; - } - /** * Configure resource schema URL. * *

If omitted or null, no schema URL is used. */ - @JsonProperty("schema_url") + @JsonProperty(SCHEMA_URL) @Nullable public String getSchemaUrl() { + if (schemaUrl == null) { + return ExtensionPropertyUtil.getGraduated(SCHEMA_URL, extensionProperties, String.class); + } return schemaUrl; } - @JsonProperty("schema_url") + @JsonProperty(SCHEMA_URL) public ResourceModel withSchemaUrl(String schemaUrl) { this.schemaUrl = schemaUrl; return this; @@ -87,29 +96,49 @@ public ResourceModel withSchemaUrl(String schemaUrl) { * *

If omitted or null, no resource attributes are added. */ - @JsonProperty("attributes_list") + @JsonProperty(ATTRIBUTES_LIST) @Nullable public String getAttributesList() { + if (attributesList == null) { + return ExtensionPropertyUtil.getGraduated(ATTRIBUTES_LIST, extensionProperties, String.class); + } return attributesList; } - @JsonProperty("attributes_list") + @JsonProperty(ATTRIBUTES_LIST) public ResourceModel withAttributesList(String attributesList) { this.attributesList = attributesList; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public ResourceModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + EXPERIMENTAL_PROPERTIES, + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "ResourceModel{" + "attributes=" + attributes - + ", detectionDevelopment=" - + detectionDevelopment + ", schemaUrl=" + schemaUrl + ", attributesList=" + attributesList + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -119,11 +148,11 @@ public int hashCode() { h *= 1000003; h ^= (this.attributes == null) ? 0 : this.attributes.hashCode(); h *= 1000003; - h ^= (this.detectionDevelopment == null) ? 0 : this.detectionDevelopment.hashCode(); - h *= 1000003; h ^= (this.schemaUrl == null) ? 0 : this.schemaUrl.hashCode(); h *= 1000003; h ^= (this.attributesList == null) ? 0 : this.attributesList.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -137,15 +166,15 @@ public boolean equals(@Nullable Object o) { return (this.attributes == null ? that.attributes == null : this.attributes.equals(that.attributes)) - && (this.detectionDevelopment == null - ? that.detectionDevelopment == null - : this.detectionDevelopment.equals(that.detectionDevelopment)) && (this.schemaUrl == null ? that.schemaUrl == null : this.schemaUrl.equals(that.schemaUrl)) && (this.attributesList == null ? that.attributesList == null - : this.attributesList.equals(that.attributesList)); + : this.attributesList.equals(that.attributesList)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SamplerModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SamplerModel.java index e1bdccdc782..6021ebebfe8 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SamplerModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SamplerModel.java @@ -5,54 +5,68 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SamplerModel.ALWAYS_OFF; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SamplerModel.ALWAYS_ON; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SamplerModel.PARENT_BASED; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SamplerModel.TRACE_ID_RATIO_BASED; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.SamplerModelAccessor.EXPERIMENTAL_PROPERTIES; + import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalComposableSamplerModel; -import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalJaegerRemoteSamplerModel; -import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalProbabilitySamplerModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "always_off", - "always_on", - "composite/development", - "jaeger_remote/development", - "parent_based", - "probability/development", - "trace_id_ratio_based" -}) +@JsonPropertyOrder({ALWAYS_OFF, ALWAYS_ON, PARENT_BASED, TRACE_ID_RATIO_BASED}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class SamplerModel { + static final String ALWAYS_OFF = "always_off"; + static final String ALWAYS_ON = "always_on"; + static final String PARENT_BASED = "parent_based"; + static final String TRACE_ID_RATIO_BASED = "trace_id_ratio_based"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(ALWAYS_OFF, AlwaysOffSamplerModel.class); + STABLE_PROPERTIES.put(ALWAYS_ON, AlwaysOnSamplerModel.class); + STABLE_PROPERTIES.put(PARENT_BASED, ParentBasedSamplerModel.class); + STABLE_PROPERTIES.put(TRACE_ID_RATIO_BASED, TraceIdRatioBasedSamplerModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = true; + @Nullable private AlwaysOffSamplerModel alwaysOff; @Nullable private AlwaysOnSamplerModel alwaysOn; - @Nullable private ExperimentalComposableSamplerModel compositeDevelopment; - @Nullable private ExperimentalJaegerRemoteSamplerModel jaegerRemoteDevelopment; @Nullable private ParentBasedSamplerModel parentBased; - @Nullable private ExperimentalProbabilitySamplerModel probabilityDevelopment; @Nullable private TraceIdRatioBasedSamplerModel traceIdRatioBased; - private Map additionalProperties = - new LinkedHashMap(); + private Map extensionProperties = new LinkedHashMap(); /** * Configure sampler to be always_off. * *

If omitted, ignore. */ - @JsonProperty("always_off") + @JsonProperty(ALWAYS_OFF) @Nullable public AlwaysOffSamplerModel getAlwaysOff() { + if (alwaysOff == null) { + return ExtensionPropertyUtil.getGraduated( + ALWAYS_OFF, extensionProperties, AlwaysOffSamplerModel.class); + } return alwaysOff; } - @JsonProperty("always_off") + @JsonProperty(ALWAYS_OFF) public SamplerModel withAlwaysOff(AlwaysOffSamplerModel alwaysOff) { this.alwaysOff = alwaysOff; return this; @@ -63,114 +77,78 @@ public SamplerModel withAlwaysOff(AlwaysOffSamplerModel alwaysOff) { * *

If omitted, ignore. */ - @JsonProperty("always_on") + @JsonProperty(ALWAYS_ON) @Nullable public AlwaysOnSamplerModel getAlwaysOn() { + if (alwaysOn == null) { + return ExtensionPropertyUtil.getGraduated( + ALWAYS_ON, extensionProperties, AlwaysOnSamplerModel.class); + } return alwaysOn; } - @JsonProperty("always_on") + @JsonProperty(ALWAYS_ON) public SamplerModel withAlwaysOn(AlwaysOnSamplerModel alwaysOn) { this.alwaysOn = alwaysOn; return this; } - /** - * Configure sampler to be composite. - * - *

If omitted, ignore. - */ - @JsonProperty("composite/development") - @Nullable - public ExperimentalComposableSamplerModel getCompositeDevelopment() { - return compositeDevelopment; - } - - @JsonProperty("composite/development") - public SamplerModel withCompositeDevelopment( - ExperimentalComposableSamplerModel compositeDevelopment) { - this.compositeDevelopment = compositeDevelopment; - return this; - } - - /** - * Configure sampler to be jaeger_remote. - * - *

If omitted, ignore. - */ - @JsonProperty("jaeger_remote/development") - @Nullable - public ExperimentalJaegerRemoteSamplerModel getJaegerRemoteDevelopment() { - return jaegerRemoteDevelopment; - } - - @JsonProperty("jaeger_remote/development") - public SamplerModel withJaegerRemoteDevelopment( - ExperimentalJaegerRemoteSamplerModel jaegerRemoteDevelopment) { - this.jaegerRemoteDevelopment = jaegerRemoteDevelopment; - return this; - } - /** * Configure sampler to be parent_based. * *

If omitted, ignore. */ - @JsonProperty("parent_based") + @JsonProperty(PARENT_BASED) @Nullable public ParentBasedSamplerModel getParentBased() { + if (parentBased == null) { + return ExtensionPropertyUtil.getGraduated( + PARENT_BASED, extensionProperties, ParentBasedSamplerModel.class); + } return parentBased; } - @JsonProperty("parent_based") + @JsonProperty(PARENT_BASED) public SamplerModel withParentBased(ParentBasedSamplerModel parentBased) { this.parentBased = parentBased; return this; } - /** - * Configure sampler to be probability. - * - *

If omitted, ignore. - */ - @JsonProperty("probability/development") - @Nullable - public ExperimentalProbabilitySamplerModel getProbabilityDevelopment() { - return probabilityDevelopment; - } - - @JsonProperty("probability/development") - public SamplerModel withProbabilityDevelopment( - ExperimentalProbabilitySamplerModel probabilityDevelopment) { - this.probabilityDevelopment = probabilityDevelopment; - return this; - } - /** * Configure sampler to be trace_id_ratio_based. * *

If omitted, ignore. */ - @JsonProperty("trace_id_ratio_based") + @JsonProperty(TRACE_ID_RATIO_BASED) @Nullable public TraceIdRatioBasedSamplerModel getTraceIdRatioBased() { + if (traceIdRatioBased == null) { + return ExtensionPropertyUtil.getGraduated( + TRACE_ID_RATIO_BASED, extensionProperties, TraceIdRatioBasedSamplerModel.class); + } return traceIdRatioBased; } - @JsonProperty("trace_id_ratio_based") + @JsonProperty(TRACE_ID_RATIO_BASED) public SamplerModel withTraceIdRatioBased(TraceIdRatioBasedSamplerModel traceIdRatioBased) { this.traceIdRatioBased = traceIdRatioBased; return this; } @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); } @JsonAnySetter - public SamplerModel withAdditionalProperty(String name, SamplerPropertyModel value) { - this.additionalProperties.put(name, value); + public SamplerModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + EXPERIMENTAL_PROPERTIES, + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); return this; } @@ -181,18 +159,12 @@ public String toString() { + alwaysOff + ", alwaysOn=" + alwaysOn - + ", compositeDevelopment=" - + compositeDevelopment - + ", jaegerRemoteDevelopment=" - + jaegerRemoteDevelopment + ", parentBased=" + parentBased - + ", probabilityDevelopment=" - + probabilityDevelopment + ", traceIdRatioBased=" + traceIdRatioBased - + ", additionalProperties=" - + additionalProperties + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -204,17 +176,11 @@ public int hashCode() { h *= 1000003; h ^= (this.alwaysOn == null) ? 0 : this.alwaysOn.hashCode(); h *= 1000003; - h ^= (this.compositeDevelopment == null) ? 0 : this.compositeDevelopment.hashCode(); - h *= 1000003; - h ^= (this.jaegerRemoteDevelopment == null) ? 0 : this.jaegerRemoteDevelopment.hashCode(); - h *= 1000003; h ^= (this.parentBased == null) ? 0 : this.parentBased.hashCode(); h *= 1000003; - h ^= (this.probabilityDevelopment == null) ? 0 : this.probabilityDevelopment.hashCode(); - h *= 1000003; h ^= (this.traceIdRatioBased == null) ? 0 : this.traceIdRatioBased.hashCode(); h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -229,24 +195,15 @@ public boolean equals(@Nullable Object o) { ? that.alwaysOff == null : this.alwaysOff.equals(that.alwaysOff)) && (this.alwaysOn == null ? that.alwaysOn == null : this.alwaysOn.equals(that.alwaysOn)) - && (this.compositeDevelopment == null - ? that.compositeDevelopment == null - : this.compositeDevelopment.equals(that.compositeDevelopment)) - && (this.jaegerRemoteDevelopment == null - ? that.jaegerRemoteDevelopment == null - : this.jaegerRemoteDevelopment.equals(that.jaegerRemoteDevelopment)) && (this.parentBased == null ? that.parentBased == null : this.parentBased.equals(that.parentBased)) - && (this.probabilityDevelopment == null - ? that.probabilityDevelopment == null - : this.probabilityDevelopment.equals(that.probabilityDevelopment)) && (this.traceIdRatioBased == null ? that.traceIdRatioBased == null : this.traceIdRatioBased.equals(that.traceIdRatioBased)) - && (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SamplerPropertyModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SamplerPropertyModel.java deleted file mode 100644 index d2a8a40e355..00000000000 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SamplerPropertyModel.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.util.LinkedHashMap; -import java.util.Map; -import javax.annotation.Generated; -import javax.annotation.Nullable; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({}) -@Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") -public class SamplerPropertyModel { - - private Map additionalProperties = new LinkedHashMap(); - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public SamplerPropertyModel withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - - @Override - public String toString() { - return "SamplerPropertyModel{" + "additionalProperties=" + additionalProperties + "}"; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); - return h; - } - - @Override - public boolean equals(@Nullable Object o) { - if (o == this) { - return true; - } - if (o instanceof SamplerPropertyModel) { - SamplerPropertyModel that = (SamplerPropertyModel) o; - return (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); - } - return false; - } -} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SimpleLogRecordProcessorModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SimpleLogRecordProcessorModel.java index 3db8f96772c..460ce258379 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SimpleLogRecordProcessorModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SimpleLogRecordProcessorModel.java @@ -5,39 +5,86 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SimpleLogRecordProcessorModel.EXPORTER; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"exporter"}) +@JsonPropertyOrder({EXPORTER}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class SimpleLogRecordProcessorModel { + static final String EXPORTER = "exporter"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(EXPORTER, LogRecordExporterModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private LogRecordExporterModel exporter; + private Map extensionProperties = new LinkedHashMap(); /** * Configure exporter. * *

Property is required and must be non-null. */ - @JsonProperty("exporter") + @JsonProperty(EXPORTER) @Nullable public LogRecordExporterModel getExporter() { + if (exporter == null) { + return ExtensionPropertyUtil.getGraduated( + EXPORTER, extensionProperties, LogRecordExporterModel.class); + } return exporter; } - @JsonProperty("exporter") + @JsonProperty(EXPORTER) public SimpleLogRecordProcessorModel withExporter(LogRecordExporterModel exporter) { this.exporter = exporter; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public SimpleLogRecordProcessorModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { - return "SimpleLogRecordProcessorModel{" + "exporter=" + exporter + "}"; + return "SimpleLogRecordProcessorModel{" + + "exporter=" + + exporter + + ", extensionProperties=" + + extensionProperties + + "}"; } @Override @@ -45,6 +92,8 @@ public int hashCode() { int h = 1; h *= 1000003; h ^= (this.exporter == null) ? 0 : this.exporter.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -55,7 +104,10 @@ public boolean equals(@Nullable Object o) { } if (o instanceof SimpleLogRecordProcessorModel) { SimpleLogRecordProcessorModel that = (SimpleLogRecordProcessorModel) o; - return (this.exporter == null ? that.exporter == null : this.exporter.equals(that.exporter)); + return (this.exporter == null ? that.exporter == null : this.exporter.equals(that.exporter)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SimpleSpanProcessorModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SimpleSpanProcessorModel.java index 441175aaadc..e502c54428e 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SimpleSpanProcessorModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SimpleSpanProcessorModel.java @@ -5,39 +5,86 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SimpleSpanProcessorModel.EXPORTER; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"exporter"}) +@JsonPropertyOrder({EXPORTER}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class SimpleSpanProcessorModel { + static final String EXPORTER = "exporter"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(EXPORTER, SpanExporterModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private SpanExporterModel exporter; + private Map extensionProperties = new LinkedHashMap(); /** * Configure exporter. * *

Property is required and must be non-null. */ - @JsonProperty("exporter") + @JsonProperty(EXPORTER) @Nullable public SpanExporterModel getExporter() { + if (exporter == null) { + return ExtensionPropertyUtil.getGraduated( + EXPORTER, extensionProperties, SpanExporterModel.class); + } return exporter; } - @JsonProperty("exporter") + @JsonProperty(EXPORTER) public SimpleSpanProcessorModel withExporter(SpanExporterModel exporter) { this.exporter = exporter; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public SimpleSpanProcessorModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { - return "SimpleSpanProcessorModel{" + "exporter=" + exporter + "}"; + return "SimpleSpanProcessorModel{" + + "exporter=" + + exporter + + ", extensionProperties=" + + extensionProperties + + "}"; } @Override @@ -45,6 +92,8 @@ public int hashCode() { int h = 1; h *= 1000003; h ^= (this.exporter == null) ? 0 : this.exporter.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -55,7 +104,10 @@ public boolean equals(@Nullable Object o) { } if (o instanceof SimpleSpanProcessorModel) { SimpleSpanProcessorModel that = (SimpleSpanProcessorModel) o; - return (this.exporter == null ? that.exporter == null : this.exporter.equals(that.exporter)); + return (this.exporter == null ? that.exporter == null : this.exporter.equals(that.exporter)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SpanExporterModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SpanExporterModel.java index 20aec6f4cf5..a19d96e0af7 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SpanExporterModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SpanExporterModel.java @@ -5,41 +5,64 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SpanExporterModel.CONSOLE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SpanExporterModel.OTLP_GRPC; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SpanExporterModel.OTLP_HTTP; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.SpanExporterModelAccessor.EXPERIMENTAL_PROPERTIES; + import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalOtlpFileExporterModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"otlp_http", "otlp_grpc", "otlp_file/development", "console"}) +@JsonPropertyOrder({OTLP_HTTP, OTLP_GRPC, CONSOLE}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class SpanExporterModel { + static final String OTLP_HTTP = "otlp_http"; + static final String OTLP_GRPC = "otlp_grpc"; + static final String CONSOLE = "console"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(OTLP_HTTP, OtlpHttpExporterModel.class); + STABLE_PROPERTIES.put(OTLP_GRPC, OtlpGrpcExporterModel.class); + STABLE_PROPERTIES.put(CONSOLE, ConsoleExporterModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = true; + @Nullable private OtlpHttpExporterModel otlpHttp; @Nullable private OtlpGrpcExporterModel otlpGrpc; - @Nullable private ExperimentalOtlpFileExporterModel otlpFileDevelopment; @Nullable private ConsoleExporterModel console; - private Map additionalProperties = - new LinkedHashMap(); + private Map extensionProperties = new LinkedHashMap(); /** * Configure exporter to be OTLP with HTTP transport. * *

If omitted, ignore. */ - @JsonProperty("otlp_http") + @JsonProperty(OTLP_HTTP) @Nullable public OtlpHttpExporterModel getOtlpHttp() { + if (otlpHttp == null) { + return ExtensionPropertyUtil.getGraduated( + OTLP_HTTP, extensionProperties, OtlpHttpExporterModel.class); + } return otlpHttp; } - @JsonProperty("otlp_http") + @JsonProperty(OTLP_HTTP) public SpanExporterModel withOtlpHttp(OtlpHttpExporterModel otlpHttp) { this.otlpHttp = otlpHttp; return this; @@ -50,61 +73,57 @@ public SpanExporterModel withOtlpHttp(OtlpHttpExporterModel otlpHttp) { * *

If omitted, ignore. */ - @JsonProperty("otlp_grpc") + @JsonProperty(OTLP_GRPC) @Nullable public OtlpGrpcExporterModel getOtlpGrpc() { + if (otlpGrpc == null) { + return ExtensionPropertyUtil.getGraduated( + OTLP_GRPC, extensionProperties, OtlpGrpcExporterModel.class); + } return otlpGrpc; } - @JsonProperty("otlp_grpc") + @JsonProperty(OTLP_GRPC) public SpanExporterModel withOtlpGrpc(OtlpGrpcExporterModel otlpGrpc) { this.otlpGrpc = otlpGrpc; return this; } - /** - * Configure exporter to be OTLP with file transport. - * - *

If omitted, ignore. - */ - @JsonProperty("otlp_file/development") - @Nullable - public ExperimentalOtlpFileExporterModel getOtlpFileDevelopment() { - return otlpFileDevelopment; - } - - @JsonProperty("otlp_file/development") - public SpanExporterModel withOtlpFileDevelopment( - ExperimentalOtlpFileExporterModel otlpFileDevelopment) { - this.otlpFileDevelopment = otlpFileDevelopment; - return this; - } - /** * Configure exporter to be console. * *

If omitted, ignore. */ - @JsonProperty("console") + @JsonProperty(CONSOLE) @Nullable public ConsoleExporterModel getConsole() { + if (console == null) { + return ExtensionPropertyUtil.getGraduated( + CONSOLE, extensionProperties, ConsoleExporterModel.class); + } return console; } - @JsonProperty("console") + @JsonProperty(CONSOLE) public SpanExporterModel withConsole(ConsoleExporterModel console) { this.console = console; return this; } @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); } @JsonAnySetter - public SpanExporterModel withAdditionalProperty(String name, SpanExporterPropertyModel value) { - this.additionalProperties.put(name, value); + public SpanExporterModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + EXPERIMENTAL_PROPERTIES, + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); return this; } @@ -115,12 +134,10 @@ public String toString() { + otlpHttp + ", otlpGrpc=" + otlpGrpc - + ", otlpFileDevelopment=" - + otlpFileDevelopment + ", console=" + console - + ", additionalProperties=" - + additionalProperties + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -132,11 +149,9 @@ public int hashCode() { h *= 1000003; h ^= (this.otlpGrpc == null) ? 0 : this.otlpGrpc.hashCode(); h *= 1000003; - h ^= (this.otlpFileDevelopment == null) ? 0 : this.otlpFileDevelopment.hashCode(); - h *= 1000003; h ^= (this.console == null) ? 0 : this.console.hashCode(); h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -149,13 +164,10 @@ public boolean equals(@Nullable Object o) { SpanExporterModel that = (SpanExporterModel) o; return (this.otlpHttp == null ? that.otlpHttp == null : this.otlpHttp.equals(that.otlpHttp)) && (this.otlpGrpc == null ? that.otlpGrpc == null : this.otlpGrpc.equals(that.otlpGrpc)) - && (this.otlpFileDevelopment == null - ? that.otlpFileDevelopment == null - : this.otlpFileDevelopment.equals(that.otlpFileDevelopment)) && (this.console == null ? that.console == null : this.console.equals(that.console)) - && (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SpanExporterPropertyModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SpanExporterPropertyModel.java deleted file mode 100644 index a2e323f35a3..00000000000 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SpanExporterPropertyModel.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.util.LinkedHashMap; -import java.util.Map; -import javax.annotation.Generated; -import javax.annotation.Nullable; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({}) -@Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") -public class SpanExporterPropertyModel { - - private Map additionalProperties = new LinkedHashMap(); - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public SpanExporterPropertyModel withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - - @Override - public String toString() { - return "SpanExporterPropertyModel{" + "additionalProperties=" + additionalProperties + "}"; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); - return h; - } - - @Override - public boolean equals(@Nullable Object o) { - if (o == this) { - return true; - } - if (o instanceof SpanExporterPropertyModel) { - SpanExporterPropertyModel that = (SpanExporterPropertyModel) o; - return (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); - } - return false; - } -} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SpanLimitsModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SpanLimitsModel.java index 3acd087605c..285f702270f 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SpanLimitsModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SpanLimitsModel.java @@ -5,30 +5,66 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SpanLimitsModel.ATTRIBUTE_COUNT_LIMIT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SpanLimitsModel.ATTRIBUTE_VALUE_LENGTH_LIMIT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SpanLimitsModel.EVENT_ATTRIBUTE_COUNT_LIMIT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SpanLimitsModel.EVENT_COUNT_LIMIT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SpanLimitsModel.LINK_ATTRIBUTE_COUNT_LIMIT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SpanLimitsModel.LINK_COUNT_LIMIT; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ - "attribute_value_length_limit", - "attribute_count_limit", - "event_count_limit", - "link_count_limit", - "event_attribute_count_limit", - "link_attribute_count_limit" + ATTRIBUTE_VALUE_LENGTH_LIMIT, + ATTRIBUTE_COUNT_LIMIT, + EVENT_COUNT_LIMIT, + LINK_COUNT_LIMIT, + EVENT_ATTRIBUTE_COUNT_LIMIT, + LINK_ATTRIBUTE_COUNT_LIMIT }) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class SpanLimitsModel { + static final String ATTRIBUTE_VALUE_LENGTH_LIMIT = "attribute_value_length_limit"; + static final String ATTRIBUTE_COUNT_LIMIT = "attribute_count_limit"; + static final String EVENT_COUNT_LIMIT = "event_count_limit"; + static final String LINK_COUNT_LIMIT = "link_count_limit"; + static final String EVENT_ATTRIBUTE_COUNT_LIMIT = "event_attribute_count_limit"; + static final String LINK_ATTRIBUTE_COUNT_LIMIT = "link_attribute_count_limit"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(ATTRIBUTE_VALUE_LENGTH_LIMIT, Integer.class); + STABLE_PROPERTIES.put(ATTRIBUTE_COUNT_LIMIT, Integer.class); + STABLE_PROPERTIES.put(EVENT_COUNT_LIMIT, Integer.class); + STABLE_PROPERTIES.put(LINK_COUNT_LIMIT, Integer.class); + STABLE_PROPERTIES.put(EVENT_ATTRIBUTE_COUNT_LIMIT, Integer.class); + STABLE_PROPERTIES.put(LINK_ATTRIBUTE_COUNT_LIMIT, Integer.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private Integer attributeValueLengthLimit; @Nullable private Integer attributeCountLimit; @Nullable private Integer eventCountLimit; @Nullable private Integer linkCountLimit; @Nullable private Integer eventAttributeCountLimit; @Nullable private Integer linkAttributeCountLimit; + private Map extensionProperties = new LinkedHashMap(); /** * Configure max attribute value size. Overrides .attribute_limits.attribute_value_length_limit. @@ -37,13 +73,17 @@ public class SpanLimitsModel { * *

If omitted or null, there is no limit. */ - @JsonProperty("attribute_value_length_limit") + @JsonProperty(ATTRIBUTE_VALUE_LENGTH_LIMIT) @Nullable public Integer getAttributeValueLengthLimit() { + if (attributeValueLengthLimit == null) { + return ExtensionPropertyUtil.getGraduated( + ATTRIBUTE_VALUE_LENGTH_LIMIT, extensionProperties, Integer.class); + } return attributeValueLengthLimit; } - @JsonProperty("attribute_value_length_limit") + @JsonProperty(ATTRIBUTE_VALUE_LENGTH_LIMIT) public SpanLimitsModel withAttributeValueLengthLimit(Integer attributeValueLengthLimit) { this.attributeValueLengthLimit = attributeValueLengthLimit; return this; @@ -56,13 +96,17 @@ public SpanLimitsModel withAttributeValueLengthLimit(Integer attributeValueLengt * *

If omitted or null, 128 is used. */ - @JsonProperty("attribute_count_limit") + @JsonProperty(ATTRIBUTE_COUNT_LIMIT) @Nullable public Integer getAttributeCountLimit() { + if (attributeCountLimit == null) { + return ExtensionPropertyUtil.getGraduated( + ATTRIBUTE_COUNT_LIMIT, extensionProperties, Integer.class); + } return attributeCountLimit; } - @JsonProperty("attribute_count_limit") + @JsonProperty(ATTRIBUTE_COUNT_LIMIT) public SpanLimitsModel withAttributeCountLimit(Integer attributeCountLimit) { this.attributeCountLimit = attributeCountLimit; return this; @@ -75,13 +119,17 @@ public SpanLimitsModel withAttributeCountLimit(Integer attributeCountLimit) { * *

If omitted or null, 128 is used. */ - @JsonProperty("event_count_limit") + @JsonProperty(EVENT_COUNT_LIMIT) @Nullable public Integer getEventCountLimit() { + if (eventCountLimit == null) { + return ExtensionPropertyUtil.getGraduated( + EVENT_COUNT_LIMIT, extensionProperties, Integer.class); + } return eventCountLimit; } - @JsonProperty("event_count_limit") + @JsonProperty(EVENT_COUNT_LIMIT) public SpanLimitsModel withEventCountLimit(Integer eventCountLimit) { this.eventCountLimit = eventCountLimit; return this; @@ -94,13 +142,17 @@ public SpanLimitsModel withEventCountLimit(Integer eventCountLimit) { * *

If omitted or null, 128 is used. */ - @JsonProperty("link_count_limit") + @JsonProperty(LINK_COUNT_LIMIT) @Nullable public Integer getLinkCountLimit() { + if (linkCountLimit == null) { + return ExtensionPropertyUtil.getGraduated( + LINK_COUNT_LIMIT, extensionProperties, Integer.class); + } return linkCountLimit; } - @JsonProperty("link_count_limit") + @JsonProperty(LINK_COUNT_LIMIT) public SpanLimitsModel withLinkCountLimit(Integer linkCountLimit) { this.linkCountLimit = linkCountLimit; return this; @@ -113,13 +165,17 @@ public SpanLimitsModel withLinkCountLimit(Integer linkCountLimit) { * *

If omitted or null, 128 is used. */ - @JsonProperty("event_attribute_count_limit") + @JsonProperty(EVENT_ATTRIBUTE_COUNT_LIMIT) @Nullable public Integer getEventAttributeCountLimit() { + if (eventAttributeCountLimit == null) { + return ExtensionPropertyUtil.getGraduated( + EVENT_ATTRIBUTE_COUNT_LIMIT, extensionProperties, Integer.class); + } return eventAttributeCountLimit; } - @JsonProperty("event_attribute_count_limit") + @JsonProperty(EVENT_ATTRIBUTE_COUNT_LIMIT) public SpanLimitsModel withEventAttributeCountLimit(Integer eventAttributeCountLimit) { this.eventAttributeCountLimit = eventAttributeCountLimit; return this; @@ -132,18 +188,39 @@ public SpanLimitsModel withEventAttributeCountLimit(Integer eventAttributeCountL * *

If omitted or null, 128 is used. */ - @JsonProperty("link_attribute_count_limit") + @JsonProperty(LINK_ATTRIBUTE_COUNT_LIMIT) @Nullable public Integer getLinkAttributeCountLimit() { + if (linkAttributeCountLimit == null) { + return ExtensionPropertyUtil.getGraduated( + LINK_ATTRIBUTE_COUNT_LIMIT, extensionProperties, Integer.class); + } return linkAttributeCountLimit; } - @JsonProperty("link_attribute_count_limit") + @JsonProperty(LINK_ATTRIBUTE_COUNT_LIMIT) public SpanLimitsModel withLinkAttributeCountLimit(Integer linkAttributeCountLimit) { this.linkAttributeCountLimit = linkAttributeCountLimit; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public SpanLimitsModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "SpanLimitsModel{" @@ -159,6 +236,8 @@ public String toString() { + eventAttributeCountLimit + ", linkAttributeCountLimit=" + linkAttributeCountLimit + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -177,6 +256,8 @@ public int hashCode() { h ^= (this.eventAttributeCountLimit == null) ? 0 : this.eventAttributeCountLimit.hashCode(); h *= 1000003; h ^= (this.linkAttributeCountLimit == null) ? 0 : this.linkAttributeCountLimit.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -204,7 +285,10 @@ public boolean equals(@Nullable Object o) { : this.eventAttributeCountLimit.equals(that.eventAttributeCountLimit)) && (this.linkAttributeCountLimit == null ? that.linkAttributeCountLimit == null - : this.linkAttributeCountLimit.equals(that.linkAttributeCountLimit)); + : this.linkAttributeCountLimit.equals(that.linkAttributeCountLimit)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SpanProcessorModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SpanProcessorModel.java index 1a50b6bd02e..2094ba22a5e 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SpanProcessorModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SpanProcessorModel.java @@ -5,38 +5,60 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SpanProcessorModel.BATCH; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SpanProcessorModel.SIMPLE; + import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"batch", "simple"}) +@JsonPropertyOrder({BATCH, SIMPLE}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class SpanProcessorModel { + static final String BATCH = "batch"; + static final String SIMPLE = "simple"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(BATCH, BatchSpanProcessorModel.class); + STABLE_PROPERTIES.put(SIMPLE, SimpleSpanProcessorModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = true; + @Nullable private BatchSpanProcessorModel batch; @Nullable private SimpleSpanProcessorModel simple; - private Map additionalProperties = - new LinkedHashMap(); + private Map extensionProperties = new LinkedHashMap(); /** * Configure a batch span processor. * *

If omitted, ignore. */ - @JsonProperty("batch") + @JsonProperty(BATCH) @Nullable public BatchSpanProcessorModel getBatch() { + if (batch == null) { + return ExtensionPropertyUtil.getGraduated( + BATCH, extensionProperties, BatchSpanProcessorModel.class); + } return batch; } - @JsonProperty("batch") + @JsonProperty(BATCH) public SpanProcessorModel withBatch(BatchSpanProcessorModel batch) { this.batch = batch; return this; @@ -47,26 +69,36 @@ public SpanProcessorModel withBatch(BatchSpanProcessorModel batch) { * *

If omitted, ignore. */ - @JsonProperty("simple") + @JsonProperty(SIMPLE) @Nullable public SimpleSpanProcessorModel getSimple() { + if (simple == null) { + return ExtensionPropertyUtil.getGraduated( + SIMPLE, extensionProperties, SimpleSpanProcessorModel.class); + } return simple; } - @JsonProperty("simple") + @JsonProperty(SIMPLE) public SpanProcessorModel withSimple(SimpleSpanProcessorModel simple) { this.simple = simple; return this; } @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); } @JsonAnySetter - public SpanProcessorModel withAdditionalProperty(String name, SpanProcessorPropertyModel value) { - this.additionalProperties.put(name, value); + public SpanProcessorModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); return this; } @@ -77,8 +109,8 @@ public String toString() { + batch + ", simple=" + simple - + ", additionalProperties=" - + additionalProperties + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -90,7 +122,7 @@ public int hashCode() { h *= 1000003; h ^= (this.simple == null) ? 0 : this.simple.hashCode(); h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -103,9 +135,9 @@ public boolean equals(@Nullable Object o) { SpanProcessorModel that = (SpanProcessorModel) o; return (this.batch == null ? that.batch == null : this.batch.equals(that.batch)) && (this.simple == null ? that.simple == null : this.simple.equals(that.simple)) - && (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SpanProcessorPropertyModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SpanProcessorPropertyModel.java deleted file mode 100644 index 4dbcfc9624e..00000000000 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/SpanProcessorPropertyModel.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.util.LinkedHashMap; -import java.util.Map; -import javax.annotation.Generated; -import javax.annotation.Nullable; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({}) -@Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") -public class SpanProcessorPropertyModel { - - private Map additionalProperties = new LinkedHashMap(); - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public SpanProcessorPropertyModel withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - - @Override - public String toString() { - return "SpanProcessorPropertyModel{" + "additionalProperties=" + additionalProperties + "}"; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); - return h; - } - - @Override - public boolean equals(@Nullable Object o) { - if (o == this) { - return true; - } - if (o instanceof SpanProcessorPropertyModel) { - SpanProcessorPropertyModel that = (SpanProcessorPropertyModel) o; - return (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); - } - return false; - } -} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/TextMapPropagatorModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/TextMapPropagatorModel.java index 5e36c249962..54af1a79b02 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/TextMapPropagatorModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/TextMapPropagatorModel.java @@ -5,40 +5,68 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.TextMapPropagatorModel.BAGGAGE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.TextMapPropagatorModel.B_3; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.TextMapPropagatorModel.B_3_MULTI; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.TextMapPropagatorModel.TRACECONTEXT; + import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"tracecontext", "baggage", "b3", "b3multi"}) +@JsonPropertyOrder({TRACECONTEXT, BAGGAGE, B_3, B_3_MULTI}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class TextMapPropagatorModel { + static final String TRACECONTEXT = "tracecontext"; + static final String BAGGAGE = "baggage"; + static final String B_3 = "b3"; + static final String B_3_MULTI = "b3multi"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(TRACECONTEXT, TraceContextPropagatorModel.class); + STABLE_PROPERTIES.put(BAGGAGE, BaggagePropagatorModel.class); + STABLE_PROPERTIES.put(B_3, B3PropagatorModel.class); + STABLE_PROPERTIES.put(B_3_MULTI, B3MultiPropagatorModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = true; + @Nullable private TraceContextPropagatorModel tracecontext; @Nullable private BaggagePropagatorModel baggage; @Nullable private B3PropagatorModel b3; @Nullable private B3MultiPropagatorModel b3multi; - private Map additionalProperties = - new LinkedHashMap(); + private Map extensionProperties = new LinkedHashMap(); /** * Include the w3c trace context propagator. * *

If omitted, ignore. */ - @JsonProperty("tracecontext") + @JsonProperty(TRACECONTEXT) @Nullable public TraceContextPropagatorModel getTracecontext() { + if (tracecontext == null) { + return ExtensionPropertyUtil.getGraduated( + TRACECONTEXT, extensionProperties, TraceContextPropagatorModel.class); + } return tracecontext; } - @JsonProperty("tracecontext") + @JsonProperty(TRACECONTEXT) public TextMapPropagatorModel withTracecontext(TraceContextPropagatorModel tracecontext) { this.tracecontext = tracecontext; return this; @@ -49,13 +77,17 @@ public TextMapPropagatorModel withTracecontext(TraceContextPropagatorModel trace * *

If omitted, ignore. */ - @JsonProperty("baggage") + @JsonProperty(BAGGAGE) @Nullable public BaggagePropagatorModel getBaggage() { + if (baggage == null) { + return ExtensionPropertyUtil.getGraduated( + BAGGAGE, extensionProperties, BaggagePropagatorModel.class); + } return baggage; } - @JsonProperty("baggage") + @JsonProperty(BAGGAGE) public TextMapPropagatorModel withBaggage(BaggagePropagatorModel baggage) { this.baggage = baggage; return this; @@ -66,13 +98,16 @@ public TextMapPropagatorModel withBaggage(BaggagePropagatorModel baggage) { * *

If omitted, ignore. */ - @JsonProperty("b3") + @JsonProperty(B_3) @Nullable public B3PropagatorModel getB3() { + if (b3 == null) { + return ExtensionPropertyUtil.getGraduated(B_3, extensionProperties, B3PropagatorModel.class); + } return b3; } - @JsonProperty("b3") + @JsonProperty(B_3) public TextMapPropagatorModel withB3(B3PropagatorModel b3) { this.b3 = b3; return this; @@ -83,27 +118,36 @@ public TextMapPropagatorModel withB3(B3PropagatorModel b3) { * *

If omitted, ignore. */ - @JsonProperty("b3multi") + @JsonProperty(B_3_MULTI) @Nullable public B3MultiPropagatorModel getB3multi() { + if (b3multi == null) { + return ExtensionPropertyUtil.getGraduated( + B_3_MULTI, extensionProperties, B3MultiPropagatorModel.class); + } return b3multi; } - @JsonProperty("b3multi") + @JsonProperty(B_3_MULTI) public TextMapPropagatorModel withB3multi(B3MultiPropagatorModel b3multi) { this.b3multi = b3multi; return this; } @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); } @JsonAnySetter - public TextMapPropagatorModel withAdditionalProperty( - String name, TextMapPropagatorPropertyModel value) { - this.additionalProperties.put(name, value); + public TextMapPropagatorModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); return this; } @@ -118,8 +162,8 @@ public String toString() { + b3 + ", b3multi=" + b3multi - + ", additionalProperties=" - + additionalProperties + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -135,7 +179,7 @@ public int hashCode() { h *= 1000003; h ^= (this.b3multi == null) ? 0 : this.b3multi.hashCode(); h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -152,9 +196,9 @@ public boolean equals(@Nullable Object o) { && (this.baggage == null ? that.baggage == null : this.baggage.equals(that.baggage)) && (this.b3 == null ? that.b3 == null : this.b3.equals(that.b3)) && (this.b3multi == null ? that.b3multi == null : this.b3multi.equals(that.b3multi)) - && (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/TextMapPropagatorPropertyModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/TextMapPropagatorPropertyModel.java deleted file mode 100644 index 1cc7703b715..00000000000 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/TextMapPropagatorPropertyModel.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.util.LinkedHashMap; -import java.util.Map; -import javax.annotation.Generated; -import javax.annotation.Nullable; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({}) -@Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") -public class TextMapPropagatorPropertyModel { - - private Map additionalProperties = new LinkedHashMap(); - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public TextMapPropagatorPropertyModel withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - - @Override - public String toString() { - return "TextMapPropagatorPropertyModel{" + "additionalProperties=" + additionalProperties + "}"; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= (this.additionalProperties == null) ? 0 : this.additionalProperties.hashCode(); - return h; - } - - @Override - public boolean equals(@Nullable Object o) { - if (o == this) { - return true; - } - if (o instanceof TextMapPropagatorPropertyModel) { - TextMapPropagatorPropertyModel that = (TextMapPropagatorPropertyModel) o; - return (this.additionalProperties == null - ? that.additionalProperties == null - : this.additionalProperties.equals(that.additionalProperties)); - } - return false; - } -} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/TraceIdRatioBasedSamplerModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/TraceIdRatioBasedSamplerModel.java index f03037a5291..88f6589b249 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/TraceIdRatioBasedSamplerModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/TraceIdRatioBasedSamplerModel.java @@ -5,39 +5,85 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.TraceIdRatioBasedSamplerModel.RATIO; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"ratio"}) +@JsonPropertyOrder({RATIO}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class TraceIdRatioBasedSamplerModel { + static final String RATIO = "ratio"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(RATIO, Double.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private Double ratio; + private Map extensionProperties = new LinkedHashMap(); /** * Configure trace_id_ratio. * *

If omitted or null, 1.0 is used. */ - @JsonProperty("ratio") + @JsonProperty(RATIO) @Nullable public Double getRatio() { + if (ratio == null) { + return ExtensionPropertyUtil.getGraduated(RATIO, extensionProperties, Double.class); + } return ratio; } - @JsonProperty("ratio") + @JsonProperty(RATIO) public TraceIdRatioBasedSamplerModel withRatio(Double ratio) { this.ratio = ratio; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public TraceIdRatioBasedSamplerModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { - return "TraceIdRatioBasedSamplerModel{" + "ratio=" + ratio + "}"; + return "TraceIdRatioBasedSamplerModel{" + + "ratio=" + + ratio + + ", extensionProperties=" + + extensionProperties + + "}"; } @Override @@ -45,6 +91,8 @@ public int hashCode() { int h = 1; h *= 1000003; h ^= (this.ratio == null) ? 0 : this.ratio.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -55,7 +103,10 @@ public boolean equals(@Nullable Object o) { } if (o instanceof TraceIdRatioBasedSamplerModel) { TraceIdRatioBasedSamplerModel that = (TraceIdRatioBasedSamplerModel) o; - return (this.ratio == null ? that.ratio == null : this.ratio.equals(that.ratio)); + return (this.ratio == null ? that.ratio == null : this.ratio.equals(that.ratio)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/TracerProviderModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/TracerProviderModel.java index 10f7d747775..36f2c772d79 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/TracerProviderModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/TracerProviderModel.java @@ -5,43 +5,64 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.TracerProviderModel.ID_GENERATOR; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.TracerProviderModel.LIMITS; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.TracerProviderModel.PROCESSORS; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.TracerProviderModel.SAMPLER; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.TracerProviderModelAccessor.EXPERIMENTAL_PROPERTIES; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalTracerConfiguratorModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "processors", - "limits", - "sampler", - "id_generator", - "tracer_configurator/development" -}) +@JsonPropertyOrder({PROCESSORS, LIMITS, SAMPLER, ID_GENERATOR}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class TracerProviderModel { + static final String PROCESSORS = "processors"; + static final String LIMITS = "limits"; + static final String SAMPLER = "sampler"; + static final String ID_GENERATOR = "id_generator"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(LIMITS, SpanLimitsModel.class); + STABLE_PROPERTIES.put(SAMPLER, SamplerModel.class); + STABLE_PROPERTIES.put(ID_GENERATOR, IdGeneratorModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private List processors; @Nullable private SpanLimitsModel limits; @Nullable private SamplerModel sampler; @Nullable private IdGeneratorModel idGenerator; - @Nullable private ExperimentalTracerConfiguratorModel tracerConfiguratorDevelopment; + private Map extensionProperties = new LinkedHashMap(); /** * Configure span processors. * *

Property is required and must be non-null. */ - @JsonProperty("processors") + @JsonProperty(PROCESSORS) @Nullable public List getProcessors() { return processors; } - @JsonProperty("processors") + @JsonProperty(PROCESSORS) public TracerProviderModel withProcessors(List processors) { this.processors = processors; return this; @@ -52,13 +73,16 @@ public TracerProviderModel withProcessors(List processors) { * *

If omitted, default values as described in SpanLimits are used. */ - @JsonProperty("limits") + @JsonProperty(LIMITS) @Nullable public SpanLimitsModel getLimits() { + if (limits == null) { + return ExtensionPropertyUtil.getGraduated(LIMITS, extensionProperties, SpanLimitsModel.class); + } return limits; } - @JsonProperty("limits") + @JsonProperty(LIMITS) public TracerProviderModel withLimits(SpanLimitsModel limits) { this.limits = limits; return this; @@ -69,13 +93,16 @@ public TracerProviderModel withLimits(SpanLimitsModel limits) { * *

If omitted, parent based sampler with a root of always_on is used. */ - @JsonProperty("sampler") + @JsonProperty(SAMPLER) @Nullable public SamplerModel getSampler() { + if (sampler == null) { + return ExtensionPropertyUtil.getGraduated(SAMPLER, extensionProperties, SamplerModel.class); + } return sampler; } - @JsonProperty("sampler") + @JsonProperty(SAMPLER) public TracerProviderModel withSampler(SamplerModel sampler) { this.sampler = sampler; return this; @@ -86,33 +113,36 @@ public TracerProviderModel withSampler(SamplerModel sampler) { * *

If omitted, RandomIdGenerator is used. */ - @JsonProperty("id_generator") + @JsonProperty(ID_GENERATOR) @Nullable public IdGeneratorModel getIdGenerator() { + if (idGenerator == null) { + return ExtensionPropertyUtil.getGraduated( + ID_GENERATOR, extensionProperties, IdGeneratorModel.class); + } return idGenerator; } - @JsonProperty("id_generator") + @JsonProperty(ID_GENERATOR) public TracerProviderModel withIdGenerator(IdGeneratorModel idGenerator) { this.idGenerator = idGenerator; return this; } - /** - * Configure tracers. - * - *

If omitted, all tracers use default values as described in ExperimentalTracerConfig. - */ - @JsonProperty("tracer_configurator/development") - @Nullable - public ExperimentalTracerConfiguratorModel getTracerConfiguratorDevelopment() { - return tracerConfiguratorDevelopment; + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); } - @JsonProperty("tracer_configurator/development") - public TracerProviderModel withTracerConfiguratorDevelopment( - ExperimentalTracerConfiguratorModel tracerConfiguratorDevelopment) { - this.tracerConfiguratorDevelopment = tracerConfiguratorDevelopment; + @JsonAnySetter + public TracerProviderModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + EXPERIMENTAL_PROPERTIES, + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); return this; } @@ -127,8 +157,8 @@ public String toString() { + sampler + ", idGenerator=" + idGenerator - + ", tracerConfiguratorDevelopment=" - + tracerConfiguratorDevelopment + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -144,10 +174,7 @@ public int hashCode() { h *= 1000003; h ^= (this.idGenerator == null) ? 0 : this.idGenerator.hashCode(); h *= 1000003; - h ^= - (this.tracerConfiguratorDevelopment == null) - ? 0 - : this.tracerConfiguratorDevelopment.hashCode(); + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -166,9 +193,9 @@ public boolean equals(@Nullable Object o) { && (this.idGenerator == null ? that.idGenerator == null : this.idGenerator.equals(that.idGenerator)) - && (this.tracerConfiguratorDevelopment == null - ? that.tracerConfiguratorDevelopment == null - : this.tracerConfiguratorDevelopment.equals(that.tracerConfiguratorDevelopment)); + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ViewModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ViewModel.java index 9b1876d1cb0..9f5366b607f 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ViewModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ViewModel.java @@ -5,19 +5,43 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ViewModel.SELECTOR; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ViewModel.STREAM; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"selector", "stream"}) +@JsonPropertyOrder({SELECTOR, STREAM}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class ViewModel { + static final String SELECTOR = "selector"; + static final String STREAM = "stream"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(SELECTOR, ViewSelectorModel.class); + STABLE_PROPERTIES.put(STREAM, ViewStreamModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private ViewSelectorModel selector; @Nullable private ViewStreamModel stream; + private Map extensionProperties = new LinkedHashMap(); /** * Configure view selector. @@ -27,13 +51,17 @@ public class ViewModel { * *

Property is required and must be non-null. */ - @JsonProperty("selector") + @JsonProperty(SELECTOR) @Nullable public ViewSelectorModel getSelector() { + if (selector == null) { + return ExtensionPropertyUtil.getGraduated( + SELECTOR, extensionProperties, ViewSelectorModel.class); + } return selector; } - @JsonProperty("selector") + @JsonProperty(SELECTOR) public ViewModel withSelector(ViewSelectorModel selector) { this.selector = selector; return this; @@ -44,21 +72,48 @@ public ViewModel withSelector(ViewSelectorModel selector) { * *

Property is required and must be non-null. */ - @JsonProperty("stream") + @JsonProperty(STREAM) @Nullable public ViewStreamModel getStream() { + if (stream == null) { + return ExtensionPropertyUtil.getGraduated(STREAM, extensionProperties, ViewStreamModel.class); + } return stream; } - @JsonProperty("stream") + @JsonProperty(STREAM) public ViewModel withStream(ViewStreamModel stream) { this.stream = stream; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public ViewModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { - return "ViewModel{" + "selector=" + selector + ", stream=" + stream + "}"; + return "ViewModel{" + + "selector=" + + selector + + ", stream=" + + stream + + ", extensionProperties=" + + extensionProperties + + "}"; } @Override @@ -68,6 +123,8 @@ public int hashCode() { h ^= (this.selector == null) ? 0 : this.selector.hashCode(); h *= 1000003; h ^= (this.stream == null) ? 0 : this.stream.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -79,7 +136,10 @@ public boolean equals(@Nullable Object o) { if (o instanceof ViewModel) { ViewModel that = (ViewModel) o; return (this.selector == null ? that.selector == null : this.selector.equals(that.selector)) - && (this.stream == null ? that.stream == null : this.stream.equals(that.stream)); + && (this.stream == null ? that.stream == null : this.stream.equals(that.stream)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ViewSelectorModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ViewSelectorModel.java index 18cb4a59335..925ab1b059f 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ViewSelectorModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ViewSelectorModel.java @@ -5,43 +5,82 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ViewSelectorModel.INSTRUMENT_NAME; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ViewSelectorModel.INSTRUMENT_TYPE; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ViewSelectorModel.METER_NAME; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ViewSelectorModel.METER_SCHEMA_URL; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ViewSelectorModel.METER_VERSION; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ViewSelectorModel.UNIT; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ - "instrument_name", - "instrument_type", - "unit", - "meter_name", - "meter_version", - "meter_schema_url" + INSTRUMENT_NAME, + INSTRUMENT_TYPE, + UNIT, + METER_NAME, + METER_VERSION, + METER_SCHEMA_URL }) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class ViewSelectorModel { + static final String INSTRUMENT_NAME = "instrument_name"; + static final String INSTRUMENT_TYPE = "instrument_type"; + static final String UNIT = "unit"; + static final String METER_NAME = "meter_name"; + static final String METER_VERSION = "meter_version"; + static final String METER_SCHEMA_URL = "meter_schema_url"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(INSTRUMENT_NAME, String.class); + STABLE_PROPERTIES.put(INSTRUMENT_TYPE, InstrumentTypeModel.class); + STABLE_PROPERTIES.put(UNIT, String.class); + STABLE_PROPERTIES.put(METER_NAME, String.class); + STABLE_PROPERTIES.put(METER_VERSION, String.class); + STABLE_PROPERTIES.put(METER_SCHEMA_URL, String.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private String instrumentName; @Nullable private InstrumentTypeModel instrumentType; @Nullable private String unit; @Nullable private String meterName; @Nullable private String meterVersion; @Nullable private String meterSchemaUrl; + private Map extensionProperties = new LinkedHashMap(); /** * Configure instrument name selection criteria. * *

If omitted or null, all instrument names match. */ - @JsonProperty("instrument_name") + @JsonProperty(INSTRUMENT_NAME) @Nullable public String getInstrumentName() { + if (instrumentName == null) { + return ExtensionPropertyUtil.getGraduated(INSTRUMENT_NAME, extensionProperties, String.class); + } return instrumentName; } - @JsonProperty("instrument_name") + @JsonProperty(INSTRUMENT_NAME) public ViewSelectorModel withInstrumentName(String instrumentName) { this.instrumentName = instrumentName; return this; @@ -68,13 +107,17 @@ public ViewSelectorModel withInstrumentName(String instrumentName) { * *

If omitted, all instrument types match. */ - @JsonProperty("instrument_type") + @JsonProperty(INSTRUMENT_TYPE) @Nullable public InstrumentTypeModel getInstrumentType() { + if (instrumentType == null) { + return ExtensionPropertyUtil.getGraduated( + INSTRUMENT_TYPE, extensionProperties, InstrumentTypeModel.class); + } return instrumentType; } - @JsonProperty("instrument_type") + @JsonProperty(INSTRUMENT_TYPE) public ViewSelectorModel withInstrumentType(InstrumentTypeModel instrumentType) { this.instrumentType = instrumentType; return this; @@ -85,13 +128,16 @@ public ViewSelectorModel withInstrumentType(InstrumentTypeModel instrumentType) * *

If omitted or null, all instrument units match. */ - @JsonProperty("unit") + @JsonProperty(UNIT) @Nullable public String getUnit() { + if (unit == null) { + return ExtensionPropertyUtil.getGraduated(UNIT, extensionProperties, String.class); + } return unit; } - @JsonProperty("unit") + @JsonProperty(UNIT) public ViewSelectorModel withUnit(String unit) { this.unit = unit; return this; @@ -102,13 +148,16 @@ public ViewSelectorModel withUnit(String unit) { * *

If omitted or null, all meter names match. */ - @JsonProperty("meter_name") + @JsonProperty(METER_NAME) @Nullable public String getMeterName() { + if (meterName == null) { + return ExtensionPropertyUtil.getGraduated(METER_NAME, extensionProperties, String.class); + } return meterName; } - @JsonProperty("meter_name") + @JsonProperty(METER_NAME) public ViewSelectorModel withMeterName(String meterName) { this.meterName = meterName; return this; @@ -119,13 +168,16 @@ public ViewSelectorModel withMeterName(String meterName) { * *

If omitted or null, all meter versions match. */ - @JsonProperty("meter_version") + @JsonProperty(METER_VERSION) @Nullable public String getMeterVersion() { + if (meterVersion == null) { + return ExtensionPropertyUtil.getGraduated(METER_VERSION, extensionProperties, String.class); + } return meterVersion; } - @JsonProperty("meter_version") + @JsonProperty(METER_VERSION) public ViewSelectorModel withMeterVersion(String meterVersion) { this.meterVersion = meterVersion; return this; @@ -136,18 +188,39 @@ public ViewSelectorModel withMeterVersion(String meterVersion) { * *

If omitted or null, all meter schema URLs match. */ - @JsonProperty("meter_schema_url") + @JsonProperty(METER_SCHEMA_URL) @Nullable public String getMeterSchemaUrl() { + if (meterSchemaUrl == null) { + return ExtensionPropertyUtil.getGraduated( + METER_SCHEMA_URL, extensionProperties, String.class); + } return meterSchemaUrl; } - @JsonProperty("meter_schema_url") + @JsonProperty(METER_SCHEMA_URL) public ViewSelectorModel withMeterSchemaUrl(String meterSchemaUrl) { this.meterSchemaUrl = meterSchemaUrl; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public ViewSelectorModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "ViewSelectorModel{" @@ -163,6 +236,8 @@ public String toString() { + meterVersion + ", meterSchemaUrl=" + meterSchemaUrl + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -181,6 +256,8 @@ public int hashCode() { h ^= (this.meterVersion == null) ? 0 : this.meterVersion.hashCode(); h *= 1000003; h ^= (this.meterSchemaUrl == null) ? 0 : this.meterSchemaUrl.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -206,7 +283,10 @@ public boolean equals(@Nullable Object o) { : this.meterVersion.equals(that.meterVersion)) && (this.meterSchemaUrl == null ? that.meterSchemaUrl == null - : this.meterSchemaUrl.equals(that.meterSchemaUrl)); + : this.meterSchemaUrl.equals(that.meterSchemaUrl)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ViewStreamModel.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ViewStreamModel.java index 124b0ccf4b4..f6c24cec833 100644 --- a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ViewStreamModel.java +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ViewStreamModel.java @@ -5,41 +5,71 @@ package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ViewStreamModel.AGGREGATION; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ViewStreamModel.AGGREGATION_CARDINALITY_LIMIT; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ViewStreamModel.ATTRIBUTE_KEYS; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ViewStreamModel.DESCRIPTION; +import static io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ViewStreamModel.NAME; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import javax.annotation.Generated; import javax.annotation.Nullable; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "name", - "description", - "aggregation", - "aggregation_cardinality_limit", - "attribute_keys" -}) +@JsonPropertyOrder({NAME, DESCRIPTION, AGGREGATION, AGGREGATION_CARDINALITY_LIMIT, ATTRIBUTE_KEYS}) @Generated("io.opentelemetry.gradle.DeclarativeConfigPojoGenerator") public class ViewStreamModel { + static final String NAME = "name"; + static final String DESCRIPTION = "description"; + static final String AGGREGATION = "aggregation"; + static final String AGGREGATION_CARDINALITY_LIMIT = "aggregation_cardinality_limit"; + static final String ATTRIBUTE_KEYS = "attribute_keys"; + + private static final Map> STABLE_PROPERTIES; + + static { + STABLE_PROPERTIES = new HashMap<>(); + STABLE_PROPERTIES.put(NAME, String.class); + STABLE_PROPERTIES.put(DESCRIPTION, String.class); + STABLE_PROPERTIES.put(AGGREGATION, AggregationModel.class); + STABLE_PROPERTIES.put(AGGREGATION_CARDINALITY_LIMIT, Integer.class); + STABLE_PROPERTIES.put(ATTRIBUTE_KEYS, IncludeExcludeModel.class); + } + + private static final boolean ALLOWS_ADDITIONAL_PROPERTIES = false; + @Nullable private String name; @Nullable private String description; @Nullable private AggregationModel aggregation; @Nullable private Integer aggregationCardinalityLimit; @Nullable private IncludeExcludeModel attributeKeys; + private Map extensionProperties = new LinkedHashMap(); /** * Configure metric name of the resulting stream(s). * *

If omitted or null, the instrument's original name is used. */ - @JsonProperty("name") + @JsonProperty(NAME) @Nullable public String getName() { + if (name == null) { + return ExtensionPropertyUtil.getGraduated(NAME, extensionProperties, String.class); + } return name; } - @JsonProperty("name") + @JsonProperty(NAME) public ViewStreamModel withName(String name) { this.name = name; return this; @@ -50,13 +80,16 @@ public ViewStreamModel withName(String name) { * *

If omitted or null, the instrument's origin description is used. */ - @JsonProperty("description") + @JsonProperty(DESCRIPTION) @Nullable public String getDescription() { + if (description == null) { + return ExtensionPropertyUtil.getGraduated(DESCRIPTION, extensionProperties, String.class); + } return description; } - @JsonProperty("description") + @JsonProperty(DESCRIPTION) public ViewStreamModel withDescription(String description) { this.description = description; return this; @@ -67,13 +100,17 @@ public ViewStreamModel withDescription(String description) { * *

If omitted, default is used. */ - @JsonProperty("aggregation") + @JsonProperty(AGGREGATION) @Nullable public AggregationModel getAggregation() { + if (aggregation == null) { + return ExtensionPropertyUtil.getGraduated( + AGGREGATION, extensionProperties, AggregationModel.class); + } return aggregation; } - @JsonProperty("aggregation") + @JsonProperty(AGGREGATION) public ViewStreamModel withAggregation(AggregationModel aggregation) { this.aggregation = aggregation; return this; @@ -84,13 +121,17 @@ public ViewStreamModel withAggregation(AggregationModel aggregation) { * *

If omitted or null, the metric reader's default cardinality limit is used. */ - @JsonProperty("aggregation_cardinality_limit") + @JsonProperty(AGGREGATION_CARDINALITY_LIMIT) @Nullable public Integer getAggregationCardinalityLimit() { + if (aggregationCardinalityLimit == null) { + return ExtensionPropertyUtil.getGraduated( + AGGREGATION_CARDINALITY_LIMIT, extensionProperties, Integer.class); + } return aggregationCardinalityLimit; } - @JsonProperty("aggregation_cardinality_limit") + @JsonProperty(AGGREGATION_CARDINALITY_LIMIT) public ViewStreamModel withAggregationCardinalityLimit(Integer aggregationCardinalityLimit) { this.aggregationCardinalityLimit = aggregationCardinalityLimit; return this; @@ -101,18 +142,39 @@ public ViewStreamModel withAggregationCardinalityLimit(Integer aggregationCardin * *

If omitted, all attribute keys are retained. */ - @JsonProperty("attribute_keys") + @JsonProperty(ATTRIBUTE_KEYS) @Nullable public IncludeExcludeModel getAttributeKeys() { + if (attributeKeys == null) { + return ExtensionPropertyUtil.getGraduated( + ATTRIBUTE_KEYS, extensionProperties, IncludeExcludeModel.class); + } return attributeKeys; } - @JsonProperty("attribute_keys") + @JsonProperty(ATTRIBUTE_KEYS) public ViewStreamModel withAttributeKeys(IncludeExcludeModel attributeKeys) { this.attributeKeys = attributeKeys; return this; } + @JsonAnyGetter + public Map getExtensionProperties() { + return ExtensionPropertyUtil.filterSerializable(extensionProperties, STABLE_PROPERTIES); + } + + @JsonAnySetter + public ViewStreamModel withExtensionProperty(String name, @Nullable Object value) { + ExtensionPropertyUtil.handleAnySetter( + name, + value, + extensionProperties, + Collections.emptyMap(), + STABLE_PROPERTIES, + ALLOWS_ADDITIONAL_PROPERTIES); + return this; + } + @Override public String toString() { return "ViewStreamModel{" @@ -126,6 +188,8 @@ public String toString() { + aggregationCardinalityLimit + ", attributeKeys=" + attributeKeys + + ", extensionProperties=" + + extensionProperties + "}"; } @@ -145,6 +209,8 @@ public int hashCode() { : this.aggregationCardinalityLimit.hashCode(); h *= 1000003; h ^= (this.attributeKeys == null) ? 0 : this.attributeKeys.hashCode(); + h *= 1000003; + h ^= (this.extensionProperties == null) ? 0 : this.extensionProperties.hashCode(); return h; } @@ -167,7 +233,10 @@ public boolean equals(@Nullable Object o) { : this.aggregationCardinalityLimit.equals(that.aggregationCardinalityLimit)) && (this.attributeKeys == null ? that.attributeKeys == null - : this.attributeKeys.equals(that.attributeKeys)); + : this.attributeKeys.equals(that.attributeKeys)) + && (this.extensionProperties == null + ? that.extensionProperties == null + : this.extensionProperties.equals(that.extensionProperties)); } return false; } diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/ExtensionPropertyUtil.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/ExtensionPropertyUtil.java new file mode 100644 index 00000000000..65e9595b35f --- /dev/null +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/ExtensionPropertyUtil.java @@ -0,0 +1,119 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.logging.Logger; +import javax.annotation.Nullable; + +/** + * Shared {@code @JsonAnySetter} logic for generated stable model classes. + * + *

This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class ExtensionPropertyUtil { + + private static final String DEV_SUFFIX = "/development"; + private static final Logger LOGGER = Logger.getLogger(ExtensionPropertyUtil.class.getName()); + + private ExtensionPropertyUtil() {} + + /** + * Routes a single {@code @JsonAnySetter} call into {@code extensionProperties}. Known + * experimental keys are type-converted for parse-time checking. Keys of the form {@code + * {stableName}/development} for a known stable property are graduated: a warning is logged and + * the value is converted to the stable type but stored under the original {@code /development} + * key so serialization round-trips. Unknown keys are stored raw on open types or + * warned-and-dropped on closed types. + */ + public static void handleAnySetter( + String name, + @Nullable Object value, + Map extensionProperties, + Map> experimentalPropertyTypes, + Map> stablePropertyTypes, + boolean allowsAdditionalProperties) { + + if (name.endsWith(DEV_SUFFIX)) { + String candidate = name.substring(0, name.length() - DEV_SUFFIX.length()); + Class stableType = stablePropertyTypes.get(candidate); + if (stableType != null) { + LOGGER.warning( + "Property '" + name + "' has been stabilized. Use '" + candidate + "' instead."); + extensionProperties.put( + name, value == null ? null : ModelMapper.MAPPER.convertValue(value, stableType)); + return; + } + } + + Class experimentalType = experimentalPropertyTypes.get(name); + if (experimentalType != null) { + extensionProperties.put( + name, value == null ? null : ModelMapper.MAPPER.convertValue(value, experimentalType)); + return; + } + + if (allowsAdditionalProperties) { + extensionProperties.put(name, value); + return; + } + + LOGGER.warning("Unknown property '" + name + "' is not recognized and will be ignored."); + } + + /** + * Returns the extension property value for {@code key}, cast to {@code type}. + * + *

Values are guaranteed to be the correct type at store time: {@link #handleAnySetter} + * converts known experimental properties via {@code ModelMapper} before storing, and the + * generated accessor builders enforce the type at the call site. A {@link ClassCastException} + * here indicates a contract violation (e.g. writing directly to the extension properties map with + * the wrong type). + */ + @Nullable + public static T get(String key, Map extensionProperties, Class type) { + Object raw = extensionProperties.get(key); + return raw == null ? null : type.cast(raw); + } + + /** + * Looks up a graduated value stored by {@link #handleAnySetter} under {@code stableKey + + * "/development"}. + */ + @Nullable + public static T getGraduated( + String stableKey, Map extensionProperties, Class type) { + return get(stableKey + DEV_SUFFIX, extensionProperties, type); + } + + /** + * Returns {@code extensionProperties} minus graduated entries (keys of the form {@code + * X/development} where {@code X} is in {@code stableProperties}). Used by {@code @JsonAnyGetter} + * to avoid emitting graduated values twice: once under the stable {@code @JsonProperty} key via + * the getter's {@link #getGraduated} fallback, and once under {@code /development} via the raw + * map. + */ + public static Map filterSerializable( + Map extensionProperties, Map> stableProperties) { + if (stableProperties.isEmpty() || extensionProperties.isEmpty()) { + return extensionProperties; + } + Map filtered = null; + for (String key : extensionProperties.keySet()) { + if (key.endsWith(DEV_SUFFIX) + && stableProperties.containsKey(key.substring(0, key.length() - DEV_SUFFIX.length()))) { + if (filtered == null) { + filtered = new LinkedHashMap<>(extensionProperties); + } + filtered.remove(key); + } + } + return filtered != null ? filtered : extensionProperties; + } +} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/LogRecordExporterModelAccessor.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/LogRecordExporterModelAccessor.java new file mode 100644 index 00000000000..e0cf6ca602f --- /dev/null +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/LogRecordExporterModelAccessor.java @@ -0,0 +1,47 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal; + +import static java.util.Objects.requireNonNull; + +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LogRecordExporterModel; +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Nullable; + +/** + * Provides typed access to experimental properties on {@link LogRecordExporterModel}. + * + *

This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class LogRecordExporterModelAccessor { + + private LogRecordExporterModelAccessor() {} + + static final String OTLP_FILE = "otlp_file/development"; + + public static final Map> EXPERIMENTAL_PROPERTIES; + + static { + EXPERIMENTAL_PROPERTIES = new HashMap<>(); + EXPERIMENTAL_PROPERTIES.put(OTLP_FILE, ExperimentalOtlpFileExporterModel.class); + } + + @Nullable + public static ExperimentalOtlpFileExporterModel getOtlpFile(LogRecordExporterModel model) { + return ExtensionPropertyUtil.get( + OTLP_FILE, model.getExtensionProperties(), ExperimentalOtlpFileExporterModel.class); + } + + public static LogRecordExporterModel withOtlpFile( + LogRecordExporterModel model, ExperimentalOtlpFileExporterModel value) { + requireNonNull(value, "value"); + model.withExtensionProperty(OTLP_FILE, value); + return model; + } +} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/LogRecordProcessorModelAccessor.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/LogRecordProcessorModelAccessor.java new file mode 100644 index 00000000000..ce8b533a2bf --- /dev/null +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/LogRecordProcessorModelAccessor.java @@ -0,0 +1,53 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal; + +import static java.util.Objects.requireNonNull; + +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LogRecordProcessorModel; +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Nullable; + +/** + * Provides typed access to experimental properties on {@link LogRecordProcessorModel}. + * + *

This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class LogRecordProcessorModelAccessor { + + private LogRecordProcessorModelAccessor() {} + + static final String EVENT_TO_SPAN_EVENT_BRIDGE = "event_to_span_event_bridge/development"; + + public static final Map> EXPERIMENTAL_PROPERTIES; + + static { + EXPERIMENTAL_PROPERTIES = new HashMap<>(); + EXPERIMENTAL_PROPERTIES.put( + EVENT_TO_SPAN_EVENT_BRIDGE, + ExperimentalEventToSpanEventBridgeLogRecordProcessorModel.class); + } + + @Nullable + public static ExperimentalEventToSpanEventBridgeLogRecordProcessorModel getEventToSpanEventBridge( + LogRecordProcessorModel model) { + return ExtensionPropertyUtil.get( + EVENT_TO_SPAN_EVENT_BRIDGE, + model.getExtensionProperties(), + ExperimentalEventToSpanEventBridgeLogRecordProcessorModel.class); + } + + public static LogRecordProcessorModel withEventToSpanEventBridge( + LogRecordProcessorModel model, + ExperimentalEventToSpanEventBridgeLogRecordProcessorModel value) { + requireNonNull(value, "value"); + model.withExtensionProperty(EVENT_TO_SPAN_EVENT_BRIDGE, value); + return model; + } +} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/LoggerProviderModelAccessor.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/LoggerProviderModelAccessor.java new file mode 100644 index 00000000000..f7e833e8767 --- /dev/null +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/LoggerProviderModelAccessor.java @@ -0,0 +1,50 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal; + +import static java.util.Objects.requireNonNull; + +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LoggerProviderModel; +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Nullable; + +/** + * Provides typed access to experimental properties on {@link LoggerProviderModel}. + * + *

This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class LoggerProviderModelAccessor { + + private LoggerProviderModelAccessor() {} + + static final String LOGGER_CONFIGURATOR = "logger_configurator/development"; + + public static final Map> EXPERIMENTAL_PROPERTIES; + + static { + EXPERIMENTAL_PROPERTIES = new HashMap<>(); + EXPERIMENTAL_PROPERTIES.put(LOGGER_CONFIGURATOR, ExperimentalLoggerConfiguratorModel.class); + } + + @Nullable + public static ExperimentalLoggerConfiguratorModel getLoggerConfigurator( + LoggerProviderModel model) { + return ExtensionPropertyUtil.get( + LOGGER_CONFIGURATOR, + model.getExtensionProperties(), + ExperimentalLoggerConfiguratorModel.class); + } + + public static LoggerProviderModel withLoggerConfigurator( + LoggerProviderModel model, ExperimentalLoggerConfiguratorModel value) { + requireNonNull(value, "value"); + model.withExtensionProperty(LOGGER_CONFIGURATOR, value); + return model; + } +} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/MeterProviderModelAccessor.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/MeterProviderModelAccessor.java new file mode 100644 index 00000000000..a0f39c7b4dc --- /dev/null +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/MeterProviderModelAccessor.java @@ -0,0 +1,49 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal; + +import static java.util.Objects.requireNonNull; + +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.MeterProviderModel; +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Nullable; + +/** + * Provides typed access to experimental properties on {@link MeterProviderModel}. + * + *

This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class MeterProviderModelAccessor { + + private MeterProviderModelAccessor() {} + + static final String METER_CONFIGURATOR = "meter_configurator/development"; + + public static final Map> EXPERIMENTAL_PROPERTIES; + + static { + EXPERIMENTAL_PROPERTIES = new HashMap<>(); + EXPERIMENTAL_PROPERTIES.put(METER_CONFIGURATOR, ExperimentalMeterConfiguratorModel.class); + } + + @Nullable + public static ExperimentalMeterConfiguratorModel getMeterConfigurator(MeterProviderModel model) { + return ExtensionPropertyUtil.get( + METER_CONFIGURATOR, + model.getExtensionProperties(), + ExperimentalMeterConfiguratorModel.class); + } + + public static MeterProviderModel withMeterConfigurator( + MeterProviderModel model, ExperimentalMeterConfiguratorModel value) { + requireNonNull(value, "value"); + model.withExtensionProperty(METER_CONFIGURATOR, value); + return model; + } +} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/ModelMapper.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/ModelMapper.java new file mode 100644 index 00000000000..722c2e69f82 --- /dev/null +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/ModelMapper.java @@ -0,0 +1,39 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal; + +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.ObjectMapper; + +/** + * Canonical {@link ObjectMapper} configuration for parsing declarative configuration YAML. {@link + * io.opentelemetry.sdk.autoconfigure.declarativeconfig.DeclarativeConfiguration#MAPPER} delegates + * to this instance. + * + *

This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class ModelMapper { + + public static final ObjectMapper MAPPER; + + static { + MAPPER = + new ObjectMapper() + // Create empty object instances for keys which are present but have null values + .setDefaultSetterInfo(JsonSetter.Value.forValueNulls(Nulls.AS_EMPTY)); + // Boxed primitives which are present but have null values should be set to null, rather than + // empty instances + MAPPER.configOverride(String.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SET)); + MAPPER.configOverride(Integer.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SET)); + MAPPER.configOverride(Double.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SET)); + MAPPER.configOverride(Boolean.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SET)); + } + + private ModelMapper() {} +} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/OpenTelemetryConfigurationModelAccessor.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/OpenTelemetryConfigurationModelAccessor.java new file mode 100644 index 00000000000..e39a56db220 --- /dev/null +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/OpenTelemetryConfigurationModelAccessor.java @@ -0,0 +1,48 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal; + +import static java.util.Objects.requireNonNull; + +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OpenTelemetryConfigurationModel; +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Nullable; + +/** + * Provides typed access to experimental properties on {@link OpenTelemetryConfigurationModel}. + * + *

This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class OpenTelemetryConfigurationModelAccessor { + + private OpenTelemetryConfigurationModelAccessor() {} + + static final String INSTRUMENTATION = "instrumentation/development"; + + public static final Map> EXPERIMENTAL_PROPERTIES; + + static { + EXPERIMENTAL_PROPERTIES = new HashMap<>(); + EXPERIMENTAL_PROPERTIES.put(INSTRUMENTATION, ExperimentalInstrumentationModel.class); + } + + @Nullable + public static ExperimentalInstrumentationModel getInstrumentation( + OpenTelemetryConfigurationModel model) { + return ExtensionPropertyUtil.get( + INSTRUMENTATION, model.getExtensionProperties(), ExperimentalInstrumentationModel.class); + } + + public static OpenTelemetryConfigurationModel withInstrumentation( + OpenTelemetryConfigurationModel model, ExperimentalInstrumentationModel value) { + requireNonNull(value, "value"); + model.withExtensionProperty(INSTRUMENTATION, value); + return model; + } +} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/PeriodicMetricReaderModelAccessor.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/PeriodicMetricReaderModelAccessor.java new file mode 100644 index 00000000000..d78d874f058 --- /dev/null +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/PeriodicMetricReaderModelAccessor.java @@ -0,0 +1,47 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal; + +import static java.util.Objects.requireNonNull; + +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PeriodicMetricReaderModel; +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Nullable; + +/** + * Provides typed access to experimental properties on {@link PeriodicMetricReaderModel}. + * + *

This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class PeriodicMetricReaderModelAccessor { + + private PeriodicMetricReaderModelAccessor() {} + + static final String MAX_EXPORT_BATCH_SIZE = "max_export_batch_size/development"; + + public static final Map> EXPERIMENTAL_PROPERTIES; + + static { + EXPERIMENTAL_PROPERTIES = new HashMap<>(); + EXPERIMENTAL_PROPERTIES.put(MAX_EXPORT_BATCH_SIZE, Integer.class); + } + + @Nullable + public static Integer getMaxExportBatchSize(PeriodicMetricReaderModel model) { + return ExtensionPropertyUtil.get( + MAX_EXPORT_BATCH_SIZE, model.getExtensionProperties(), Integer.class); + } + + public static PeriodicMetricReaderModel withMaxExportBatchSize( + PeriodicMetricReaderModel model, Integer value) { + requireNonNull(value, "value"); + model.withExtensionProperty(MAX_EXPORT_BATCH_SIZE, value); + return model; + } +} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/PullMetricExporterModelAccessor.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/PullMetricExporterModelAccessor.java new file mode 100644 index 00000000000..80362f68a33 --- /dev/null +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/PullMetricExporterModelAccessor.java @@ -0,0 +1,50 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal; + +import static java.util.Objects.requireNonNull; + +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PullMetricExporterModel; +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Nullable; + +/** + * Provides typed access to experimental properties on {@link PullMetricExporterModel}. + * + *

This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class PullMetricExporterModelAccessor { + + private PullMetricExporterModelAccessor() {} + + static final String PROMETHEUS = "prometheus/development"; + + public static final Map> EXPERIMENTAL_PROPERTIES; + + static { + EXPERIMENTAL_PROPERTIES = new HashMap<>(); + EXPERIMENTAL_PROPERTIES.put(PROMETHEUS, ExperimentalPrometheusMetricExporterModel.class); + } + + @Nullable + public static ExperimentalPrometheusMetricExporterModel getPrometheus( + PullMetricExporterModel model) { + return ExtensionPropertyUtil.get( + PROMETHEUS, + model.getExtensionProperties(), + ExperimentalPrometheusMetricExporterModel.class); + } + + public static PullMetricExporterModel withPrometheus( + PullMetricExporterModel model, ExperimentalPrometheusMetricExporterModel value) { + requireNonNull(value, "value"); + model.withExtensionProperty(PROMETHEUS, value); + return model; + } +} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/PushMetricExporterModelAccessor.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/PushMetricExporterModelAccessor.java new file mode 100644 index 00000000000..663a96aebb4 --- /dev/null +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/PushMetricExporterModelAccessor.java @@ -0,0 +1,47 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal; + +import static java.util.Objects.requireNonNull; + +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PushMetricExporterModel; +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Nullable; + +/** + * Provides typed access to experimental properties on {@link PushMetricExporterModel}. + * + *

This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class PushMetricExporterModelAccessor { + + private PushMetricExporterModelAccessor() {} + + static final String OTLP_FILE = "otlp_file/development"; + + public static final Map> EXPERIMENTAL_PROPERTIES; + + static { + EXPERIMENTAL_PROPERTIES = new HashMap<>(); + EXPERIMENTAL_PROPERTIES.put(OTLP_FILE, ExperimentalOtlpFileMetricExporterModel.class); + } + + @Nullable + public static ExperimentalOtlpFileMetricExporterModel getOtlpFile(PushMetricExporterModel model) { + return ExtensionPropertyUtil.get( + OTLP_FILE, model.getExtensionProperties(), ExperimentalOtlpFileMetricExporterModel.class); + } + + public static PushMetricExporterModel withOtlpFile( + PushMetricExporterModel model, ExperimentalOtlpFileMetricExporterModel value) { + requireNonNull(value, "value"); + model.withExtensionProperty(OTLP_FILE, value); + return model; + } +} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/ResourceModelAccessor.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/ResourceModelAccessor.java new file mode 100644 index 00000000000..c416478e1a5 --- /dev/null +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/ResourceModelAccessor.java @@ -0,0 +1,47 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal; + +import static java.util.Objects.requireNonNull; + +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ResourceModel; +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Nullable; + +/** + * Provides typed access to experimental properties on {@link ResourceModel}. + * + *

This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class ResourceModelAccessor { + + private ResourceModelAccessor() {} + + static final String DETECTION = "detection/development"; + + public static final Map> EXPERIMENTAL_PROPERTIES; + + static { + EXPERIMENTAL_PROPERTIES = new HashMap<>(); + EXPERIMENTAL_PROPERTIES.put(DETECTION, ExperimentalResourceDetectionModel.class); + } + + @Nullable + public static ExperimentalResourceDetectionModel getDetection(ResourceModel model) { + return ExtensionPropertyUtil.get( + DETECTION, model.getExtensionProperties(), ExperimentalResourceDetectionModel.class); + } + + public static ResourceModel withDetection( + ResourceModel model, ExperimentalResourceDetectionModel value) { + requireNonNull(value, "value"); + model.withExtensionProperty(DETECTION, value); + return model; + } +} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/SamplerModelAccessor.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/SamplerModelAccessor.java new file mode 100644 index 00000000000..76e1e8854fb --- /dev/null +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/SamplerModelAccessor.java @@ -0,0 +1,77 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal; + +import static java.util.Objects.requireNonNull; + +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SamplerModel; +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Nullable; + +/** + * Provides typed access to experimental properties on {@link SamplerModel}. + * + *

This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class SamplerModelAccessor { + + private SamplerModelAccessor() {} + + static final String COMPOSITE = "composite/development"; + static final String JAEGER_REMOTE = "jaeger_remote/development"; + static final String PROBABILITY = "probability/development"; + + public static final Map> EXPERIMENTAL_PROPERTIES; + + static { + EXPERIMENTAL_PROPERTIES = new HashMap<>(); + EXPERIMENTAL_PROPERTIES.put(COMPOSITE, ExperimentalComposableSamplerModel.class); + EXPERIMENTAL_PROPERTIES.put(JAEGER_REMOTE, ExperimentalJaegerRemoteSamplerModel.class); + EXPERIMENTAL_PROPERTIES.put(PROBABILITY, ExperimentalProbabilitySamplerModel.class); + } + + @Nullable + public static ExperimentalComposableSamplerModel getComposite(SamplerModel model) { + return ExtensionPropertyUtil.get( + COMPOSITE, model.getExtensionProperties(), ExperimentalComposableSamplerModel.class); + } + + public static SamplerModel withComposite( + SamplerModel model, ExperimentalComposableSamplerModel value) { + requireNonNull(value, "value"); + model.withExtensionProperty(COMPOSITE, value); + return model; + } + + @Nullable + public static ExperimentalJaegerRemoteSamplerModel getJaegerRemote(SamplerModel model) { + return ExtensionPropertyUtil.get( + JAEGER_REMOTE, model.getExtensionProperties(), ExperimentalJaegerRemoteSamplerModel.class); + } + + public static SamplerModel withJaegerRemote( + SamplerModel model, ExperimentalJaegerRemoteSamplerModel value) { + requireNonNull(value, "value"); + model.withExtensionProperty(JAEGER_REMOTE, value); + return model; + } + + @Nullable + public static ExperimentalProbabilitySamplerModel getProbability(SamplerModel model) { + return ExtensionPropertyUtil.get( + PROBABILITY, model.getExtensionProperties(), ExperimentalProbabilitySamplerModel.class); + } + + public static SamplerModel withProbability( + SamplerModel model, ExperimentalProbabilitySamplerModel value) { + requireNonNull(value, "value"); + model.withExtensionProperty(PROBABILITY, value); + return model; + } +} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/SpanExporterModelAccessor.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/SpanExporterModelAccessor.java new file mode 100644 index 00000000000..30e73ef51fe --- /dev/null +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/SpanExporterModelAccessor.java @@ -0,0 +1,47 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal; + +import static java.util.Objects.requireNonNull; + +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SpanExporterModel; +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Nullable; + +/** + * Provides typed access to experimental properties on {@link SpanExporterModel}. + * + *

This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class SpanExporterModelAccessor { + + private SpanExporterModelAccessor() {} + + static final String OTLP_FILE = "otlp_file/development"; + + public static final Map> EXPERIMENTAL_PROPERTIES; + + static { + EXPERIMENTAL_PROPERTIES = new HashMap<>(); + EXPERIMENTAL_PROPERTIES.put(OTLP_FILE, ExperimentalOtlpFileExporterModel.class); + } + + @Nullable + public static ExperimentalOtlpFileExporterModel getOtlpFile(SpanExporterModel model) { + return ExtensionPropertyUtil.get( + OTLP_FILE, model.getExtensionProperties(), ExperimentalOtlpFileExporterModel.class); + } + + public static SpanExporterModel withOtlpFile( + SpanExporterModel model, ExperimentalOtlpFileExporterModel value) { + requireNonNull(value, "value"); + model.withExtensionProperty(OTLP_FILE, value); + return model; + } +} diff --git a/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/TracerProviderModelAccessor.java b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/TracerProviderModelAccessor.java new file mode 100644 index 00000000000..bf054e14ed5 --- /dev/null +++ b/sdk-extensions/declarative-config/src/main/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/internal/TracerProviderModelAccessor.java @@ -0,0 +1,50 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal; + +import static java.util.Objects.requireNonNull; + +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.TracerProviderModel; +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Nullable; + +/** + * Provides typed access to experimental properties on {@link TracerProviderModel}. + * + *

This class is internal and experimental. Its APIs are unstable and can change at any time. Its + * APIs (or a version of them) may be promoted to the public stable API in the future, but no + * guarantees are made. + */ +public final class TracerProviderModelAccessor { + + private TracerProviderModelAccessor() {} + + static final String TRACER_CONFIGURATOR = "tracer_configurator/development"; + + public static final Map> EXPERIMENTAL_PROPERTIES; + + static { + EXPERIMENTAL_PROPERTIES = new HashMap<>(); + EXPERIMENTAL_PROPERTIES.put(TRACER_CONFIGURATOR, ExperimentalTracerConfiguratorModel.class); + } + + @Nullable + public static ExperimentalTracerConfiguratorModel getTracerConfigurator( + TracerProviderModel model) { + return ExtensionPropertyUtil.get( + TRACER_CONFIGURATOR, + model.getExtensionProperties(), + ExperimentalTracerConfiguratorModel.class); + } + + public static TracerProviderModel withTracerConfigurator( + TracerProviderModel model, ExperimentalTracerConfiguratorModel value) { + requireNonNull(value, "value"); + model.withExtensionProperty(TRACER_CONFIGURATOR, value); + return model; + } +} diff --git a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/DeclarativeConfigurationCreateTest.java b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/DeclarativeConfigurationCreateTest.java index 053953a5a94..d0ab0fb0476 100644 --- a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/DeclarativeConfigurationCreateTest.java +++ b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/DeclarativeConfigurationCreateTest.java @@ -175,7 +175,7 @@ void create_ModelCustomizer() { new TracerProviderModel() .withProcessors( Collections.singletonList( - new SpanProcessorModel().withAdditionalProperty("test", null)))); + new SpanProcessorModel().withExtensionProperty("test", null)))); ExtendedOpenTelemetrySdk sdk = DeclarativeConfiguration.create( model, diff --git a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/ExtensionPropertyUtilTest.java b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/ExtensionPropertyUtilTest.java new file mode 100644 index 00000000000..28ae352473a --- /dev/null +++ b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/ExtensionPropertyUtilTest.java @@ -0,0 +1,187 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.sdk.autoconfigure.declarativeconfig; + +import static org.assertj.core.api.Assertions.assertThat; + +import io.github.netmikey.logunit.api.LogCapturer; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LogRecordLimitsModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LoggerProviderModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SamplerModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalComposableSamplerModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExtensionPropertyUtil; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ModelMapper; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.slf4j.event.Level; + +class ExtensionPropertyUtilTest { + + @RegisterExtension + LogCapturer logs = + LogCapturer.create().captureForLogger(ExtensionPropertyUtil.class.getName(), Level.TRACE); + + @Test + void handleAnySetter_knownExperimentalKey_convertsAndStores() { + Map props = new LinkedHashMap<>(); + Map> experimentalTypes = new HashMap<>(); + experimentalTypes.put("composite/development", ExperimentalComposableSamplerModel.class); + + ExtensionPropertyUtil.handleAnySetter( + "composite/development", + new LinkedHashMap<>(), + props, + experimentalTypes, + Collections.emptyMap(), + false); + + assertThat(props.get("composite/development")) + .isInstanceOf(ExperimentalComposableSamplerModel.class); + } + + @Test + void handleAnySetter_knownExperimentalKey_nullValue_storesNull() { + Map props = new LinkedHashMap<>(); + Map> experimentalTypes = new HashMap<>(); + experimentalTypes.put("composite/development", ExperimentalComposableSamplerModel.class); + + ExtensionPropertyUtil.handleAnySetter( + "composite/development", null, props, experimentalTypes, Collections.emptyMap(), false); + + assertThat(props).containsEntry("composite/development", null); + } + + @Test + void handleAnySetter_graduatedKey_storesUnderDevelopmentKey_andWarns() { + Map props = new LinkedHashMap<>(); + Map> stableTypes = new HashMap<>(); + stableTypes.put("limits", LogRecordLimitsModel.class); + + ExtensionPropertyUtil.handleAnySetter( + "limits/development", + new LinkedHashMap<>(), + props, + Collections.emptyMap(), + stableTypes, + false); + + assertThat(props).doesNotContainKey("limits"); + assertThat(props.get("limits/development")).isInstanceOf(LogRecordLimitsModel.class); + logs.assertContains("Property 'limits/development' has been stabilized. Use 'limits' instead."); + } + + @Test + void handleAnySetter_unknownKey_openType_stores() { + Map props = new LinkedHashMap<>(); + + ExtensionPropertyUtil.handleAnySetter( + "custom_exporter", + "config_value", + props, + Collections.emptyMap(), + Collections.emptyMap(), + true); + + assertThat(props).containsEntry("custom_exporter", "config_value"); + } + + @Test + void handleAnySetter_unknownKey_closedType_doesNotStore_andWarns() { + Map props = new LinkedHashMap<>(); + + ExtensionPropertyUtil.handleAnySetter( + "unknown_key", "value", props, Collections.emptyMap(), Collections.emptyMap(), false); + + assertThat(props).isEmpty(); + logs.assertContains("Unknown property 'unknown_key' is not recognized and will be ignored."); + } + + @Test + void get_absentKey_returnsNull() { + assertThat( + ExtensionPropertyUtil.get("missing", new LinkedHashMap<>(), LogRecordLimitsModel.class)) + .isNull(); + } + + @Test + void get_presentKey_returnsTypedValue() { + Map props = new LinkedHashMap<>(); + LogRecordLimitsModel limits = new LogRecordLimitsModel(); + props.put("limits", limits); + + assertThat(ExtensionPropertyUtil.get("limits", props, LogRecordLimitsModel.class)) + .isSameAs(limits); + } + + @Test + void stableGetter_returnsGraduatedValue_fromExtensionPropertiesFallback() { + LoggerProviderModel model = new LoggerProviderModel(); + model.withExtensionProperty("limits/development", new LinkedHashMap<>()); + + assertThat(model.getLimits()).isNotNull().isInstanceOf(LogRecordLimitsModel.class); + } + + @Test + void filterSerializable_noStableProperties_returnsInputUnchanged() { + Map props = new LinkedHashMap<>(); + props.put("anything/development", "x"); + assertThat(ExtensionPropertyUtil.filterSerializable(props, Collections.emptyMap())) + .isSameAs(props); + } + + @Test + void filterSerializable_noMatchingGraduatedKeys_returnsInputUnchanged() { + Map props = new LinkedHashMap<>(); + props.put("composite/development", "x"); + Map> stableProperties = new HashMap<>(); + stableProperties.put("limits", LogRecordLimitsModel.class); + + assertThat(ExtensionPropertyUtil.filterSerializable(props, stableProperties)).isSameAs(props); + } + + @Test + void filterSerializable_dropsGraduatedKeys_preservesOthers() { + Map props = new LinkedHashMap<>(); + props.put("limits/development", "graduated"); + props.put("composite/development", "still-experimental"); + props.put("custom_key", "open-schema-extension"); + Map> stableProperties = new HashMap<>(); + stableProperties.put("limits", LogRecordLimitsModel.class); + + Map filtered = + ExtensionPropertyUtil.filterSerializable(props, stableProperties); + + assertThat(filtered) + .doesNotContainKey("limits/development") + .containsEntry("composite/development", "still-experimental") + .containsEntry("custom_key", "open-schema-extension"); + assertThat(props).containsKey("limits/development"); + } + + @Test + void stableModel_roundTripsGraduatedKey_emitsStableKeyOnly() throws Exception { + String json = "{\"limits/development\":{}}"; + LoggerProviderModel model = ModelMapper.MAPPER.readValue(json, LoggerProviderModel.class); + + assertThat(model.getLimits()).isNotNull().isInstanceOf(LogRecordLimitsModel.class); + + String reserialized = ModelMapper.MAPPER.writeValueAsString(model); + assertThat(reserialized).contains("\"limits\":").doesNotContain("limits/development"); + } + + @Test + void stableModel_roundTripsNonGraduatedDevelopmentKey_verbatim() throws Exception { + String json = "{\"composite/development\":{}}"; + SamplerModel model = ModelMapper.MAPPER.readValue(json, SamplerModel.class); + + String reserialized = ModelMapper.MAPPER.writeValueAsString(model); + assertThat(reserialized).contains("composite/development"); + } +} diff --git a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/IdGeneratorFactoryTest.java b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/IdGeneratorFactoryTest.java index 3b5bcbddcc9..ecbc7444352 100644 --- a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/IdGeneratorFactoryTest.java +++ b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/IdGeneratorFactoryTest.java @@ -13,9 +13,9 @@ import io.opentelemetry.internal.testing.CleanupExtension; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.component.IdGeneratorComponentProvider; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.IdGeneratorModel; -import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.IdGeneratorPropertyModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.RandomIdGeneratorModel; import io.opentelemetry.sdk.trace.IdGenerator; +import java.util.Collections; import java.util.stream.Stream; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.RegisterExtension; @@ -51,7 +51,7 @@ private static Stream createTestCases() { IdGenerator.random()), Arguments.argumentSet( "SPI id generator", - new IdGeneratorModel().withAdditionalProperty("test", new IdGeneratorPropertyModel()), + new IdGeneratorModel().withExtensionProperty("test", null), IdGeneratorComponentProvider.TestIdGenerator.create())); } @@ -68,9 +68,7 @@ private static Stream createInvalidTestCases() { Arguments.argumentSet( "unknown SPI id generator", new IdGeneratorModel() - .withAdditionalProperty( - "unknown_key", - new IdGeneratorPropertyModel().withAdditionalProperty("key1", "value")), + .withExtensionProperty("unknown_key", Collections.singletonMap("key1", "value")), "No component provider detected for io.opentelemetry.sdk.trace.IdGenerator with name \"unknown_key\".")); } } diff --git a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/LogRecordExporterFactoryTest.java b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/LogRecordExporterFactoryTest.java index 320d68f0a87..bb9ac1672b2 100644 --- a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/LogRecordExporterFactoryTest.java +++ b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/LogRecordExporterFactoryTest.java @@ -22,17 +22,18 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.GrpcTlsModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.HttpTlsModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LogRecordExporterModel; -import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LogRecordExporterPropertyModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.NameStringValuePairModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpGrpcExporterModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpHttpExporterModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalOtlpFileExporterModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.LogRecordExporterModelAccessor; import io.opentelemetry.sdk.logs.export.LogRecordExporter; import java.io.IOException; import java.nio.file.Path; import java.security.cert.CertificateEncodingException; import java.time.Duration; import java.util.Arrays; +import java.util.Collections; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Stream; import org.junit.jupiter.api.BeforeAll; @@ -156,8 +157,8 @@ Stream createTestCases() { .build()), Arguments.argumentSet( "otlp_file/development", - new LogRecordExporterModel() - .withOtlpFileDevelopment(new ExperimentalOtlpFileExporterModel()), + LogRecordExporterModelAccessor.withOtlpFile( + new LogRecordExporterModel(), new ExperimentalOtlpFileExporterModel()), OtlpStdoutLogRecordExporter.builder().build())); } @@ -174,9 +175,7 @@ Stream createInvalidTestCases() { Arguments.argumentSet( "unknown component provider", new LogRecordExporterModel() - .withAdditionalProperty( - "unknown_key", - new LogRecordExporterPropertyModel().withAdditionalProperty("key1", "value1")), + .withExtensionProperty("unknown_key", Collections.singletonMap("key1", "value1")), "No component provider detected for io.opentelemetry.sdk.logs.export.LogRecordExporter with name \"unknown_key\".")); } @@ -186,10 +185,7 @@ void create_SpiExporter_Valid() { LogRecordExporterFactory.getInstance() .create( new LogRecordExporterModel() - .withAdditionalProperty( - "test", - new LogRecordExporterPropertyModel() - .withAdditionalProperty("key1", "value1")), + .withExtensionProperty("test", Collections.singletonMap("key1", "value1")), context); assertThat(logRecordExporter) .isInstanceOf(LogRecordExporterComponentProvider.TestLogRecordExporter.class); diff --git a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/LogRecordProcessorFactoryTest.java b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/LogRecordProcessorFactoryTest.java index 993248282ef..5512536dff7 100644 --- a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/LogRecordProcessorFactoryTest.java +++ b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/LogRecordProcessorFactoryTest.java @@ -16,15 +16,16 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.BatchLogRecordProcessorModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LogRecordExporterModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LogRecordProcessorModel; -import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.LogRecordProcessorPropertyModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpHttpExporterModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SimpleLogRecordProcessorModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalEventToSpanEventBridgeLogRecordProcessorModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.LogRecordProcessorModelAccessor; import io.opentelemetry.sdk.extension.incubator.logs.EventToSpanEventBridge; import io.opentelemetry.sdk.logs.LogRecordProcessor; import io.opentelemetry.sdk.logs.export.BatchLogRecordProcessor; import io.opentelemetry.sdk.logs.export.SimpleLogRecordProcessor; import java.time.Duration; +import java.util.Collections; import java.util.stream.Stream; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.RegisterExtension; @@ -95,14 +96,13 @@ private static Stream createTestCases() { OtlpHttpLogRecordExporter.builder().setComponentLoader(context).build())), Arguments.argumentSet( "event_to_span_event_bridge/development", - new LogRecordProcessorModel() - .withEventToSpanEventBridgeDevelopment( - new ExperimentalEventToSpanEventBridgeLogRecordProcessorModel()), + LogRecordProcessorModelAccessor.withEventToSpanEventBridge( + new LogRecordProcessorModel(), + new ExperimentalEventToSpanEventBridgeLogRecordProcessorModel()), EventToSpanEventBridge.create()), Arguments.argumentSet( "spi test processor", - new LogRecordProcessorModel() - .withAdditionalProperty("test", new LogRecordProcessorPropertyModel()), + new LogRecordProcessorModel().withExtensionProperty("test", null), LogRecordProcessorComponentProvider.TestLogRecordProcessor.create())); } @@ -127,9 +127,7 @@ private static Stream createInvalidTestCases() { Arguments.argumentSet( "unknown component provider", new LogRecordProcessorModel() - .withAdditionalProperty( - "unknown_key", - new LogRecordProcessorPropertyModel().withAdditionalProperty("key1", "value1")), + .withExtensionProperty("unknown_key", Collections.singletonMap("key1", "value1")), "No component provider detected for io.opentelemetry.sdk.logs.LogRecordProcessor with name \"unknown_key\".")); } } diff --git a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/LoggerProviderFactoryTest.java b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/LoggerProviderFactoryTest.java index 1336c24ebf8..6f2ed9e80de 100644 --- a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/LoggerProviderFactoryTest.java +++ b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/LoggerProviderFactoryTest.java @@ -23,6 +23,7 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalLoggerConfigModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalLoggerConfiguratorModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalLoggerMatcherAndConfigModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.LoggerProviderModelAccessor; import io.opentelemetry.sdk.common.internal.ScopeConfigurator; import io.opentelemetry.sdk.common.internal.ScopeConfiguratorBuilder; import io.opentelemetry.sdk.logs.LogLimits; @@ -81,32 +82,31 @@ private static Stream createArguments() { "full configuration", LoggerProviderAndAttributeLimits.create( new AttributeLimitsModel(), - new LoggerProviderModel() - .withLimits( - new LogRecordLimitsModel() - .withAttributeCountLimit(1) - .withAttributeValueLengthLimit(2)) - .withProcessors( - Collections.singletonList( - new LogRecordProcessorModel() - .withBatch( - new BatchLogRecordProcessorModel() - .withExporter( - new LogRecordExporterModel() - .withOtlpHttp(new OtlpHttpExporterModel()))))) - .withLoggerConfiguratorDevelopment( - new ExperimentalLoggerConfiguratorModel() - .withDefaultConfig( - new ExperimentalLoggerConfigModel().withEnabled(false)) - .withLoggers( - Collections.singletonList( - new ExperimentalLoggerMatcherAndConfigModel() - .withName("foo") - .withConfig( - new ExperimentalLoggerConfigModel() - .withEnabled(true) - .withTraceBased(true) - .withMinimumSeverity(SeverityNumberModel.INFO)))))), + LoggerProviderModelAccessor.withLoggerConfigurator( + new LoggerProviderModel() + .withLimits( + new LogRecordLimitsModel() + .withAttributeCountLimit(1) + .withAttributeValueLengthLimit(2)) + .withProcessors( + Collections.singletonList( + new LogRecordProcessorModel() + .withBatch( + new BatchLogRecordProcessorModel() + .withExporter( + new LogRecordExporterModel() + .withOtlpHttp(new OtlpHttpExporterModel()))))), + new ExperimentalLoggerConfiguratorModel() + .withDefaultConfig(new ExperimentalLoggerConfigModel().withEnabled(false)) + .withLoggers( + Collections.singletonList( + new ExperimentalLoggerMatcherAndConfigModel() + .withName("foo") + .withConfig( + new ExperimentalLoggerConfigModel() + .withEnabled(true) + .withTraceBased(true) + .withMinimumSeverity(SeverityNumberModel.INFO)))))), setLoggerConfigurator( SdkLoggerProvider.builder(), ScopeConfigurator.builder() diff --git a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/MeterProviderFactoryTest.java b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/MeterProviderFactoryTest.java index 1f890776f70..000162bc871 100644 --- a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/MeterProviderFactoryTest.java +++ b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/MeterProviderFactoryTest.java @@ -23,6 +23,7 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalMeterConfigModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalMeterConfiguratorModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalMeterMatcherAndConfigModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.MeterProviderModelAccessor; import io.opentelemetry.sdk.common.internal.ScopeConfigurator; import io.opentelemetry.sdk.common.internal.ScopeConfiguratorBuilder; import io.opentelemetry.sdk.metrics.ExemplarFilter; @@ -74,25 +75,27 @@ private static Stream createArguments() { "defaults", new MeterProviderModel(), SdkMeterProvider.builder().build()), Arguments.argumentSet( "with reader view and meter configurator", - new MeterProviderModel() - .withReaders( - Collections.singletonList( - new MetricReaderModel() - .withPeriodic( - new PeriodicMetricReaderModel() - .withExporter( - new PushMetricExporterModel() - .withOtlpHttp(new OtlpHttpMetricExporterModel()))))) - .withViews( - Collections.singletonList( - new ViewModel() - .withSelector( - new ViewSelectorModel().withInstrumentName("instrument-name")) - .withStream( - new ViewStreamModel() - .withName("stream-name") - .withAttributeKeys(null)))) - .withMeterConfiguratorDevelopment( + MeterProviderModelAccessor.withMeterConfigurator( + new MeterProviderModel() + .withReaders( + Collections.singletonList( + new MetricReaderModel() + .withPeriodic( + new PeriodicMetricReaderModel() + .withExporter( + new PushMetricExporterModel() + .withOtlpHttp( + new OtlpHttpMetricExporterModel()))))) + .withViews( + Collections.singletonList( + new ViewModel() + .withSelector( + new ViewSelectorModel() + .withInstrumentName("instrument-name")) + .withStream( + new ViewStreamModel() + .withName("stream-name") + .withAttributeKeys(null)))), new ExperimentalMeterConfiguratorModel() .withDefaultConfig(new ExperimentalMeterConfigModel().withEnabled(false)) .withMeters( diff --git a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/MetricExporterFactoryTest.java b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/MetricExporterFactoryTest.java index 219ef6f0566..e8a071078b8 100644 --- a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/MetricExporterFactoryTest.java +++ b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/MetricExporterFactoryTest.java @@ -27,8 +27,8 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpGrpcMetricExporterModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpHttpMetricExporterModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PushMetricExporterModel; -import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PushMetricExporterPropertyModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalOtlpFileMetricExporterModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.PushMetricExporterModelAccessor; import io.opentelemetry.sdk.metrics.Aggregation; import io.opentelemetry.sdk.metrics.InstrumentType; import io.opentelemetry.sdk.metrics.export.AggregationTemporalitySelector; @@ -39,6 +39,7 @@ import java.security.cert.CertificateEncodingException; import java.time.Duration; import java.util.Arrays; +import java.util.Collections; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Stream; import org.junit.jupiter.api.BeforeAll; @@ -186,8 +187,8 @@ Stream createTestCases() { LoggingMetricExporter.create()), Arguments.argumentSet( "otlp_file/development", - new PushMetricExporterModel() - .withOtlpFileDevelopment(new ExperimentalOtlpFileMetricExporterModel()), + PushMetricExporterModelAccessor.withOtlpFile( + new PushMetricExporterModel(), new ExperimentalOtlpFileMetricExporterModel()), OtlpStdoutMetricExporter.builder().build())); } @@ -204,9 +205,7 @@ Stream createInvalidTestCases() { Arguments.argumentSet( "unknown component provider", new PushMetricExporterModel() - .withAdditionalProperty( - "unknown_key", - new PushMetricExporterPropertyModel().withAdditionalProperty("key1", "value1")), + .withExtensionProperty("unknown_key", Collections.singletonMap("key1", "value1")), "No component provider detected for io.opentelemetry.sdk.metrics.export.MetricExporter with name \"unknown_key\".")); } @@ -216,10 +215,7 @@ void create_SpiExporter_Valid() { MetricExporterFactory.getInstance() .create( new PushMetricExporterModel() - .withAdditionalProperty( - "test", - new PushMetricExporterPropertyModel() - .withAdditionalProperty("key1", "value1")), + .withExtensionProperty("test", Collections.singletonMap("key1", "value1")), context); assertThat(metricExporter) .isInstanceOf(MetricExporterComponentProvider.TestMetricExporter.class); diff --git a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/MetricReaderFactoryTest.java b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/MetricReaderFactoryTest.java index 38c9c4e4bb0..144942f53ad 100644 --- a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/MetricReaderFactoryTest.java +++ b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/MetricReaderFactoryTest.java @@ -30,6 +30,8 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.PushMetricExporterModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalPrometheusMetricExporterModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalPrometheusTranslationStrategyModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.PeriodicMetricReaderModelAccessor; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.PullMetricExporterModelAccessor; import io.opentelemetry.sdk.common.internal.IncludeExcludePredicate; import io.opentelemetry.sdk.metrics.InstrumentType; import io.opentelemetry.sdk.metrics.export.MetricReader; @@ -117,14 +119,15 @@ static Stream createTestCases() throws IOException { "periodic configured", new MetricReaderModel() .withPeriodic( - new PeriodicMetricReaderModel() - .withExporter( - new PushMetricExporterModel() - .withOtlpHttp(new OtlpHttpMetricExporterModel())) - .withInterval(1) - .withCardinalityLimits( - new CardinalityLimitsModel().withDefault(100)) - .withMaxExportBatchSizeDevelopment(200)), + PeriodicMetricReaderModelAccessor.withMaxExportBatchSize( + new PeriodicMetricReaderModel() + .withExporter( + new PushMetricExporterModel() + .withOtlpHttp(new OtlpHttpMetricExporterModel())) + .withInterval(1) + .withCardinalityLimits( + new CardinalityLimitsModel().withDefault(100)), + 200)), SdkMeterProviderUtil.setMaxExportBatchSize( PeriodicMetricReader.builder( OtlpHttpMetricExporter.builder() @@ -147,10 +150,10 @@ static Stream createTestCases() throws IOException { .withPull( new PullMetricReaderModel() .withExporter( - new PullMetricExporterModel() - .withPrometheusDevelopment( - new ExperimentalPrometheusMetricExporterModel() - .withPort(prom1Port)))), + PullMetricExporterModelAccessor.withPrometheus( + new PullMetricExporterModel(), + new ExperimentalPrometheusMetricExporterModel() + .withPort(prom1Port)))), prom1Expected, null, true)); @@ -175,20 +178,20 @@ static Stream createTestCases() throws IOException { new PullMetricReaderModel() .withCardinalityLimits(new CardinalityLimitsModel().withDefault(100)) .withExporter( - new PullMetricExporterModel() - .withPrometheusDevelopment( - new ExperimentalPrometheusMetricExporterModel() - .withHost("localhost") - .withPort(prom2Port) - .withResourceConstantLabels( - new IncludeExcludeModel() - .withIncluded(singletonList("foo")) - .withExcluded(singletonList("bar"))) - .withScopeInfoEnabled(false) - .withTargetInfoEnabledDevelopment(false) - .withTranslationStrategy( - ExperimentalPrometheusTranslationStrategyModel - .UNDERSCORE_ESCAPING_WITHOUT_SUFFIXES_DEVELOPMENT)))), + PullMetricExporterModelAccessor.withPrometheus( + new PullMetricExporterModel(), + new ExperimentalPrometheusMetricExporterModel() + .withHost("localhost") + .withPort(prom2Port) + .withResourceConstantLabels( + new IncludeExcludeModel() + .withIncluded(singletonList("foo")) + .withExcluded(singletonList("bar"))) + .withScopeInfoEnabled(false) + .withTargetInfoEnabledDevelopment(false) + .withTranslationStrategy( + ExperimentalPrometheusTranslationStrategyModel + .UNDERSCORE_ESCAPING_WITHOUT_SUFFIXES_DEVELOPMENT)))), prom2Expected, 100, true)); @@ -208,14 +211,14 @@ static Stream createTestCases() throws IOException { .withPull( new PullMetricReaderModel() .withExporter( - new PullMetricExporterModel() - .withPrometheusDevelopment( - new ExperimentalPrometheusMetricExporterModel() - .withHost("localhost") - .withPort(prom3Port) - .withTranslationStrategy( - ExperimentalPrometheusTranslationStrategyModel - .NO_TRANSLATION_DEVELOPMENT)))), + PullMetricExporterModelAccessor.withPrometheus( + new PullMetricExporterModel(), + new ExperimentalPrometheusMetricExporterModel() + .withHost("localhost") + .withPort(prom3Port) + .withTranslationStrategy( + ExperimentalPrometheusTranslationStrategyModel + .NO_TRANSLATION_DEVELOPMENT)))), prom3Expected, null, true)); diff --git a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/OpenTelemetryConfigurationFactoryTest.java b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/OpenTelemetryConfigurationFactoryTest.java index 1ce8e112283..97f4acb570f 100644 --- a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/OpenTelemetryConfigurationFactoryTest.java +++ b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/OpenTelemetryConfigurationFactoryTest.java @@ -52,6 +52,7 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ViewStreamModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalResourceDetectionModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalResourceDetectorModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ResourceModelAccessor; import io.opentelemetry.sdk.internal.ExtendedOpenTelemetrySdk; import io.opentelemetry.sdk.internal.OpenTelemetrySdkBuilderUtil; import io.opentelemetry.sdk.internal.SdkConfigProvider; @@ -238,8 +239,8 @@ void create_Configured() throws NoSuchFieldException { .withPropagator( new PropagatorModel().withCompositeList("tracecontext,baggage,b3multi,b3")) .withResource( - new ResourceModel() - .withDetectionDevelopment( + ResourceModelAccessor.withDetection( + new ResourceModel(), new ExperimentalResourceDetectionModel() .withDetectors( Arrays.asList( diff --git a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/PropagatorFactoryTest.java b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/PropagatorFactoryTest.java index cea489ee45b..ee14ceaf528 100644 --- a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/PropagatorFactoryTest.java +++ b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/PropagatorFactoryTest.java @@ -106,7 +106,7 @@ private static Stream createArguments() { new PropagatorModel() .withComposite( Collections.singletonList( - new TextMapPropagatorModel().withAdditionalProperty("test", null))), + new TextMapPropagatorModel().withExtensionProperty("test", null))), ContextPropagators.create( TextMapPropagator.composite( new TextMapPropagatorComponentProvider.TestTextMapPropagator( diff --git a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/ResourceFactoryTest.java b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/ResourceFactoryTest.java index 220b774f2b2..86db236316e 100644 --- a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/ResourceFactoryTest.java +++ b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/ResourceFactoryTest.java @@ -15,6 +15,7 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ResourceModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalResourceDetectionModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalResourceDetectorModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ResourceModelAccessor; import io.opentelemetry.sdk.resources.Resource; import java.util.Arrays; import java.util.Collections; @@ -68,19 +69,19 @@ private static Stream createArgs() { void createWithDetectors( @Nullable List included, @Nullable List excluded, Resource expectedResource) { ResourceModel resourceModel = - new ResourceModel() - .withDetectionDevelopment( - new ExperimentalResourceDetectionModel() - .withDetectors( - Arrays.asList( - new ExperimentalResourceDetectorModel() - .withAdditionalProperty("order_first", null), - new ExperimentalResourceDetectorModel() - .withAdditionalProperty("order_second", null), - new ExperimentalResourceDetectorModel() - .withAdditionalProperty("shape_color", null))) - .withAttributes( - new IncludeExcludeModel().withIncluded(included).withExcluded(excluded))); + ResourceModelAccessor.withDetection( + new ResourceModel(), + new ExperimentalResourceDetectionModel() + .withDetectors( + Arrays.asList( + new ExperimentalResourceDetectorModel() + .withAdditionalProperty("order_first", null), + new ExperimentalResourceDetectorModel() + .withAdditionalProperty("order_second", null), + new ExperimentalResourceDetectorModel() + .withAdditionalProperty("shape_color", null))) + .withAttributes( + new IncludeExcludeModel().withIncluded(included).withExcluded(excluded))); Resource resource = ResourceFactory.getInstance().create(resourceModel, context); assertThat(resource).isEqualTo(expectedResource); } @@ -179,52 +180,52 @@ private static Stream createInvalidDetectorsArgs() { return Stream.of( Arguments.argumentSet( "unknown detector", - new ResourceModel() - .withDetectionDevelopment( - new ExperimentalResourceDetectionModel() - .withDetectors( - Collections.singletonList( - new ExperimentalResourceDetectorModel() - .withAdditionalProperty("foo", null)))), + ResourceModelAccessor.withDetection( + new ResourceModel(), + new ExperimentalResourceDetectionModel() + .withDetectors( + Collections.singletonList( + new ExperimentalResourceDetectorModel() + .withAdditionalProperty("foo", null)))), "No component provider detected for io.opentelemetry.sdk.resources.Resource with name \"foo\"."), Arguments.argumentSet( "detector multiple entries", - new ResourceModel() - .withDetectionDevelopment( - new ExperimentalResourceDetectionModel() - .withDetectors( - Collections.singletonList( - new ExperimentalResourceDetectorModel() - .withAdditionalProperty("foo", null) - .withAdditionalProperty("bar", null)))), + ResourceModelAccessor.withDetection( + new ResourceModel(), + new ExperimentalResourceDetectionModel() + .withDetectors( + Collections.singletonList( + new ExperimentalResourceDetectorModel() + .withAdditionalProperty("foo", null) + .withAdditionalProperty("bar", null)))), "resource detector must have exactly one entry but has 2: [foo,bar]"), Arguments.argumentSet( "detector no entries", - new ResourceModel() - .withDetectionDevelopment( - new ExperimentalResourceDetectionModel() - .withDetectors( - Collections.singletonList(new ExperimentalResourceDetectorModel()))), + ResourceModelAccessor.withDetection( + new ResourceModel(), + new ExperimentalResourceDetectionModel() + .withDetectors( + Collections.singletonList(new ExperimentalResourceDetectorModel()))), "resource detector must have exactly one entry but has 0"), Arguments.argumentSet( "included empty list", - new ResourceModel() - .withDetectionDevelopment( - new ExperimentalResourceDetectionModel() - .withAttributes( - new IncludeExcludeModel() - .withIncluded(Collections.emptyList()) - .withExcluded(null))), + ResourceModelAccessor.withDetection( + new ResourceModel(), + new ExperimentalResourceDetectionModel() + .withAttributes( + new IncludeExcludeModel() + .withIncluded(Collections.emptyList()) + .withExcluded(null))), "included must not be empty"), Arguments.argumentSet( "excluded empty list", - new ResourceModel() - .withDetectionDevelopment( - new ExperimentalResourceDetectionModel() - .withAttributes( - new IncludeExcludeModel() - .withIncluded(null) - .withExcluded(Collections.emptyList()))), + ResourceModelAccessor.withDetection( + new ResourceModel(), + new ExperimentalResourceDetectionModel() + .withAttributes( + new IncludeExcludeModel() + .withIncluded(null) + .withExcluded(Collections.emptyList()))), "excluded must not be empty")); } } diff --git a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/SamplerFactoryTest.java b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/SamplerFactoryTest.java index 9a6a1f599bf..3a54f2d5201 100644 --- a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/SamplerFactoryTest.java +++ b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/SamplerFactoryTest.java @@ -17,7 +17,6 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.AlwaysOnSamplerModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.ParentBasedSamplerModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SamplerModel; -import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SamplerPropertyModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.TraceIdRatioBasedSamplerModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalComposableAlwaysOffSamplerModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalComposableAlwaysOnSamplerModel; @@ -26,6 +25,7 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalComposableRuleBasedSamplerModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalComposableSamplerModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalJaegerRemoteSamplerModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.SamplerModelAccessor; import io.opentelemetry.sdk.extension.incubator.trace.samplers.ComposableSampler; import io.opentelemetry.sdk.extension.incubator.trace.samplers.CompositeSampler; import io.opentelemetry.sdk.extension.trace.jaeger.sampler.JaegerRemoteSampler; @@ -34,6 +34,7 @@ import java.io.Closeable; import java.time.Duration; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.stream.Stream; import javax.annotation.Nullable; @@ -124,13 +125,13 @@ private static Stream createArguments() { .build()), Arguments.argumentSet( "jaeger_remote", - new SamplerModel() - .withJaegerRemoteDevelopment( - new ExperimentalJaegerRemoteSamplerModel() - .withEndpoint("http://jaeger-remote-endpoint") - .withInterval(10_000) - .withInitialSampler( - new SamplerModel().withAlwaysOff(new AlwaysOffSamplerModel()))), + SamplerModelAccessor.withJaegerRemote( + new SamplerModel(), + new ExperimentalJaegerRemoteSamplerModel() + .withEndpoint("http://jaeger-remote-endpoint") + .withInterval(10_000) + .withInitialSampler( + new SamplerModel().withAlwaysOff(new AlwaysOffSamplerModel()))), JaegerRemoteSampler.builder() .setEndpoint("http://jaeger-remote-endpoint") .setPollingInterval(Duration.ofSeconds(10)) @@ -138,44 +139,44 @@ private static Stream createArguments() { .build()), Arguments.argumentSet( "composite/development always_on", - new SamplerModel() - .withCompositeDevelopment( - new ExperimentalComposableSamplerModel() - .withAlwaysOn(new ExperimentalComposableAlwaysOnSamplerModel())), + SamplerModelAccessor.withComposite( + new SamplerModel(), + new ExperimentalComposableSamplerModel() + .withAlwaysOn(new ExperimentalComposableAlwaysOnSamplerModel())), CompositeSampler.wrap(ComposableSampler.alwaysOn())), Arguments.argumentSet( "composite/development always_off", - new SamplerModel() - .withCompositeDevelopment( - new ExperimentalComposableSamplerModel() - .withAlwaysOff(new ExperimentalComposableAlwaysOffSamplerModel())), + SamplerModelAccessor.withComposite( + new SamplerModel(), + new ExperimentalComposableSamplerModel() + .withAlwaysOff(new ExperimentalComposableAlwaysOffSamplerModel())), CompositeSampler.wrap(ComposableSampler.alwaysOff())), Arguments.argumentSet( "composite/development probability", - new SamplerModel() - .withCompositeDevelopment( - new ExperimentalComposableSamplerModel() - .withProbability( - new ExperimentalComposableProbabilitySamplerModel().withRatio(0.5))), + SamplerModelAccessor.withComposite( + new SamplerModel(), + new ExperimentalComposableSamplerModel() + .withProbability( + new ExperimentalComposableProbabilitySamplerModel().withRatio(0.5))), CompositeSampler.wrap(ComposableSampler.probability(0.5))), Arguments.argumentSet( "composite/development rule_based", - new SamplerModel() - .withCompositeDevelopment( - new ExperimentalComposableSamplerModel() - .withRuleBased(new ExperimentalComposableRuleBasedSamplerModel())), + SamplerModelAccessor.withComposite( + new SamplerModel(), + new ExperimentalComposableSamplerModel() + .withRuleBased(new ExperimentalComposableRuleBasedSamplerModel())), CompositeSampler.wrap(ComposableSampler.ruleBasedBuilder().build())), Arguments.argumentSet( "composite/development parent_threshold", - new SamplerModel() - .withCompositeDevelopment( - new ExperimentalComposableSamplerModel() - .withParentThreshold( - new ExperimentalComposableParentThresholdSamplerModel() - .withRoot( - new ExperimentalComposableSamplerModel() - .withAlwaysOn( - new ExperimentalComposableAlwaysOnSamplerModel())))), + SamplerModelAccessor.withComposite( + new SamplerModel(), + new ExperimentalComposableSamplerModel() + .withParentThreshold( + new ExperimentalComposableParentThresholdSamplerModel() + .withRoot( + new ExperimentalComposableSamplerModel() + .withAlwaysOn( + new ExperimentalComposableAlwaysOnSamplerModel())))), CompositeSampler.wrap( ComposableSampler.parentThreshold(ComposableSampler.alwaysOn())))); } @@ -194,30 +195,27 @@ private static Stream createInvalidArguments() { return Stream.of( Arguments.argumentSet( "jaeger_remote missing endpoint", - new SamplerModel() - .withJaegerRemoteDevelopment(new ExperimentalJaegerRemoteSamplerModel()), + SamplerModelAccessor.withJaegerRemote( + new SamplerModel(), new ExperimentalJaegerRemoteSamplerModel()), "jaeger remote sampler endpoint is required"), Arguments.argumentSet( "jaeger_remote missing initialSampler", - new SamplerModel() - .withJaegerRemoteDevelopment( - new ExperimentalJaegerRemoteSamplerModel() - .withEndpoint("http://jaeger-remote-endpoint")), + SamplerModelAccessor.withJaegerRemote( + new SamplerModel(), + new ExperimentalJaegerRemoteSamplerModel() + .withEndpoint("http://jaeger-remote-endpoint")), "jaeger remote sampler initial_sampler is required"), Arguments.argumentSet( "parent_threshold missing root", - new SamplerModel() - .withCompositeDevelopment( - new ExperimentalComposableSamplerModel() - .withParentThreshold( - new ExperimentalComposableParentThresholdSamplerModel())), + SamplerModelAccessor.withComposite( + new SamplerModel(), + new ExperimentalComposableSamplerModel() + .withParentThreshold(new ExperimentalComposableParentThresholdSamplerModel())), "parent threshold sampler root is required but is null"), Arguments.argumentSet( "unknown component provider", new SamplerModel() - .withAdditionalProperty( - "unknown_key", - new SamplerPropertyModel().withAdditionalProperty("key1", "value1")), + .withExtensionProperty("unknown_key", Collections.singletonMap("key1", "value1")), "No component provider detected for io.opentelemetry.sdk.trace.samplers.Sampler with name \"unknown_key\".")); } @@ -227,9 +225,7 @@ void create_SpiExporter_Valid() { SamplerFactory.getInstance() .create( new SamplerModel() - .withAdditionalProperty( - "test", - new SamplerPropertyModel().withAdditionalProperty("key1", "value1")), + .withExtensionProperty("test", Collections.singletonMap("key1", "value1")), context); assertThat(sampler).isInstanceOf(SamplerComponentProvider.TestSampler.class); assertThat(((SamplerComponentProvider.TestSampler) sampler).config.getString("key1")) diff --git a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/SpanExporterFactoryTest.java b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/SpanExporterFactoryTest.java index 49409121652..c08fd2244ff 100644 --- a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/SpanExporterFactoryTest.java +++ b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/SpanExporterFactoryTest.java @@ -26,8 +26,8 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpGrpcExporterModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.OtlpHttpExporterModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SpanExporterModel; -import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SpanExporterPropertyModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalOtlpFileExporterModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.SpanExporterModelAccessor; import io.opentelemetry.sdk.extension.trace.jaeger.sampler.JaegerRemoteSampler; import io.opentelemetry.sdk.trace.export.SpanExporter; import java.io.IOException; @@ -35,6 +35,7 @@ import java.security.cert.CertificateEncodingException; import java.time.Duration; import java.util.Arrays; +import java.util.Collections; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Stream; import org.junit.jupiter.api.BeforeAll; @@ -163,8 +164,8 @@ Stream createTestCases() { LoggingSpanExporter.create()), Arguments.argumentSet( "otlp_file/development", - new SpanExporterModel() - .withOtlpFileDevelopment(new ExperimentalOtlpFileExporterModel()), + SpanExporterModelAccessor.withOtlpFile( + new SpanExporterModel(), new ExperimentalOtlpFileExporterModel()), OtlpStdoutSpanExporter.builder().build())); } @@ -181,9 +182,7 @@ Stream createInvalidTestCases() { Arguments.argumentSet( "unknown component provider", new SpanExporterModel() - .withAdditionalProperty( - "unknown_key", - new SpanExporterPropertyModel().withAdditionalProperty("key1", "value1")), + .withExtensionProperty("unknown_key", Collections.singletonMap("key1", "value1")), "No component provider detected for io.opentelemetry.sdk.trace.export.SpanExporter with name \"unknown_key\".")); } @@ -193,9 +192,7 @@ void create_SpiExporter_Valid() { SpanExporterFactory.getInstance() .create( new SpanExporterModel() - .withAdditionalProperty( - "test", - new SpanExporterPropertyModel().withAdditionalProperty("key1", "value1")), + .withExtensionProperty("test", Collections.singletonMap("key1", "value1")), context); assertThat(spanExporter).isInstanceOf(SpanExporterComponentProvider.TestSpanExporter.class); assertThat( diff --git a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/SpanProcessorFactoryTest.java b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/SpanProcessorFactoryTest.java index 416c172f58b..e826a320831 100644 --- a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/SpanProcessorFactoryTest.java +++ b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/SpanProcessorFactoryTest.java @@ -18,11 +18,11 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SimpleSpanProcessorModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SpanExporterModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SpanProcessorModel; -import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.SpanProcessorPropertyModel; import io.opentelemetry.sdk.trace.SpanProcessor; import io.opentelemetry.sdk.trace.export.BatchSpanProcessor; import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor; import java.time.Duration; +import java.util.Collections; import java.util.stream.Stream; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -113,9 +113,7 @@ private static Stream createInvalidTestCases() { Arguments.argumentSet( "unknown component provider", new SpanProcessorModel() - .withAdditionalProperty( - "unknown_key", - new SpanProcessorPropertyModel().withAdditionalProperty("key1", "value1")), + .withExtensionProperty("unknown_key", Collections.singletonMap("key1", "value1")), "No component provider detected for io.opentelemetry.sdk.trace.SpanProcessor with name \"unknown_key\".")); } @@ -125,9 +123,7 @@ void create_SpiProcessor_Valid() { SpanProcessorFactory.getInstance() .create( new SpanProcessorModel() - .withAdditionalProperty( - "test", - new SpanProcessorPropertyModel().withAdditionalProperty("key1", "value1")), + .withExtensionProperty("test", Collections.singletonMap("key1", "value1")), context); assertThat(spanProcessor).isInstanceOf(SpanProcessorComponentProvider.TestSpanProcessor.class); assertThat( diff --git a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/TracerProviderFactoryTest.java b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/TracerProviderFactoryTest.java index da944bed5e0..dc1956b4870 100644 --- a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/TracerProviderFactoryTest.java +++ b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/TracerProviderFactoryTest.java @@ -23,6 +23,7 @@ import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalTracerConfigModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalTracerConfiguratorModel; import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.ExperimentalTracerMatcherAndConfigModel; +import io.opentelemetry.sdk.autoconfigure.declarativeconfig.model.internal.TracerProviderModelAccessor; import io.opentelemetry.sdk.common.internal.ScopeConfigurator; import io.opentelemetry.sdk.common.internal.ScopeConfiguratorBuilder; import io.opentelemetry.sdk.trace.SdkTracerProvider; @@ -83,35 +84,33 @@ private static Stream createArguments() { "full configuration", TracerProviderAndAttributeLimits.create( new AttributeLimitsModel(), - new TracerProviderModel() - .withLimits( - new SpanLimitsModel() - .withAttributeCountLimit(1) - .withAttributeValueLengthLimit(2) - .withEventCountLimit(3) - .withLinkCountLimit(4) - .withEventAttributeCountLimit(5) - .withLinkAttributeCountLimit(6)) - .withSampler(new SamplerModel().withAlwaysOn(new AlwaysOnSamplerModel())) - .withProcessors( - Collections.singletonList( - new SpanProcessorModel() - .withBatch( - new BatchSpanProcessorModel() - .withExporter( - new SpanExporterModel() - .withOtlpHttp(new OtlpHttpExporterModel()))))) - .withTracerConfiguratorDevelopment( - new ExperimentalTracerConfiguratorModel() - .withDefaultConfig( - new ExperimentalTracerConfigModel().withEnabled(false)) - .withTracers( - Collections.singletonList( - new ExperimentalTracerMatcherAndConfigModel() - .withName("foo") - .withConfig( - new ExperimentalTracerConfigModel() - .withEnabled(true)))))), + TracerProviderModelAccessor.withTracerConfigurator( + new TracerProviderModel() + .withLimits( + new SpanLimitsModel() + .withAttributeCountLimit(1) + .withAttributeValueLengthLimit(2) + .withEventCountLimit(3) + .withLinkCountLimit(4) + .withEventAttributeCountLimit(5) + .withLinkAttributeCountLimit(6)) + .withSampler(new SamplerModel().withAlwaysOn(new AlwaysOnSamplerModel())) + .withProcessors( + Collections.singletonList( + new SpanProcessorModel() + .withBatch( + new BatchSpanProcessorModel() + .withExporter( + new SpanExporterModel() + .withOtlpHttp(new OtlpHttpExporterModel()))))), + new ExperimentalTracerConfiguratorModel() + .withDefaultConfig(new ExperimentalTracerConfigModel().withEnabled(false)) + .withTracers( + Collections.singletonList( + new ExperimentalTracerMatcherAndConfigModel() + .withName("foo") + .withConfig( + new ExperimentalTracerConfigModel().withEnabled(true)))))), addTracerConfigurator( SdkTracerProvider.builder(), ScopeConfigurator.builder() diff --git a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ModelPackageBoundaryTest.java b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ModelPackageBoundaryTest.java index 731d5fbd82f..dec71f24aef 100644 --- a/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ModelPackageBoundaryTest.java +++ b/sdk-extensions/declarative-config/src/test/java/io/opentelemetry/sdk/autoconfigure/declarativeconfig/model/ModelPackageBoundaryTest.java @@ -16,11 +16,13 @@ /** * Guards the experimental/stable package boundary for the generated model types. * - *

Experimental (unstable) types must live in {@code MODEL_PACKAGE.internal} (exempt from the - * stability guarantees in {@code VERSIONING.md}) and stable types in {@code MODEL_PACKAGE}. The - * generator enforces this by routing types whose name starts with {@code Experimental} into the - * internal sub-package. This test fails if a schema update or rename ever breaks that invariant - * — e.g. leaking a mutable experimental type into the stable public API. + *

Experimental (unstable) model types must live in {@code MODEL_PACKAGE.internal} and stable + * model types in {@code MODEL_PACKAGE}. The generator routes types whose name starts with {@code + * Experimental} to the internal sub-package. {@code *ModelAccessor} classes also live in {@code + * MODEL_PACKAGE.internal}; they provide typed access to experimental properties on stable classes + * and are exempt from the {@code Experimental} prefix requirement. This test fails if a schema + * update or rename ever breaks the invariant — e.g. leaking a mutable experimental type into + * the stable public API. */ class ModelPackageBoundaryTest { @@ -51,10 +53,15 @@ void experimentalTypesAreExactlyTheInternalPackage() throws IOException { clazz -> { boolean inInternal = clazz.getPackage().getName().equals(INTERNAL_PACKAGE); boolean experimental = clazz.getSimpleName().startsWith(EXPERIMENTAL_PREFIX); - assertThat(experimental) + // Internal utility classes are exempt from the Experimental prefix requirement. + boolean isInfrastructure = + clazz.getSimpleName().endsWith("Accessor") + || clazz.getSimpleName().equals("ModelMapper") + || clazz.getSimpleName().equals("ExtensionPropertyUtil"); + assertThat(experimental || isInfrastructure) .as( - "%s: experimental types (name starts with %s) must live in %s, all other " - + "types in %s", + "%s: experimental types (name starts with %s) and internal infrastructure " + + "classes must live in %s, all other types in %s", clazz.getName(), EXPERIMENTAL_PREFIX, INTERNAL_PACKAGE, MODEL_PACKAGE) .isEqualTo(inInternal); });