-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding disk buffering, part 2 #160
Merged
LikeTheSalad
merged 9 commits into
open-telemetry:main
from
LikeTheSalad:disk-buffering-part-2
Dec 12, 2023
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2dc3386
Using disk span exporter
LikeTheSalad 4b5fcce
Moving test assertions out of nested callbacks
LikeTheSalad d9f682f
Logging when disk span exporter init fails
LikeTheSalad 3dbd9a8
Updating log message
LikeTheSalad 5917780
Created SimpleTemporaryFileProviderTest
LikeTheSalad 9a3c9e1
Adding javadoc to SimpleTemporaryFileProvider.createTemporaryFile
LikeTheSalad b089905
Replacing java Logger by android Log
LikeTheSalad 6206346
Improving tests for SimpleTemporaryFileProvider
LikeTheSalad db49011
Using UUID to reduce the changes of creating duplicate temp files
LikeTheSalad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
26 changes: 26 additions & 0 deletions
26
...a/io/opentelemetry/android/internal/features/persistence/SimpleTemporaryFileProvider.java
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,26 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.android.internal.features.persistence; | ||
|
||
import io.opentelemetry.contrib.disk.buffering.internal.files.TemporaryFileProvider; | ||
import java.io.File; | ||
|
||
/** | ||
* This class is internal and not for public use. Its APIs are unstable and can change at any time. | ||
*/ | ||
public final class SimpleTemporaryFileProvider implements TemporaryFileProvider { | ||
private final File tempDir; | ||
|
||
public SimpleTemporaryFileProvider(File tempDir) { | ||
this.tempDir = tempDir; | ||
} | ||
|
||
/** Creates a unique file instance using the provided prefix and the current time in millis. */ | ||
@Override | ||
public File createTemporaryFile(String prefix) { | ||
breedx-splk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return new File(tempDir, prefix + "_" + System.currentTimeMillis() + ".tmp"); | ||
breedx-splk marked this conversation as resolved.
Show resolved
Hide resolved
LikeTheSalad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
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
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
30 changes: 30 additions & 0 deletions
30
.../opentelemetry/android/internal/features/persistence/SimpleTemporaryFileProviderTest.java
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,30 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.android.internal.features.persistence; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.io.File; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
class SimpleTemporaryFileProviderTest { | ||
@TempDir File tempDir; | ||
|
||
@Test | ||
void createUniqueFilesBasedOnCurrentTimeAndPrefix() throws InterruptedException { | ||
SimpleTemporaryFileProvider provider = new SimpleTemporaryFileProvider(tempDir); | ||
File first = provider.createTemporaryFile("a"); | ||
File second = provider.createTemporaryFile("b"); | ||
Thread.sleep(1); | ||
File third = provider.createTemporaryFile("a"); | ||
|
||
assertThat(first.getName()).startsWith("a").endsWith(".tmp"); | ||
assertThat(second.getName()).startsWith("b").endsWith(".tmp"); | ||
assertThat(third.getName()).startsWith("a").endsWith(".tmp"); | ||
assertThat(first).isNotEqualTo(third); | ||
LikeTheSalad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it only IOEx or also securityexception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment it's only IOExceptions thrown in case the dirs cannot be created for whatever reason.