Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
Comparing source compatibility of opentelemetry-exporter-otlp-1.69.0-SNAPSHOT.jar against opentelemetry-exporter-otlp-1.68.0.jar
No changes.
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporterBuilder (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporterBuilder setProxy(io.opentelemetry.sdk.common.export.ProxyOptions)
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporterBuilder (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporterBuilder setProxy(io.opentelemetry.sdk.common.export.ProxyOptions)
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder setProxy(io.opentelemetry.sdk.common.export.ProxyOptions)
13 changes: 12 additions & 1 deletion docs/apidiffs/current_vs_latest/opentelemetry-sdk-common.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
Comparing source compatibility of opentelemetry-sdk-common-1.69.0-SNAPSHOT.jar against opentelemetry-sdk-common-1.68.0.jar
No changes.
*** MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.sdk.common.export.GrpcSenderConfig (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.common.export.ProxyOptions getProxyOptions()
+++ NEW ANNOTATION: javax.annotation.Nullable
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.common.export.ProxyOptions (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.common.export.ProxyOptions create(java.net.InetSocketAddress, java.lang.String, java.lang.String)
+++ NEW METHOD: PUBLIC(+) java.lang.String getPassword()
+++ NEW ANNOTATION: javax.annotation.Nullable
+++ NEW METHOD: PUBLIC(+) java.lang.String getUsername()
+++ NEW ANNOTATION: javax.annotation.Nullable
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.common.export.ProxyOptions noProxy()
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public void setUp() {
null,
null,
Long.MAX_VALUE,
null,
null),
InternalTelemetryVersion.LATEST,
ComponentId.generateLazy(StandardComponentId.ExporterType.OTLP_GRPC_SPAN_EXPORTER),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.opentelemetry.sdk.common.export.Compressor;
import io.opentelemetry.sdk.common.export.GrpcSender;
import io.opentelemetry.sdk.common.export.GrpcSenderProvider;
import io.opentelemetry.sdk.common.export.ProxyOptions;
import io.opentelemetry.sdk.common.export.RetryPolicy;
import io.opentelemetry.sdk.common.internal.ComponentId;
import io.opentelemetry.sdk.common.internal.StandardComponentId;
Expand Down Expand Up @@ -71,6 +72,7 @@ public class GrpcExporterBuilder {
@Nullable private ExecutorService executorService;
private long maxRequestMessageSize = DEFAULT_MAX_REQUEST_MESSAGE_SIZE;
@Nullable private List<String> enabledProtocols;
@Nullable private ProxyOptions proxyOptions;

// Use Object type since gRPC may not be on the classpath.
@Nullable private Object grpcChannel;
Expand Down Expand Up @@ -184,6 +186,11 @@ public GrpcExporterBuilder setEnabledProtocols(@Nullable List<String> enabledPro
return this;
}

public GrpcExporterBuilder setProxyOptions(ProxyOptions proxyOptions) {
this.proxyOptions = proxyOptions;
return this;
}

@SuppressWarnings("BuilderReturnThis")
public GrpcExporterBuilder copy() {
GrpcExporterBuilder copy =
Expand All @@ -205,6 +212,7 @@ public GrpcExporterBuilder copy() {
copy.componentLoader = componentLoader;
copy.maxRequestMessageSize = maxRequestMessageSize;
copy.enabledProtocols = enabledProtocols;
copy.proxyOptions = proxyOptions;
return copy;
}

Expand Down Expand Up @@ -248,7 +256,8 @@ public GrpcExporter build() {
// 4mb to align with spec guidance - even though we don't do anything with the
// response today, we will so better to have future-looking memory profile
4 * 1024L * 1024L,
enabledProtocols));
enabledProtocols,
proxyOptions));
LOGGER.log(Level.FINE, "Using GrpcSender: " + grpcSender.getClass().getName());

return new GrpcExporter(
Expand Down Expand Up @@ -285,6 +294,9 @@ public String toString(boolean includePrefixAndSuffix) {
if (enabledProtocols != null) {
joiner.add("enabledProtocols=" + enabledProtocols);
}
if (proxyOptions != null) {
joiner.add("proxyOptions=" + proxyOptions);
}
if (grpcChannel != null) {
joiner.add("grpcChannel=" + grpcChannel);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.google.auto.value.AutoValue;
import io.opentelemetry.exporter.internal.grpc.ExtendedGrpcSenderConfig;
import io.opentelemetry.sdk.common.export.Compressor;
import io.opentelemetry.sdk.common.export.ProxyOptions;
import io.opentelemetry.sdk.common.export.RetryPolicy;
import java.net.URI;
import java.time.Duration;
Expand Down Expand Up @@ -40,7 +41,8 @@ public static ImmutableGrpcSenderConfig create(
@Nullable ExecutorService executorService,
@Nullable Object managedChannel,
long maxResponseBodySize,
@Nullable List<String> enabledProtocols) {
@Nullable List<String> enabledProtocols,
@Nullable ProxyOptions proxyOptions) {
return new AutoValue_ImmutableGrpcSenderConfig(
endpoint,
fullMethodName,
Expand All @@ -54,7 +56,8 @@ public static ImmutableGrpcSenderConfig create(
executorService,
managedChannel,
maxResponseBodySize,
enabledProtocols);
enabledProtocols,
proxyOptions);
}

@Override
Expand All @@ -63,4 +66,8 @@ public static ImmutableGrpcSenderConfig create(
@Override
@Nullable
public abstract List<String> getEnabledProtocols();

@Override
@Nullable
public abstract ProxyOptions getProxyOptions();
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
import io.opentelemetry.sdk.autoconfigure.spi.internal.ExtendedDeclarativeConfigProperties;
import io.opentelemetry.sdk.common.InternalTelemetryVersion;
import io.opentelemetry.sdk.common.export.MemoryMode;
import io.opentelemetry.sdk.common.export.ProxyOptions;
import io.opentelemetry.sdk.common.export.RetryPolicy;
import java.net.InetSocketAddress;
import java.net.ProxySelector;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.time.Duration;
import java.util.Collections;
Expand Down Expand Up @@ -64,6 +69,7 @@ public static void configureOtlpExporterBuilder(
Consumer<RetryPolicy> setRetryPolicy,
Consumer<MemoryMode> setMemoryMode,
Consumer<Long> setMaxRequestSize,
Consumer<ProxyOptions> setProxy,
boolean isHttpProtobuf,
Consumer<InternalTelemetryVersion> internalTelemetryVersionConsumer,
Runnable setNoopMeterProvider) {
Expand Down Expand Up @@ -113,6 +119,8 @@ public static void configureOtlpExporterBuilder(
setMaxRequestSize.accept(maxRequestSize.longValue());
}

setProxy.accept(toProxyOptions(config.getStructured("proxy/development")));

DeclarativeConfigProperties tls =
config.getStructured("tls", DeclarativeConfigProperties.empty());
String certificatePath = tls.getString("ca_file");
Expand Down Expand Up @@ -149,6 +157,71 @@ public static void configureOtlpExporterBuilder(
}
}

/**
* Converts the {@code proxy/development} config to {@link ProxyOptions}. When absent, returns
* options which never use a proxy, so that ambient JVM proxy settings (e.g. {@code
* https.proxyHost} system properties or {@link ProxySelector#getDefault()}) don't apply, per the
* declarative configuration "what you see is what you get" principle.
*/
// Visible for testing
static ProxyOptions toProxyOptions(@Nullable DeclarativeConfigProperties proxy) {
if (proxy == null) {
return ProxyOptions.noProxy();
}

String url = proxy.getString("url");
if (url == null) {
throw new DeclarativeConfigException("proxy/development.url is required");
}

URI uri = getUri(url);
String host = uri.getHost();
if (host == null) {
throw new DeclarativeConfigException("proxy/development.url must include a host");
}

int port = uri.getPort() == -1 ? 80 : uri.getPort();
InetSocketAddress address = InetSocketAddress.createUnresolved(host, port);

String username = proxy.getString("username");
String password = proxy.getString("password");
if (username == null && password == null) {
return ProxyOptions.create(address);
}

if (username == null || password == null) {
throw new DeclarativeConfigException(
"proxy/development.username and proxy/development.password must be set together");
}

return ProxyOptions.create(address, username, password);
}

private static URI getUri(String url) {
URI uri;
try {
uri = new URI(url);
} catch (URISyntaxException e) {
throw new DeclarativeConfigException("Invalid proxy/development.url", e);
}

String scheme = uri.getScheme();
if ("https".equals(scheme)) {
throw new DeclarativeConfigException(
"proxy/development.url with https scheme is not supported.");
}

if (!"http".equals(scheme)) {
throw new DeclarativeConfigException("proxy/development.url scheme must be http or https");
}

if (uri.getRawUserInfo() != null) {
throw new DeclarativeConfigException(
"proxy/development.url must not include userinfo; set username and password instead");
}
return uri;
}

@Nullable
private static InternalTelemetryVersion getInternalTelemetryVersion(
ConfigProvider configProvider) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public LogRecordExporter create(DeclarativeConfigProperties config) {
builder::setRetryPolicy,
builder::setMemoryMode,
builder::setMaxRequestMessageSize,
builder::setProxy,
/* isHttpProtobuf= */ false,
builder::setInternalTelemetryVersion,
() -> builder.setMeterProvider(MeterProvider::noop));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public MetricExporter create(DeclarativeConfigProperties config) {
builder::setRetryPolicy,
builder::setMemoryMode,
builder::setMaxRequestMessageSize,
builder::setProxy,
/* isHttpProtobuf= */ false,
builder::setInternalTelemetryVersion,
() -> builder.setMeterProvider(MeterProvider::noop));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public SpanExporter create(DeclarativeConfigProperties config) {
builder::setRetryPolicy,
builder::setMemoryMode,
builder::setMaxRequestMessageSize,
builder::setProxy,
/* isHttpProtobuf= */ false,
builder::setInternalTelemetryVersion,
() -> builder.setMeterProvider(MeterProvider::noop));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public LogRecordExporter create(DeclarativeConfigProperties config) {
builder::setRetryPolicy,
builder::setMemoryMode,
builder::setMaxRequestBodySize,
builder::setProxyOptions,
/* isHttpProtobuf= */ true,
builder::setInternalTelemetryVersion,
() -> builder.setMeterProvider(MeterProvider::noop));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public MetricExporter create(DeclarativeConfigProperties config) {
builder::setRetryPolicy,
builder::setMemoryMode,
builder::setMaxRequestBodySize,
builder::setProxyOptions,
/* isHttpProtobuf= */ true,
builder::setInternalTelemetryVersion,
() -> builder.setMeterProvider(MeterProvider::noop));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public SpanExporter create(DeclarativeConfigProperties config) {
builder::setRetryPolicy,
builder::setMemoryMode,
builder::setMaxRequestBodySize,
builder::setProxy,
/* isHttpProtobuf= */ true,
builder::setInternalTelemetryVersion,
() -> builder.setMeterProvider(MeterProvider::noop));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.opentelemetry.sdk.common.InternalTelemetryVersion;
import io.opentelemetry.sdk.common.export.Compressor;
import io.opentelemetry.sdk.common.export.MemoryMode;
import io.opentelemetry.sdk.common.export.ProxyOptions;
import io.opentelemetry.sdk.common.export.RetryPolicy;
import io.opentelemetry.sdk.common.internal.StandardComponentId;
import java.net.URI;
Expand Down Expand Up @@ -333,6 +334,21 @@ public OtlpGrpcLogRecordExporterBuilder setEnabledProtocols(List<String> enabled
return this;
}

/**
* Sets the proxy options. If unset, the sender implementation's default proxy behavior is used.
*
* <p>The exporter tunnels through the proxy using HTTP {@code CONNECT}, for both {@code https}
* and plaintext {@code http} endpoints. Proxy options are ignored by the {@code
* ManagedChannel}-based sender.
*
* @since 1.69.0
*/
public OtlpGrpcLogRecordExporterBuilder setProxy(ProxyOptions proxyOptions) {
requireNonNull(proxyOptions, "proxyOptions");
delegate.setProxyOptions(proxyOptions);
return this;
}

/**
* Constructs a new instance of the exporter based on the builder's values.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.opentelemetry.sdk.common.InternalTelemetryVersion;
import io.opentelemetry.sdk.common.export.Compressor;
import io.opentelemetry.sdk.common.export.MemoryMode;
import io.opentelemetry.sdk.common.export.ProxyOptions;
import io.opentelemetry.sdk.common.export.RetryPolicy;
import io.opentelemetry.sdk.common.internal.StandardComponentId;
import io.opentelemetry.sdk.metrics.InstrumentType;
Expand Down Expand Up @@ -390,6 +391,21 @@ public OtlpGrpcMetricExporterBuilder setEnabledProtocols(List<String> enabledPro
return this;
}

/**
* Sets the proxy options. If unset, the sender implementation's default proxy behavior is used.
*
* <p>The exporter tunnels through the proxy using HTTP {@code CONNECT}, for both {@code https}
* and plaintext {@code http} endpoints. Proxy options are ignored by the {@code
* ManagedChannel}-based sender.
*
* @since 1.69.0
*/
public OtlpGrpcMetricExporterBuilder setProxy(ProxyOptions proxyOptions) {
requireNonNull(proxyOptions, "proxyOptions");
delegate.setProxyOptions(proxyOptions);
return this;
}

/**
* Constructs a new instance of the exporter based on the builder's values.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.opentelemetry.sdk.common.InternalTelemetryVersion;
import io.opentelemetry.sdk.common.export.Compressor;
import io.opentelemetry.sdk.common.export.MemoryMode;
import io.opentelemetry.sdk.common.export.ProxyOptions;
import io.opentelemetry.sdk.common.export.RetryPolicy;
import io.opentelemetry.sdk.common.internal.StandardComponentId;
import java.net.URI;
Expand Down Expand Up @@ -330,6 +331,21 @@ public OtlpGrpcSpanExporterBuilder setEnabledProtocols(List<String> enabledProto
return this;
}

/**
* Sets the proxy options. If unset, the sender implementation's default proxy behavior is used.
*
* <p>The exporter tunnels through the proxy using HTTP {@code CONNECT}, for both {@code https}
* and plaintext {@code http} endpoints. Proxy options are ignored by the {@code
* ManagedChannel}-based sender.
*
* @since 1.69.0
*/
public OtlpGrpcSpanExporterBuilder setProxy(ProxyOptions proxyOptions) {
requireNonNull(proxyOptions, "proxyOptions");
delegate.setProxyOptions(proxyOptions);
return this;
}

/**
* Constructs a new instance of the exporter based on the builder's values.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.opentelemetry.exporter.otlp.internal.GrpcExporterBuilder;
import io.opentelemetry.exporter.otlp.internal.OtlpUserAgent;
import io.opentelemetry.sdk.common.export.Compressor;
import io.opentelemetry.sdk.common.export.ProxyOptions;
import io.opentelemetry.sdk.common.export.RetryPolicy;
import io.opentelemetry.sdk.common.internal.StandardComponentId;
import java.net.URI;
Expand Down Expand Up @@ -254,6 +255,19 @@ public OtlpGrpcProfilesExporterBuilder setEnabledProtocols(List<String> enabledP
return this;
}

/**
* Sets the proxy options. If unset, the sender implementation's default proxy behavior is used.
*
* <p>The exporter tunnels through the proxy using HTTP {@code CONNECT}, for both {@code https}
* and plaintext {@code http} endpoints. Proxy options are ignored by the {@code
* ManagedChannel}-based sender.
*/
public OtlpGrpcProfilesExporterBuilder setProxy(ProxyOptions proxyOptions) {
requireNonNull(proxyOptions, "proxyOptions");
delegate.setProxyOptions(proxyOptions);
return this;
}

/**
* Constructs a new instance of the exporter based on the builder's values.
*
Expand Down
Loading
Loading