-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to enable debug logging for disk buffering (#753)
* refactor to kotlin * use config in demo * enable debug mode and wire up to demo app * extract constants * extract constants
- Loading branch information
1 parent
6ee3d1f
commit a55b22a
Showing
8 changed files
with
97 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
core/src/main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.android.features.diskbuffering | ||
|
||
import android.util.Log | ||
import io.opentelemetry.android.common.RumConstants.OTEL_RUM_LOG_TAG | ||
import java.util.concurrent.TimeUnit | ||
|
||
const val DEFAULT_MAX_CACHE_SIZE: Int = 60 * 1024 * 1024 | ||
const val MAX_CACHE_FILE_SIZE: Int = 1024 * 1024 | ||
const val DEFAULT_MAX_FILE_AGE_FOR_WRITE_MS = 30L | ||
const val DEFAULT_MIN_FILE_AGE_FOR_READ_MS = 33L | ||
const val DEFAULT_MAX_FILE_AGE_FOR_READ_MS = 18L | ||
|
||
data class DiskBufferingConfig | ||
@JvmOverloads | ||
constructor( | ||
val enabled: Boolean = false, | ||
val maxCacheSize: Int = DEFAULT_MAX_CACHE_SIZE, | ||
val maxFileAgeForWriteMillis: Long = TimeUnit.SECONDS.toMillis(DEFAULT_MAX_FILE_AGE_FOR_WRITE_MS), | ||
val minFileAgeForReadMillis: Long = TimeUnit.SECONDS.toMillis(DEFAULT_MIN_FILE_AGE_FOR_READ_MS), | ||
val maxFileAgeForReadMillis: Long = TimeUnit.HOURS.toMillis(DEFAULT_MAX_FILE_AGE_FOR_READ_MS), | ||
val maxCacheFileSize: Int = MAX_CACHE_FILE_SIZE, | ||
val debugEnabled: Boolean = false, | ||
) { | ||
companion object { | ||
/** | ||
* Convenience factory method that validates the min/max and fixes | ||
* those up if needed. Users should prefer this method over the | ||
* vanilla non-validating constructor. | ||
*/ | ||
@JvmOverloads | ||
@JvmStatic | ||
fun create( | ||
enabled: Boolean = false, | ||
maxCacheSize: Int = DEFAULT_MAX_CACHE_SIZE, | ||
maxFileAgeForWriteMillis: Long = TimeUnit.SECONDS.toMillis(30), | ||
minFileAgeForReadMillis: Long = TimeUnit.SECONDS.toMillis(33), | ||
maxFileAgeForReadMillis: Long = TimeUnit.HOURS.toMillis(18), | ||
maxCacheFileSize: Int = MAX_CACHE_FILE_SIZE, | ||
debugEnabled: Boolean = false, | ||
): DiskBufferingConfig { | ||
var minRead = minFileAgeForReadMillis | ||
if (minFileAgeForReadMillis <= maxFileAgeForWriteMillis) { | ||
minRead = maxFileAgeForWriteMillis + 5 | ||
Log.w(OTEL_RUM_LOG_TAG, "minFileAgeForReadMillis must be greater than maxFileAgeForWriteMillis") | ||
Log.w(OTEL_RUM_LOG_TAG, "overriding minFileAgeForReadMillis from $minFileAgeForReadMillis to $minRead") | ||
} | ||
return DiskBufferingConfig( | ||
enabled = enabled, | ||
maxCacheSize = maxCacheSize, | ||
maxFileAgeForWriteMillis = maxFileAgeForWriteMillis, | ||
minFileAgeForReadMillis = minRead, | ||
maxFileAgeForReadMillis = maxFileAgeForReadMillis, | ||
maxCacheFileSize = maxCacheFileSize, | ||
debugEnabled = debugEnabled, | ||
) | ||
} | ||
} | ||
} |
125 changes: 0 additions & 125 deletions
125
...main/java/io/opentelemetry/android/features/diskbuffering/DiskBufferingConfiguration.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.