Class DeclarativeConfigDurationUtil

java.lang.Object
io.opentelemetry.instrumentation.config.bridge.DeclarativeConfigDurationUtil

public final class DeclarativeConfigDurationUtil extends Object
Helpers for reading duration values from DeclarativeConfigProperties.

When the config is backed by flat ConfigProperties, duration strings such as 42ms are supported by delegating to the SDK's standard duration parser.

For other declarative-config implementations, this utility expects duration values to already be normalized to integer milliseconds, which means string durations in declarative YAML are not accepted.

  • Method Details

    • getDuration

      @Nullable public static Duration getDuration(io.opentelemetry.api.incubator.config.DeclarativeConfigProperties properties, String key)
      Reads a duration from declarative config.

      String duration values are only supported when properties is a ConfigPropertiesBackedDeclarativeConfigProperties. Other implementations must provide integer milliseconds for the same key.