Class HttpClientFactory

java.lang.Object
io.confluent.telemetry.exporter.http.HttpClientFactory

public class HttpClientFactory extends Object
  • Constructor Details

    • HttpClientFactory

      public HttpClientFactory()
  • Method Details

    • getInstance

      public static HttpClientFactory getInstance()
    • get

      public io.confluent.telemetry.client.BufferingAsyncClient<ExportableMetric, io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceResponse> get(HttpExporterConfigWrapper configWrapper)
      Retrieves or creates a BufferingAsyncClient instance based on the provided configuration wrapper.

      If the HttpExporterConfigWrapper contains a non-null HttpClientConfig, this method attempts to reuse an existing CloseableReferenceTracker for the client name specified in the HttpClientConfig. If no tracker exists, or if the existing tracker's configuration has changed and the tracker is marked for replacement, a new tracker is created and stored, replacing the old one to allow GC to collect it.

      The returned BufferingAsyncClient is a proxy that tracks references, ensuring that the underlying static client is closed only when all references (leases) are released.

      If the HttpExporterConfigWrapper does not contain a HttpClientConfig (i.e., it's null), a new, non-static BufferingAsyncClient is created directly by calling HttpExporterConfigWrapper.createBufferingClient().

      Parameters:
      configWrapper - The wrapper containing configuration for the HTTP exporter and its client.
      Returns:
      A BufferingAsyncClient instance, potentially wrapped in a ReferenceTrackingProxy.