Skip to content
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

add-disk-buffering-debug-mode #664

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Annosha
Copy link

@Annosha Annosha commented Oct 27, 2024

Description

Fixes #597 Add setting to enable disk buffering debug mode

This PR introduces a configurable debug mode in the DiskBufferingConfiguration class within OpenTelemetry Android, allowing users to enable verbose logging for troubleshooting disk buffering behavior.
Changes Made

  1. Added setDebugMode Method:

A new method, setDebugMode, has been added to the DiskBufferingConfiguration.Builder class. This method accepts a boolean parameter to enable or disable debug mode.
When enabled, a log message indicates that debug mode for disk buffering is active, providing enhanced logging details for easier troubleshooting.

  1. Enhanced setEnabled Method:

The setEnabled method now includes a check for enableDebugMode. If debug mode is active, an additional log message provides further information on the state of disk buffering.
This conditional logging gives users more visibility into the disk buffering configuration when debug mode is enabled.

@Annosha Annosha requested a review from a team as a code owner October 27, 2024 07:34
@@ -22,6 +22,7 @@ public final class DiskBufferingConfiguration {
private final long maxFileAgeForWriteMillis;
private final long minFileAgeForReadMillis;
private final long maxFileAgeForReadMillis;
private final boolean enableDebugMode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a debug mode should be part of the OtelRumConfig or the lowest level of configuration (if there's one) so the whole SDK respects the debug mode flag, and not only for the disk buffering, this would be useful across the SDK and its configurations

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a case to be made for both. Top-level debug mode could imply disk buffering debug mode, but not the other way around. In any case, that should be a separate PR IMO. Feel free to log an issue to track.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good, having an SDK debug mode for all options feels too much IMO, a top-level debug mode that logs everything everywhere and respects eg a severity log level for filtering would be cleaner and easier to enable/disable.
If we introduce a debug flag per feature eg diskbuffering, that just adds more complexity everywhere, I'd rather achieve this with TAG filtering if the global debug mode is enabled.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I unresolved the comment so that I can copy-paste the comment URL otherwise the anchor link does not work, but it's not that you have to address this in this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I'm not entirely sure I made my point, so let's continue chatting about it at SIG sometime.

…ring/DiskBufferingConfiguration.java

Co-authored-by: Manoel Aranda Neto <5731772+marandaneto@users.noreply.github.com>
Copy link
Contributor

@breedx-splk breedx-splk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. This is a good first step, but we're currently missing the glue that uses this setting to actually turn on this feature in the disk buffering module. Can you please add that part, where the disk buffering code is initialized?

Comment on lines +84 to +87
Level.INFO,
"Disk buffering has been "
+ (enabled ? "enabled." : "disabled.")
+ (enableDebugMode ? " Debug mode is active." : ""));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to log the enabled setting here -- that's a separate concern below. I recommend changing the log message to be simpler and only reflect the new value of enableDebugMode.

/** 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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this message is probably not what you intended?

@breedx-splk
Copy link
Contributor

Hey @Annosha just checking in to see if you're still able to work on some revisions/improvements to this PR. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add setting to enable disk buffering debug mode
3 participants