8000 add module id in log by notshivansh · Pull Request #2756 · akto-api-security/akto · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

add module id in log #2756

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

Merged
merged 2 commits into from
Jul 4, 2025
Merged

Conversation

notshivansh
Copy link
Contributor

No description provided.

@Copilot Copilot AI review requested due to automatic review settings July 4, 2025 08:52
Copy link
Contributor
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a module identifier to all log entries by capturing a user-defined name and including it in the log text.

  • Removes the no-name init(...) overload in ModuleInfoWorker to require an explicit module name.
  • Introduces moduleId state and a setter in LoggerMaker, and updates insert() to prefix each log message with the module ID.
  • Updates the Main classes in both mini-testing and mini-runtime to pass and set the custom module name on LoggerMaker.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
libs/utils/src/main/java/com/akto/metrics/ModuleInfoWorker.java Removed the two-argument init(...) overload to enforce providing a module name.
libs/utils/src/main/java/com/akto/log/LoggerMaker.java Added moduleId field and setter; updated insert() to include [moduleId] in log messages.
apps/mini-testing/src/main/java/com/akto/testing/Main.java Calls loggerMaker.setModuleId(...) after initializing the module with a custom name.
apps/mini-runtime/src/main/java/com/akto/hybrid_runtime/Main.java Generates or reads a service name, passes it to ModuleInfoWorker.init(...), and sets it on loggerMaker.
Comments suppressed due to low confidence (3)

libs/utils/src/main/java/com/akto/metrics/ModuleInfoWorker.java:53

  • Removing this overload breaks backward compatibility for callers relying on the two-arg init method. Consider deprecating instead or providing a default name internally to avoid a breaking change.
    }

libs/utils/src/main/java/com/akto/log/LoggerMaker.java:53

  • There are no unit tests verifying that moduleId is correctly prefixed (and that null/empty values are handled). Consider adding tests for insert() to ensure consistent log output.
    private String moduleId = "";

libs/utils/src/main/java/com/akto/log/LoggerMaker.java:53

  • The mutable moduleId field is not volatile or synchronized, risking visibility issues across threads. Consider declaring it volatile or ensuring it's initialized before any worker threads start.
    private String moduleId = "";

Comment on lines +248 to +251
if (moduleId == null) {
moduleId = "";
}

Copy link
Preview
Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

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

This null check is redundant because moduleId is initialized to an empty string. It may be clearer to enforce non-null in the setter and remove this guard.

Suggested change
if (moduleId == null) {
moduleId = "";
}

Copilot uses AI. Check for mistakes.

moduleId = "";
}

String text = aClass + " : " + " [" + moduleId + " ] " + info;
Copy link
Preview
Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

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

[nitpick] The extra spaces inside the brackets lead to inconsistent log formatting. Consider simplifying to aClass + " : [" + moduleId + "] " + info for clarity.

Suggested change
String text = aClass + " : " + " [" + moduleId + " ] " + info;
String text = aClass + " : [" + moduleId + "] " + info;

Copilot uses AI. Check for mistakes.

@notshivansh notshivansh merged commit 8e5e9c5 into feature/mini-runtime-release Jul 4, 2025
3 checks passed
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.

2 participants
0