org.apache.rocketmq.shaded.io.opentelemetry.exporter.internal.ExporterBuilderUtil Maven / Gradle / Ivy
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package org.apache.rocketmq.shaded.io.opentelemetry.exporter.internal;
import java.net.URI;
import java.net.URISyntaxException;
/**
* Utilities for exporter builders.
*
* This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public final class ExporterBuilderUtil {
/** Validate OTLP endpoint. */
public static URI validateEndpoint(String endpoint) {
URI uri;
try {
uri = new URI(endpoint);
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Invalid endpoint, must be a URL: " + endpoint, e);
}
if (uri.getScheme() == null
|| (!uri.getScheme().equals("http") && !uri.getScheme().equals("https"))) {
throw new IllegalArgumentException(
"Invalid endpoint, must start with http:// or https://: " + uri);
}
return uri;
}
private ExporterBuilderUtil() {}
}