Class DeclarativeConfiguration

java.lang.Object
io.opentelemetry.sdk.extension.incubator.fileconfig.DeclarativeConfiguration

public final class DeclarativeConfiguration extends Object
Configure OpenTelemetrySdk using declarative configuration. For most users, this means calling parseAndCreate(InputStream) with a YAML configuration file.

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:


 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
  • Method Summary

    Modifier and Type
    Method
    Description
    static io.opentelemetry.sdk.internal.ExtendedOpenTelemetrySdk
    create(io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.OpenTelemetryConfigurationModel configurationModel)
    Interpret the configurationModel to create OpenTelemetrySdk instance corresponding to the configuration.
    static io.opentelemetry.sdk.internal.ExtendedOpenTelemetrySdk
    create(io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.OpenTelemetryConfigurationModel configurationModel, io.opentelemetry.common.ComponentLoader componentLoader)
    Interpret the configurationModel to create OpenTelemetrySdk instance corresponding to the configuration.
    static io.opentelemetry.sdk.trace.samplers.Sampler
    createSampler(io.opentelemetry.api.incubator.config.DeclarativeConfigProperties genericSamplerModel)
    Create a SamplerModel from the samplerModel representing the sampler config.
    static io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.OpenTelemetryConfigurationModel
    parse(InputStream configuration)
    Parse the configuration YAML and return the OpenTelemetryConfigurationModel.
    static io.opentelemetry.sdk.internal.ExtendedOpenTelemetrySdk
    static io.opentelemetry.api.incubator.config.DeclarativeConfigProperties
    Convert the configuration YAML to a generic DeclarativeConfigProperties.
    static io.opentelemetry.api.incubator.config.DeclarativeConfigProperties
    Convert the model to a generic DeclarativeConfigProperties.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • parseAndCreate

      public static io.opentelemetry.sdk.internal.ExtendedOpenTelemetrySdk parseAndCreate(InputStream inputStream)
      Throws:
      io.opentelemetry.api.incubator.config.DeclarativeConfigException - if unable to parse or interpret
    • create

      public static io.opentelemetry.sdk.internal.ExtendedOpenTelemetrySdk create(io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.OpenTelemetryConfigurationModel configurationModel)
      Interpret the configurationModel to create OpenTelemetrySdk instance corresponding to the configuration.
      Parameters:
      configurationModel - the configuration model
      Returns:
      the OpenTelemetrySdk
      Throws:
      io.opentelemetry.api.incubator.config.DeclarativeConfigException - if unable to interpret
    • create

      public static io.opentelemetry.sdk.internal.ExtendedOpenTelemetrySdk create(io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.OpenTelemetryConfigurationModel configurationModel, io.opentelemetry.common.ComponentLoader componentLoader)
      Interpret the configurationModel to create OpenTelemetrySdk instance corresponding to the configuration.
      Parameters:
      configurationModel - the configuration model
      componentLoader - the component loader used to load ComponentProvider implementations
      Returns:
      the OpenTelemetrySdk
      Throws:
      io.opentelemetry.api.incubator.config.DeclarativeConfigException - if unable to interpret
    • parse

      public static io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.OpenTelemetryConfigurationModel parse(InputStream configuration)
      Parse the configuration YAML and return the OpenTelemetryConfigurationModel.

      During parsing, environment variable and system property substitution is performed as defined in the OpenTelemetry Configuration Data Model specification.

      Throws:
      io.opentelemetry.api.incubator.config.DeclarativeConfigException - if unable to parse
    • toConfigProperties

      public static io.opentelemetry.api.incubator.config.DeclarativeConfigProperties toConfigProperties(Object model)
      Convert the model to a generic DeclarativeConfigProperties.
      Parameters:
      model - the configuration model
      Returns:
      a generic DeclarativeConfigProperties representation of the model
    • toConfigProperties

      public static io.opentelemetry.api.incubator.config.DeclarativeConfigProperties toConfigProperties(InputStream configuration)
      Convert the configuration YAML to a generic DeclarativeConfigProperties.
      Parameters:
      configuration - configuration YAML
      Returns:
      a generic DeclarativeConfigProperties representation of the model
    • createSampler

      public static io.opentelemetry.sdk.trace.samplers.Sampler createSampler(io.opentelemetry.api.incubator.config.DeclarativeConfigProperties genericSamplerModel)
      Create a SamplerModel from the samplerModel representing the sampler config.

      This is used when samplers are composed, with one sampler accepting one or more additional samplers as config properties. The ComponentProvider implementation can call this to configure a delegate SamplerModel from the DeclarativeConfigProperties corresponding to a particular config property.