public OpenAIClient build()

in instrumentation/openai-client-instrumentation/instrumentation-1.1/src/main/java/co/elastic/otel/openai/v1_1/wrappers/InstrumentedOpenAiClient.java [76:103]


    public OpenAIClient build() {
      if (delegate instanceof InstrumentedOpenAiClient) {
        return delegate;
      }
      String hostname = null;
      Long port = null;
      if (baseUrl != null) {
        try {
          URI parsed = new URI(baseUrl);
          hostname = parsed.getHost();
          int urlPort = parsed.getPort();
          if (urlPort != -1) {
            port = (long) urlPort;
          } else {
            long defaultPort = parsed.toURL().getDefaultPort();
            if (defaultPort != -1) {
              port = defaultPort;
            }
          }
        } catch (Exception e) {
          // ignore malformed
        }
      }
      return new InstrumentedOpenAiClient(
              delegate,
              new InstrumentationSettings(emitEvents, captureMessageContent, hostname, port))
          .createProxy();
    }