From 6493988d206ff53b6c8d91b4e0cb3ccf4fc797ae Mon Sep 17 00:00:00 2001 From: Victor Date: Fri, 1 Nov 2024 03:41:45 +0100 Subject: [PATCH] replaced Function with a custom CategoryFunction interface and Duration with a plain long value for timeWindowInMillis ref #638 --- .vscode/settings.json | 3 +++ core/build.gradle.kts | 6 ------ .../opentelemetry/android/export/RateLimitedExporter.java | 7 +++---- 3 files changed, 6 insertions(+), 10 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..e0f15db2e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "automatic" +} \ No newline at end of file diff --git a/core/build.gradle.kts b/core/build.gradle.kts index f863ad92e..6d32acda9 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -12,12 +12,6 @@ android { testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") buildConfigField("String", "OTEL_ANDROID_VERSION", "\"$version\"") - -// Enable desugaring for Java 8 features - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 // Set source compatibility to Java 8 - targetCompatibility = JavaVersion.VERSION_1_8 // Set target compatibility to Java 8 - } } buildTypes { diff --git a/core/src/main/java/io/opentelemetry/android/export/RateLimitedExporter.java b/core/src/main/java/io/opentelemetry/android/export/RateLimitedExporter.java index 4adee7371..b4e5372a3 100644 --- a/core/src/main/java/io/opentelemetry/android/export/RateLimitedExporter.java +++ b/core/src/main/java/io/opentelemetry/android/export/RateLimitedExporter.java @@ -28,8 +28,7 @@ private BandwidthThrottlingExporter(Builder builder) { this.categoryFunction = builder.categoryFunction; this.maxBytesPerSecond = builder.maxBytesPerSecond; this.timeWindowInMillis = builder.timeWindow.toMillis(); - this.lastExportTime = System.currentTimeMillis(); - + this.lastExportTime = SystemTime.get().getCurrentTimeMillis(); this.bytesExportedInWindow = 0; } @@ -88,9 +87,9 @@ public CompletableResultCode shutdown() { static class Builder { final SpanExporter delegate; - Function categoryFunction = span -> "default"; + CategoryFunction categoryFunction = span -> "default"; long maxBytesPerSecond = 1024; // Default to 1 KB/s - Duration timeWindow = Duration.ofSeconds(1); // Default to 1 second + long timeWindowInMillis = 1000; // Default to 1 second private Builder(SpanExporter delegate) { this.delegate = delegate;