Repository: open-telemetry/opentelemetry-java
File: exporters/prometheus/src/main/java/io/opentelemetry/exporter/prometheus/PrometheusHttpServerBuilder.java (Java)

Code before:
    metricReaderBuilder.setOtelScopeLabelsEnabled(otelScopeLabelsEnabled);
    return this;
  }

  /** Set if the {@code otel_target_info} metric is generated. Default is {@code true}. */
  @CanIgnoreReturnValue
  public PrometheusHttpServerBuilder setTargetInfoMetricEnabled(boolean targetInfoMetricEnabled) {
    metricReaderBuilder.setTargetInfoMetricEnabled(targetInfoMetricEnabled);
    return this;
  }

  /**
   * Set if the resource attributes should be added as labels on each exported metric.
   *
   * <p>If set, resource attributes will be added as labels on each exported metric if their key
   * tests positive (true) when passed through {@code resourceAttributesFilter}.
   *
   * @param resourceAttributesFilter a predicate that returns true if the resource attribute should
   *     be added as a label on each exported metric. The predicates input is the resource attribute
   *     key.
   */
  @CanIgnoreReturnValue
  public PrometheusHttpServerBuilder setAllowedResourceAttributesFilter(
      Predicate<String> resourceAttributesFilter) {
    metricReaderBuilder.setAllowedResourceAttributesFilter(
        requireNonNull(resourceAttributesFilter, "resourceAttributesFilter"));
    return this;
  }

  /**
   * Set the {@link MemoryMode}.
   *
   * <p>If set to {@link MemoryMode#REUSABLE_DATA}, requests are served sequentially which is
   * accomplished by overriding {@link #setExecutor(ExecutorService)} to {@link
   * Executors#newSingleThreadExecutor()}.
   */
  @CanIgnoreReturnValue
  public PrometheusHttpServerBuilder setMemoryMode(MemoryMode memoryMode) {
    requireNonNull(memoryMode, "memoryMode");
    this.memoryMode = memoryMode;
    return this;
  }

  /**
   * Override the default handler for serving the "/", "/**" endpoint.
   *
   * <p>This can be used to serve metrics on additional paths besides the default "/metrics". For
   * example: <code>
   *   PrometheusHttpServer.builder()
   *     .setPrometheusRegistry(prometheusRegistry)
   *     .setDefaultHandler(new MetricsHandler(prometheusRegistry))

Review comment (suggestion):
#nit: I prefer to break out the `requireNonNull` statement onto a separate line above the call to `setAllowedResourceAttributesFilter`. Its more consistent with the style used elsewhere and I think yields slightly improved stack traces.

Code after:
    metricReaderBuilder.setTargetInfoMetricEnabled(targetInfoMetricEnabled);
    return this;
  }

  /**
   * Set if the resource attributes should be added as labels on each exported metric.
   *
   * <p>If set, resource attributes will be added as labels on each exported metric if their key
   * tests positive (true) when passed through {@code resourceAttributesFilter}.
   *
   * @param resourceAttributesFilter a predicate that returns true if the resource attribute should
   *     be added as a label on each exported metric. The predicates input is the resource attribute
   *     key.
   */
  public PrometheusHttpServerBuilder setAllowedResourceAttributesFilter(
      Predicate<String> resourceAttributesFilter) {
    requireNonNull(resourceAttributesFilter, "resourceAttributesFilter");
    metricReaderBuilder.setAllowedResourceAttributesFilter(resourceAttributesFilter);
    return this;
  }

  /**
   * Set the {@link MemoryMode}.
   *
   * <p>If set to {@link MemoryMode#REUSABLE_DATA}, requests are served sequentially which is
   * accomplished by overriding {@link #setExecutor(ExecutorService)} to {@link
   * Executors#newSingleThreadExecutor()}.
   */
  public PrometheusHttpServerBuilder setMemoryMode(MemoryMode memoryMode) {
    requireNonNull(memoryMode, "memoryMode");
    this.memoryMode = memoryMode;
    return this;
  }

  /**
   * Override the default handler for serving the "/", "/**" endpoint.
   *
   * <p>This can be used to serve metrics on additional paths besides the default "/metrics". For
   * example: <code>
   *   PrometheusHttpServer.builder()
   *     .setPrometheusRegistry(prometheusRegistry)
   *     .setDefaultHandler(new MetricsHandler(prometheusRegistry))
   *     .build()
   * </code>
   */
  public PrometheusHttpServerBuilder setDefaultHandler(HttpHandler defaultHandler) {
    requireNonNull(defaultHandler, "defaultHandler");
    this.defaultHandler = defaultHandler;
    return this;
  }