From 09b7047a6e802522b3cc1f9d2b1f445b768ae46f Mon Sep 17 00:00:00 2001 From: Annosha Date: Sun, 27 Oct 2024 12:31:13 +0500 Subject: [PATCH 1/4] add-disk-buffering-debug-mode --- .../diskbuffering/DiskBufferingConfiguration.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java b/core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java index ab4d5a662..6c81115ea 100644 --- a/core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java +++ b/core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java @@ -30,6 +30,7 @@ private DiskBufferingConfiguration(Builder builder) { maxFileAgeForWriteMillis = builder.maxFileAgeForWriteMillis; minFileAgeForReadMillis = builder.minFileAgeForReadMillis; maxFileAgeForReadMillis = builder.maxFileAgeForReadMillis; + this.enableDebugMode = builder.enableDebugMode; } public static Builder builder() { @@ -70,12 +71,26 @@ public static final class Builder { private long maxFileAgeForWriteMillis = TimeUnit.SECONDS.toMillis(30); private long minFileAgeForReadMillis = TimeUnit.SECONDS.toMillis(33); private long maxFileAgeForReadMillis = TimeUnit.HOURS.toMillis(18); + private boolean enableDebugMode = false; private ExportScheduleHandler exportScheduleHandler = DefaultExportScheduleHandler.create(); + // Sets the debug mode for disk buffering, enabling additional logging. + public Builder setDebugMode(boolean enableDebugMode) { + this.enableDebugMode = enableDebugMode; + Logger.getLogger(DiskBufferingConfiguration.class.getName()).log(Level.INFO, + "Disk buffering has been " + (enabled ? "enabled." : "disabled.") + + (enableDebugMode ? " Debug mode is active." : "")); + return this; + } + /** Enables or disables disk buffering. */ public Builder setEnabled(boolean enabled) { this.enabled = enabled; + if (enableDebugMode) { + Logger.getLogger(DiskBufferingConfiguration.class.getName()).log(Level.INFO, "Debug log message here"); + } + return this; } From 8773508653ced5c939c01c4c46484242e9949d7a Mon Sep 17 00:00:00 2001 From: Annosha Date: Sun, 27 Oct 2024 12:43:45 +0500 Subject: [PATCH 2/4] lint fixes --- .../DiskBufferingConfiguration.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java b/core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java index 6c81115ea..b75bc9db2 100644 --- a/core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java +++ b/core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java @@ -30,7 +30,7 @@ private DiskBufferingConfiguration(Builder builder) { maxFileAgeForWriteMillis = builder.maxFileAgeForWriteMillis; minFileAgeForReadMillis = builder.minFileAgeForReadMillis; maxFileAgeForReadMillis = builder.maxFileAgeForReadMillis; - this.enableDebugMode = builder.enableDebugMode; + this.enableDebugMode = builder.enableDebugMode; } public static Builder builder() { @@ -78,9 +78,12 @@ public static final class Builder { // Sets the debug mode for disk buffering, enabling additional logging. public Builder setDebugMode(boolean enableDebugMode) { this.enableDebugMode = enableDebugMode; - Logger.getLogger(DiskBufferingConfiguration.class.getName()).log(Level.INFO, - "Disk buffering has been " + (enabled ? "enabled." : "disabled.") + - (enableDebugMode ? " Debug mode is active." : "")); + Logger.getLogger(DiskBufferingConfiguration.class.getName()) + .log( + Level.INFO, + "Disk buffering has been " + + (enabled ? "enabled." : "disabled.") + + (enableDebugMode ? " Debug mode is active." : "")); return this; } @@ -88,9 +91,10 @@ public Builder setDebugMode(boolean enableDebugMode) { public Builder setEnabled(boolean enabled) { this.enabled = enabled; if (enableDebugMode) { - Logger.getLogger(DiskBufferingConfiguration.class.getName()).log(Level.INFO, "Debug log message here"); + Logger.getLogger(DiskBufferingConfiguration.class.getName()) + .log(Level.INFO, "Debug log message here"); } - + return this; } From 0976e0d8d389635c1601365cc194107dffe69617 Mon Sep 17 00:00:00 2001 From: Annosha Date: Sun, 27 Oct 2024 13:07:02 +0500 Subject: [PATCH 3/4] fixing-variables --- .../features/diskbuffering/DiskBufferingConfiguration.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java b/core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java index b75bc9db2..70f1ff545 100644 --- a/core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java +++ b/core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java @@ -22,6 +22,7 @@ public final class DiskBufferingConfiguration { private final long maxFileAgeForWriteMillis; private final long minFileAgeForReadMillis; private final long maxFileAgeForReadMillis; + private final boolean enableDebugMode; private DiskBufferingConfiguration(Builder builder) { enabled = builder.enabled; @@ -30,7 +31,7 @@ private DiskBufferingConfiguration(Builder builder) { maxFileAgeForWriteMillis = builder.maxFileAgeForWriteMillis; minFileAgeForReadMillis = builder.minFileAgeForReadMillis; maxFileAgeForReadMillis = builder.maxFileAgeForReadMillis; - this.enableDebugMode = builder.enableDebugMode; + enableDebugMode = builder.enableDebugMode; } public static Builder builder() { From e7ad0e5ffd2e268e5fc91440f9368d4561ab340a Mon Sep 17 00:00:00 2001 From: Annosha <111076986+Annosha@users.noreply.github.com> Date: Tue, 29 Oct 2024 10:35:09 +0500 Subject: [PATCH 4/4] Update core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java Co-authored-by: Manoel Aranda Neto <5731772+marandaneto@users.noreply.github.com> --- .../features/diskbuffering/DiskBufferingConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java b/core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java index 70f1ff545..9d659956e 100644 --- a/core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java +++ b/core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java @@ -76,7 +76,7 @@ public static final class Builder { private ExportScheduleHandler exportScheduleHandler = DefaultExportScheduleHandler.create(); - // Sets the debug mode for disk buffering, enabling additional logging. + /** Sets the debug mode for disk buffering, enabling additional logging. */ public Builder setDebugMode(boolean enableDebugMode) { this.enableDebugMode = enableDebugMode; Logger.getLogger(DiskBufferingConfiguration.class.getName())