Class MetricsConfig.BuilderBase<BUILDER extends MetricsConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends MetricsConfig>

java.lang.Object
io.helidon.metrics.api.MetricsConfig.BuilderBase<BUILDER, PROTOTYPE>
Type Parameters:
BUILDER - type of the builder extending this abstract builder
PROTOTYPE - type of the prototype interface that would be built by Prototype.Builder.buildPrototype()
All Implemented Interfaces:
Prototype.Builder<BUILDER, PROTOTYPE>, ConfigBuilderSupport.ConfiguredBuilder<BUILDER, PROTOTYPE>
Direct Known Subclasses:
MetricsConfig.Builder
Enclosing interface:
MetricsConfig

public abstract static class MetricsConfig.BuilderBase<BUILDER extends MetricsConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends MetricsConfig> extends Object implements ConfigBuilderSupport.ConfiguredBuilder<BUILDER, PROTOTYPE>
Fluent API builder base for MetricsConfig.
  • Constructor Details

    • BuilderBase

      protected BuilderBase()
      Protected to support extensibility.
  • Method Details

    • from

      public BUILDER from(MetricsConfig prototype)
      Update this builder from an existing prototype instance. This method disables automatic service discovery.
      Parameters:
      prototype - existing prototype to update this builder from
      Returns:
      updated builder instance
    • from

      public BUILDER from(MetricsConfig.BuilderBase<?,?> builder)
      Update this builder from an existing prototype builder instance.
      Parameters:
      builder - existing builder prototype to update this builder from
      Returns:
      updated builder instance
    • config

      public BUILDER config(Config config)
      Update builder from configuration (node of this type). If a value is present in configuration, it would override currently configured values.
      Specified by:
      config in interface ConfigBuilderSupport.ConfiguredBuilder<BUILDER extends MetricsConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends MetricsConfig>
      Parameters:
      config - configuration instance used to obtain values to update this builder
      Returns:
      updated builder instance
    • enabled

      public BUILDER enabled(boolean enabled)
      Whether metrics functionality is enabled.
      Parameters:
      enabled - if metrics are configured to be enabled
      Returns:
      updated builder instance
      See Also:
    • permitAll

      public BUILDER permitAll(boolean permitAll)
      Whether to allow anybody to access the metrics endpoint when this config is used by a metrics observer. This setting has no effect in the top-level metrics config which controls the shared registry.
      Parameters:
      permitAll - whether to permit access to the observer's metrics endpoint to anybody, defaults to true
      Returns:
      updated builder instance
      See Also:
    • clearRoles

      public BUILDER clearRoles()
      Clear all roles.
      Returns:
      updated builder instance
      See Also:
    • roles

      public BUILDER roles(List<String> roles)
      Role names allowed to access the metrics endpoint when this config is used by a metrics observer and permitAll() is false. This setting has no effect in the top-level metrics config which controls the shared registry.
      Parameters:
      roles - allowed role names
      Returns:
      updated builder instance
      See Also:
    • addRoles

      public BUILDER addRoles(List<String> roles)
      Role names allowed to access the metrics endpoint when this config is used by a metrics observer and permitAll() is false. This setting has no effect in the top-level metrics config which controls the shared registry.
      Parameters:
      roles - allowed role names
      Returns:
      updated builder instance
      See Also:
    • keyPerformanceIndicatorMetricsConfig

      public BUILDER keyPerformanceIndicatorMetricsConfig(KeyPerformanceIndicatorMetricsConfig keyPerformanceIndicatorMetricsConfig)
      Key performance indicator metrics settings.
      Parameters:
      keyPerformanceIndicatorMetricsConfig - key performance indicator metrics settings
      Returns:
      updated builder instance
      See Also:
    • keyPerformanceIndicatorMetricsConfig

      public BUILDER keyPerformanceIndicatorMetricsConfig(Consumer<KeyPerformanceIndicatorMetricsConfig.Builder> consumer)
      Key performance indicator metrics settings.
      Parameters:
      consumer - consumer of builder of key performance indicator metrics settings
      Returns:
      updated builder instance
      See Also:
    • keyPerformanceIndicatorMetricsConfig

      public BUILDER keyPerformanceIndicatorMetricsConfig(Supplier<? extends KeyPerformanceIndicatorMetricsConfig> supplier)
      Key performance indicator metrics settings.
      Parameters:
      supplier - supplier of key performance indicator metrics settings
      Returns:
      updated builder instance
      See Also:
    • clearTags

      public BUILDER clearTags()
      Clear all tags.
      Returns:
      updated builder instance
      See Also:
    • tags

      public BUILDER tags(List<? extends Tag> tags)
      Global tags.
      Parameters:
      tags - name/value pairs for global tags
      Returns:
      updated builder instance
      See Also:
    • addTags

      public BUILDER addTags(List<? extends Tag> tags)
      Global tags.
      Parameters:
      tags - name/value pairs for global tags
      Returns:
      updated builder instance
      See Also:
    • clearAppName

      public BUILDER clearAppName()
      Clear existing value of appName.
      Returns:
      updated builder instance
      See Also:
    • appName

      public BUILDER appName(String appName)
      Value for the application tag to be added to each meter ID.
      Parameters:
      appName - application tag value
      Returns:
      updated builder instance
      See Also:
    • clearAppTagName

      public BUILDER clearAppTagName()
      Clear existing value of appTagName.
      Returns:
      updated builder instance
      See Also:
    • appTagName

      public BUILDER appTagName(String appTagName)
      Name for the application tag to be added to each meter ID.
      Parameters:
      appTagName - application tag name
      Returns:
      updated builder instance
      See Also:
    • scoping

      @Deprecated(since="27.0.0", forRemoval=true) public BUILDER scoping(ScopingConfig scoping)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Core metrics ignores these settings, and this method will be removed.
      Returns scope settings retained for compatibility; core metrics ignores them.
      Parameters:
      scoping - configured scope settings
      Returns:
      updated builder instance
      See Also:
    • scoping

      @Deprecated(since="27.0.0", forRemoval=true) public BUILDER scoping(Consumer<ScopingConfig.Builder> consumer)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Core metrics ignores these settings, and this method will be removed.
      Returns scope settings retained for compatibility; core metrics ignores them.
      Parameters:
      consumer - consumer of builder of configured scope settings
      Returns:
      updated builder instance
      See Also:
    • scoping

      @Deprecated(since="27.0.0", forRemoval=true) public BUILDER scoping(Supplier<? extends ScopingConfig> supplier)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Core metrics ignores these settings, and this method will be removed.
      Returns scope settings retained for compatibility; core metrics ignores them.
      Parameters:
      supplier - supplier of configured scope settings
      Returns:
      updated builder instance
      See Also:
    • restRequestEnabled

      public BUILDER restRequestEnabled(boolean restRequestEnabled)
      Whether automatic REST request metrics should be measured.
      Parameters:
      restRequestEnabled - true/false
      Returns:
      updated builder instance
      See Also:
    • virtualThreadsEnabled

      public BUILDER virtualThreadsEnabled(boolean virtualThreadsEnabled)
      Whether Helidon should expose meters related to virtual threads.
      Parameters:
      virtualThreadsEnabled - true to include meters related to virtual threads
      Returns:
      updated builder instance
      See Also:
    • virtualThreadsPinnedThreshold

      public BUILDER virtualThreadsPinnedThreshold(Duration virtualThreadsPinnedThreshold)
      Threshold for sampling pinned virtual threads to include in the pinned threads meter.
      Parameters:
      virtualThreadsPinnedThreshold - threshold used to filter virtual thread pinning events
      Returns:
      updated builder instance
      See Also:
    • builtInMeterNameFormat

      public BUILDER builtInMeterNameFormat(BuiltInMeterNameFormat builtInMeterNameFormat)
      Output format for built-in meter names.

      BuiltInMeterNameFormat.SNAKE selects "snake_case" which does not conform to the MicroProfile Metrics specification.

      Parameters:
      builtInMeterNameFormat - the output format for built-in meter names
      Returns:
      updated builder instance
      See Also:
    • clearJsonUnitsDefault

      public BUILDER clearJsonUnitsDefault()
      Clear existing value of jsonUnitsDefault.
      Returns:
      updated builder instance
      See Also:
    • jsonUnitsDefault

      public BUILDER jsonUnitsDefault(TimeUnit jsonUnitsDefault)
      Default units for timer output in JSON if not specified on a given timer.

      If the configuration key is absent, the Helidon JSON output uses TimeUnit.SECONDS. If the configuration key is present, Helidon formats each timer using that timer's specific units (if set) and the config value otherwise.

      Parameters:
      jsonUnitsDefault - default TimeUnit to use for JSON timer output
      Returns:
      updated builder instance
      See Also:
    • warnOnMultipleRegistries

      public BUILDER warnOnMultipleRegistries(boolean warnOnMultipleRegistries)
      Whether to log warnings when multiple registries are created.

      By far most applications use a single meter registry, but certain app or library programming errors can cause Helidon to create more than one. By default, Helidon logs warning messages for each additional meter registry created. This setting allows users with apps that need multiple meter registries to suppress those warnings.

      Parameters:
      warnOnMultipleRegistries - whether to log warnings upon creation of multiple meter registries
      Returns:
      updated builder instance
      See Also:
    • clearPublishers

      public BUILDER clearPublishers()
      Clear all publishers.
      Returns:
      updated builder instance
      See Also:
    • publishers

      public BUILDER publishers(List<? extends MetricsPublisher> publishers)
      Metrics publishers which make the metrics data available to external systems. Helidon's Micrometer-based metrics provider includes publishers with the config keys prometheus (inferred by default) and otlp. See the config reference entries for io.helidon.metrics.providers.micrometer.PrometheusPublisher and io.helidon.metrics.providers.micrometer.OtlpPublisher.
      Parameters:
      publishers - metrics publishers
      Returns:
      updated builder instance
      See Also:
    • addPublishers

      public BUILDER addPublishers(List<? extends MetricsPublisher> publishers)
      Metrics publishers which make the metrics data available to external systems. Helidon's Micrometer-based metrics provider includes publishers with the config keys prometheus (inferred by default) and otlp. See the config reference entries for io.helidon.metrics.providers.micrometer.PrometheusPublisher and io.helidon.metrics.providers.micrometer.OtlpPublisher.
      Parameters:
      publishers - metrics publishers
      Returns:
      updated builder instance
      See Also:
    • addPublisher

      public BUILDER addPublisher(MetricsPublisher publisher)
      Metrics publishers which make the metrics data available to external systems. Helidon's Micrometer-based metrics provider includes publishers with the config keys prometheus (inferred by default) and otlp. See the config reference entries for io.helidon.metrics.providers.micrometer.PrometheusPublisher and io.helidon.metrics.providers.micrometer.OtlpPublisher.
      Parameters:
      publisher - add single metrics publishers
      Returns:
      updated builder instance
      See Also:
    • publishersDiscoverServices

      public BUILDER publishersDiscoverServices(boolean publishersDiscoverServices)
      Service discovery flag for publishers(). If set to true, services will be discovered from Java service loader, or Helidon ServiceRegistry.
      Parameters:
      publishersDiscoverServices - whether to enable automatic service discovery
      Returns:
      updated builder instance
      See Also:
    • enabled

      public boolean enabled()
      Whether metrics functionality is enabled.
      Returns:
      if metrics are configured to be enabled
    • permitAll

      public boolean permitAll()
      Whether to allow anybody to access the metrics endpoint when this config is used by a metrics observer. This setting has no effect in the top-level metrics config which controls the shared registry.
      Returns:
      whether to permit access to the observer's metrics endpoint to anybody, defaults to true
      See Also:
    • roles

      public List<String> roles()
      Role names allowed to access the metrics endpoint when this config is used by a metrics observer and permitAll() is false. This setting has no effect in the top-level metrics config which controls the shared registry.
      Returns:
      allowed role names
    • keyPerformanceIndicatorMetricsConfig

      public Optional<KeyPerformanceIndicatorMetricsConfig> keyPerformanceIndicatorMetricsConfig()
      Key performance indicator metrics settings.
      Returns:
      key performance indicator metrics settings
    • tags

      public List<Tag> tags()
      Global tags.
      Returns:
      name/value pairs for global tags
    • appName

      public Optional<String> appName()
      Value for the application tag to be added to each meter ID.
      Returns:
      application tag value
    • appTagName

      public Optional<String> appTagName()
      Name for the application tag to be added to each meter ID.
      Returns:
      application tag name
    • scoping

      @Deprecated(since="27.0.0", forRemoval=true) public Optional<ScopingConfig> scoping()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Core metrics ignores these settings, and this method will be removed.
      Returns scope settings retained for compatibility; core metrics ignores them.
      Returns:
      configured scope settings
    • restRequestEnabled

      public boolean restRequestEnabled()
      Whether automatic REST request metrics should be measured.
      Returns:
      true/false
    • virtualThreadsEnabled

      public boolean virtualThreadsEnabled()
      Whether Helidon should expose meters related to virtual threads.
      Returns:
      true to include meters related to virtual threads
    • virtualThreadsPinnedThreshold

      public Duration virtualThreadsPinnedThreshold()
      Threshold for sampling pinned virtual threads to include in the pinned threads meter.
      Returns:
      threshold used to filter virtual thread pinning events
    • config

      public Optional<Config> config()
      Metrics configuration node.
      Returns:
      metrics configuration
    • builtInMeterNameFormat

      public BuiltInMeterNameFormat builtInMeterNameFormat()
      Output format for built-in meter names.

      BuiltInMeterNameFormat.SNAKE selects "snake_case" which does not conform to the MicroProfile Metrics specification.

      Returns:
      the output format for built-in meter names
    • jsonUnitsDefault

      public Optional<TimeUnit> jsonUnitsDefault()
      Default units for timer output in JSON if not specified on a given timer.

      If the configuration key is absent, the Helidon JSON output uses TimeUnit.SECONDS. If the configuration key is present, Helidon formats each timer using that timer's specific units (if set) and the config value otherwise.

      Returns:
      default TimeUnit to use for JSON timer output
    • warnOnMultipleRegistries

      public boolean warnOnMultipleRegistries()
      Whether to log warnings when multiple registries are created.

      By far most applications use a single meter registry, but certain app or library programming errors can cause Helidon to create more than one. By default, Helidon logs warning messages for each additional meter registry created. This setting allows users with apps that need multiple meter registries to suppress those warnings.

      Returns:
      whether to log warnings upon creation of multiple meter registries
    • publishers

      public List<MetricsPublisher> publishers()
      Metrics publishers which make the metrics data available to external systems. Helidon's Micrometer-based metrics provider includes publishers with the config keys prometheus (inferred by default) and otlp. See the config reference entries for io.helidon.metrics.providers.micrometer.PrometheusPublisher and io.helidon.metrics.providers.micrometer.OtlpPublisher.
      Returns:
      metrics publishers
    • publishersDiscoverServices

      public boolean publishersDiscoverServices()
      Service discovery flag for publishers(). If set to true, services will be discovered from Java service loader, or Helidon ServiceRegistry.
      Returns:
      whether to enable automatic service discovery
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • preBuildPrototype

      protected void preBuildPrototype()
      Handles providers and decorators.
    • validatePrototype

      protected void validatePrototype()
      Validates required properties.