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,25 @@
Comparing source compatibility of opentelemetry-exporter-otlp-1.57.0-SNAPSHOT.jar against opentelemetry-exporter-otlp-1.56.0.jar
No changes.
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporterBuilder (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporterBuilder setLogThrottlingRate(double, double)
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporterBuilder setLogThrottlingTimeUnit(java.util.concurrent.TimeUnit)
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporterBuilder (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporterBuilder setLogThrottlingRate(double, double)
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporterBuilder setLogThrottlingTimeUnit(java.util.concurrent.TimeUnit)
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder setLogThrottlingRate(double, double)
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder setLogThrottlingTimeUnit(java.util.concurrent.TimeUnit)
*** 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 setLogThrottlingRate(double, double)
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporterBuilder setLogThrottlingTimeUnit(java.util.concurrent.TimeUnit)
*** 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 setLogThrottlingRate(double, double)
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporterBuilder setLogThrottlingTimeUnit(java.util.concurrent.TimeUnit)
*** 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 setLogThrottlingRate(double, double)
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder setLogThrottlingTimeUnit(java.util.concurrent.TimeUnit)
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.opentelemetry.sdk.common.InternalTelemetryVersion;
import io.opentelemetry.sdk.internal.StandardComponentId;
import io.opentelemetry.sdk.internal.ThrottlingLogger;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
import java.util.logging.Level;
Expand All @@ -32,7 +33,7 @@ public final class GrpcExporter<T extends Marshaler> {

private static final Logger internalLogger = Logger.getLogger(GrpcExporter.class.getName());

private final ThrottlingLogger logger = new ThrottlingLogger(internalLogger);
private final ThrottlingLogger logger;

// We only log unimplemented once since it's a configuration issue that won't be recovered.
private final AtomicBoolean loggedUnimplemented = new AtomicBoolean();
Expand All @@ -53,6 +54,24 @@ public GrpcExporter(
this.exporterMetrics =
new ExporterInstrumentation(
internalTelemetryVersion, meterProviderSupplier, componentId, endpoint);
this.logger = new ThrottlingLogger(internalLogger);
}

public GrpcExporter(
GrpcSender<T> grpcSender,
InternalTelemetryVersion internalTelemetryVersion,
StandardComponentId componentId,
Supplier<MeterProvider> meterProviderSupplier,
String endpoint,
double rateLimit,
double throttledRateLimit,
TimeUnit rateTimeUnit) {
this.type = componentId.getStandardType().signal().logFriendlyName();
this.grpcSender = grpcSender;
this.exporterMetrics =
new ExporterInstrumentation(
internalTelemetryVersion, meterProviderSupplier, componentId, endpoint);
this.logger = new ThrottlingLogger(internalLogger, rateLimit, throttledRateLimit, rateTimeUnit);
}

public CompletableResultCode export(T exportRequest, int numItems) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ public class GrpcExporterBuilder<T extends Marshaler> {
// Use Object type since gRPC may not be on the classpath.
@Nullable private Object grpcChannel;

private double throttlingLoggerRateLimit = 5;
private double throttlingLoggerThrottledRateLimit = 1;
private TimeUnit throttlingLoggerTimeUnit = TimeUnit.MINUTES;

public GrpcExporterBuilder(
StandardComponentId.ExporterType exporterType,
long defaultTimeoutSecs,
Expand Down Expand Up @@ -182,6 +186,17 @@ public GrpcExporterBuilder<T> setExecutorService(ExecutorService executorService
return this;
}

public GrpcExporterBuilder<T> setLogThrottlingRate(double rateLimit, double throttledRateLimit) {
this.throttlingLoggerRateLimit = rateLimit;
this.throttlingLoggerThrottledRateLimit = throttledRateLimit;
return this;
}

public GrpcExporterBuilder<T> setLogThrottlingTimeUnit(TimeUnit rateTimeUnit) {
this.throttlingLoggerTimeUnit = rateTimeUnit;
return this;
}

@SuppressWarnings("BuilderReturnThis")
public GrpcExporterBuilder<T> copy() {
GrpcExporterBuilder<T> copy =
Expand All @@ -206,6 +221,9 @@ public GrpcExporterBuilder<T> copy() {
copy.internalTelemetryVersion = internalTelemetryVersion;
copy.grpcChannel = grpcChannel;
copy.componentLoader = componentLoader;
copy.throttlingLoggerRateLimit = throttlingLoggerRateLimit;
copy.throttlingLoggerThrottledRateLimit = throttlingLoggerThrottledRateLimit;
copy.throttlingLoggerTimeUnit = throttlingLoggerTimeUnit;
return copy;
}

Expand Down Expand Up @@ -255,7 +273,10 @@ public GrpcExporter<T> build() {
internalTelemetryVersion,
ComponentId.generateLazy(exporterType),
meterProviderSupplier,
endpoint.toString());
endpoint.toString(),
throttlingLoggerRateLimit,
throttlingLoggerThrottledRateLimit,
throttlingLoggerTimeUnit);
}

public String toString(boolean includePrefixAndSuffix) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.opentelemetry.sdk.internal.StandardComponentId;
import io.opentelemetry.sdk.internal.ThrottlingLogger;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
import java.util.logging.Level;
Expand All @@ -32,7 +33,7 @@ public final class HttpExporter<T extends Marshaler> {

private static final Logger internalLogger = Logger.getLogger(HttpExporter.class.getName());

private final ThrottlingLogger logger = new ThrottlingLogger(internalLogger);
private final ThrottlingLogger logger;
private final AtomicBoolean isShutdown = new AtomicBoolean();

private final String type;
Expand All @@ -50,6 +51,24 @@ public HttpExporter(
this.exporterMetrics =
new ExporterInstrumentation(
internalTelemetryVersion, meterProviderSupplier, componentId, endpoint);
this.logger = new ThrottlingLogger(internalLogger);
}

public HttpExporter(
StandardComponentId componentId,
HttpSender httpSender,
Supplier<MeterProvider> meterProviderSupplier,
InternalTelemetryVersion internalTelemetryVersion,
String endpoint,
double rateLimit,
double throttledRateLimit,
TimeUnit rateTimeUnit) {
this.type = componentId.getStandardType().signal().logFriendlyName();
this.httpSender = httpSender;
this.exporterMetrics =
new ExporterInstrumentation(
internalTelemetryVersion, meterProviderSupplier, componentId, endpoint);
this.logger = new ThrottlingLogger(internalLogger, rateLimit, throttledRateLimit, rateTimeUnit);
}

public CompletableResultCode export(T exportRequest, int numItems) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public final class HttpExporterBuilder<T extends Marshaler> {
ComponentLoader.forClassLoader(HttpExporterBuilder.class.getClassLoader());
@Nullable private ExecutorService executorService;

private double throttlingLoggerRateLimit = 5;
private double throttlingLoggerThrottledRateLimit = 1;
private TimeUnit throttlingLoggerTimeUnit = TimeUnit.MINUTES;

public HttpExporterBuilder(
StandardComponentId.ExporterType exporterType, String defaultEndpoint) {
this.exporterType = exporterType;
Expand Down Expand Up @@ -167,6 +171,17 @@ public HttpExporterBuilder<T> setExecutorService(ExecutorService executorService
return this;
}

public HttpExporterBuilder<T> setLogThrottlingRate(double rateLimit, double throttledRateLimit) {
this.throttlingLoggerRateLimit = rateLimit;
this.throttlingLoggerThrottledRateLimit = throttledRateLimit;
return this;
}

public HttpExporterBuilder<T> setLogThrottlingTimeUnit(TimeUnit rateTimeUnit) {
this.throttlingLoggerTimeUnit = rateTimeUnit;
return this;
}

public HttpExporterBuilder<T> exportAsJson() {
this.exportAsJson = true;
exporterType = mapToJsonTypeIfPossible(exporterType);
Expand Down Expand Up @@ -205,6 +220,9 @@ public HttpExporterBuilder<T> copy() {
copy.internalTelemetryVersion = internalTelemetryVersion;
copy.proxyOptions = proxyOptions;
copy.componentLoader = componentLoader;
copy.throttlingLoggerRateLimit = throttlingLoggerRateLimit;
copy.throttlingLoggerThrottledRateLimit = throttlingLoggerThrottledRateLimit;
copy.throttlingLoggerTimeUnit = throttlingLoggerTimeUnit;
return copy;
}

Expand Down Expand Up @@ -254,7 +272,10 @@ public HttpExporter<T> build() {
httpSender,
meterProviderSupplier,
internalTelemetryVersion,
endpoint);
endpoint,
throttlingLoggerRateLimit,
throttlingLoggerThrottledRateLimit,
throttlingLoggerTimeUnit);
}

public String toString(boolean includePrefixAndSuffix) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,20 @@ public OtlpHttpLogRecordExporterBuilder setExecutorService(ExecutorService execu
return this;
}

public OtlpHttpLogRecordExporterBuilder setLogThrottlingRate(
double rateLimit, double throttledRateLimit) {
checkArgument(rateLimit > 0, "rateLimit invalid");
checkArgument(throttledRateLimit > 0, "throttledRateLimit invalid");
delegate.setLogThrottlingRate(rateLimit, throttledRateLimit);
return this;
}

public OtlpHttpLogRecordExporterBuilder setLogThrottlingTimeUnit(TimeUnit timeUnit) {
requireNonNull(timeUnit, "logTimeUnit");
delegate.setLogThrottlingTimeUnit(timeUnit);
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 @@ -334,6 +334,20 @@ public OtlpHttpMetricExporterBuilder setExecutorService(ExecutorService executor
return this;
}

public OtlpHttpMetricExporterBuilder setLogThrottlingRate(
double rateLimit, double throttledRateLimit) {
checkArgument(rateLimit > 0, "rateLimit invalid");
checkArgument(throttledRateLimit > 0, "throttledRateLimit invalid");
delegate.setLogThrottlingRate(rateLimit, throttledRateLimit);
return this;
}

public OtlpHttpMetricExporterBuilder setLogThrottlingTimeUnit(TimeUnit timeUnit) {
requireNonNull(timeUnit, "logTimeUnit");
delegate.setLogThrottlingTimeUnit(timeUnit);
return this;
}

OtlpHttpMetricExporterBuilder exportAsJson() {
delegate.exportAsJson();
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,20 @@ public OtlpHttpSpanExporterBuilder setExecutorService(ExecutorService executorSe
return this;
}

public OtlpHttpSpanExporterBuilder setLogThrottlingRate(
double rateLimit, double throttledRateLimit) {
checkArgument(rateLimit > 0, "rateLimit invalid");
checkArgument(throttledRateLimit > 0, "throttledRateLimit invalid");
delegate.setLogThrottlingRate(rateLimit, throttledRateLimit);
return this;
}

public OtlpHttpSpanExporterBuilder setLogThrottlingTimeUnit(TimeUnit timeUnit) {
requireNonNull(timeUnit, "logTimeUnit");
delegate.setLogThrottlingTimeUnit(timeUnit);
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 @@ -22,6 +22,8 @@
import java.time.Duration;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

Expand Down Expand Up @@ -57,6 +59,8 @@ public static void configureOtlpExporterBuilder(
BiConsumer<byte[], byte[]> setClientTls,
Consumer<RetryPolicy> setRetryPolicy,
Consumer<MemoryMode> setMemoryMode,
BiConsumer<Double, Double> setLogThrottlingRate,
Consumer<TimeUnit> setLogTimeUnit,
boolean isHttpProtobuf) {
setComponentLoader.accept(config.getComponentLoader());

Expand Down Expand Up @@ -117,6 +121,20 @@ public static void configureOtlpExporterBuilder(
}

IncubatingExporterBuilderUtil.configureExporterMemoryMode(config, setMemoryMode);

Double throttlingLoggerRateLimit = config.getDouble("log_rate");
Double throttlingLoggerThrottledRateLimit = config.getDouble("throttled_log_rate");

if (throttlingLoggerRateLimit != null && throttlingLoggerThrottledRateLimit != null) {
setLogThrottlingRate.accept(throttlingLoggerRateLimit, throttlingLoggerThrottledRateLimit);
}

String throttlingLoggerTimeUnitStr = config.getString("log_rate_unit");
if (throttlingLoggerTimeUnitStr != null) {
TimeUnit throttlingLoggerTimeUnit =
TimeUnit.valueOf(throttlingLoggerTimeUnitStr.toUpperCase(Locale.ROOT));
setLogTimeUnit.accept(throttlingLoggerTimeUnit);
}
}

private OtlpDeclarativeConfigUtil() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public LogRecordExporter create(DeclarativeConfigProperties config) {
builder::setClientTls,
builder::setRetryPolicy,
builder::setMemoryMode,
builder::setLogThrottlingRate,
builder::setLogThrottlingTimeUnit,
/* isHttpProtobuf= */ false);

return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public MetricExporter create(DeclarativeConfigProperties config) {
builder::setClientTls,
builder::setRetryPolicy,
builder::setMemoryMode,
builder::setLogThrottlingRate,
builder::setLogThrottlingTimeUnit,
/* isHttpProtobuf= */ false);
IncubatingExporterBuilderUtil.configureOtlpAggregationTemporality(
config, builder::setAggregationTemporalitySelector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public SpanExporter create(DeclarativeConfigProperties config) {
builder::setClientTls,
builder::setRetryPolicy,
builder::setMemoryMode,
builder::setLogThrottlingRate,
builder::setLogThrottlingTimeUnit,
/* isHttpProtobuf= */ false);

return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public LogRecordExporter create(DeclarativeConfigProperties config) {
builder::setClientTls,
builder::setRetryPolicy,
builder::setMemoryMode,
builder::setLogThrottlingRate,
builder::setLogThrottlingTimeUnit,
/* isHttpProtobuf= */ true);

return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public MetricExporter create(DeclarativeConfigProperties config) {
builder::setClientTls,
builder::setRetryPolicy,
builder::setMemoryMode,
builder::setLogThrottlingRate,
builder::setLogThrottlingTimeUnit,
/* isHttpProtobuf= */ true);
IncubatingExporterBuilderUtil.configureOtlpAggregationTemporality(
config, builder::setAggregationTemporalitySelector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public SpanExporter create(DeclarativeConfigProperties config) {
builder::setClientTls,
builder::setRetryPolicy,
builder::setMemoryMode,
builder::setLogThrottlingRate,
builder::setLogThrottlingTimeUnit,
/* isHttpProtobuf= */ true);

return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,20 @@ public OtlpGrpcLogRecordExporterBuilder setExecutorService(ExecutorService execu
return this;
}

public OtlpGrpcLogRecordExporterBuilder setLogThrottlingRate(
double rateLimit, double throttledRateLimit) {
checkArgument(rateLimit > 0, "rateLimit invalid");
checkArgument(throttledRateLimit > 0, "throttledRateLimit invalid");
delegate.setLogThrottlingRate(rateLimit, throttledRateLimit);
return this;
}

public OtlpGrpcLogRecordExporterBuilder setLogThrottlingTimeUnit(TimeUnit timeUnit) {
requireNonNull(timeUnit, "logTimeUnit");
delegate.setLogThrottlingTimeUnit(timeUnit);
return this;
}

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