-
Notifications
You must be signed in to change notification settings - Fork 93
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 recorder support #203
Add recorder support #203
Conversation
WalkthroughThe changes introduce a new version update in Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 1
Outside diff range and nitpick comments (1)
src/main/java/com/alipay/sofa/common/insight/RecordContext.java (1)
214-220
: Refine thetoString
method for better readability.The current implementation of
toString
could be improved for better readability by usingString.format
or joining strings in a more structured way:@Override public String toString() { return String.format("RecordContext{requestId=%d, traceId='%s', rpcId='%s', targetServiceUniqueName='%s', methodName='%s', moduleName='%s', beanName='%s', extraInfo=%s}", requestId, traceId, rpcId, targetServiceUniqueName, methodName, moduleName, beanName, extraInfo); }
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (11)
- pom.xml (1 hunks)
- src/main/java/com/alipay/sofa/common/insight/NoopRecorder.java (1 hunks)
- src/main/java/com/alipay/sofa/common/insight/RecordContext.java (1 hunks)
- src/main/java/com/alipay/sofa/common/insight/RecordScene.java (1 hunks)
- src/main/java/com/alipay/sofa/common/insight/Recorder.java (1 hunks)
- src/main/java/com/alipay/sofa/common/insight/RecorderManager.java (1 hunks)
- src/main/java/com/alipay/sofa/common/log/MultiAppLoggerSpaceManager.java (2 hunks)
- src/main/java/com/alipay/sofa/common/thread/ThreadPoolGovernor.java (2 hunks)
- src/test/java/com/alipay/sofa/common/recorder/RecorderManagerTest.java (1 hunks)
- src/test/java/com/alipay/sofa/common/recorder/SampleRecorder.java (1 hunks)
- src/test/resources/META-INF/services/com.alipay.sofa.common.insight.Recorder (1 hunks)
Files skipped from review due to trivial changes (2)
- pom.xml
- src/test/java/com/alipay/sofa/common/recorder/RecorderManagerTest.java
Additional comments not posted (8)
src/test/resources/META-INF/services/com.alipay.sofa.common.insight.Recorder (1)
1-1
: Correct declaration ofSampleRecorder
as a service provider for theRecorder
interface.src/main/java/com/alipay/sofa/common/insight/NoopRecorder.java (1)
23-37
: TheNoopRecorder
class is correctly implemented as a no-operation singleton recorder.src/main/java/com/alipay/sofa/common/insight/Recorder.java (1)
23-39
: TheRecorder
interface is well-defined with clear method signatures and documentation.src/test/java/com/alipay/sofa/common/recorder/SampleRecorder.java (1)
29-40
: TheSampleRecorder
class correctly implements theRecorder
interface. Note: It usesSystem.out
for logging, ensure this is intended for non-production use.src/main/java/com/alipay/sofa/common/insight/RecordScene.java (1)
23-59
: TheRecordScene
enum is well-defined with clear descriptions for each recording scenario.src/main/java/com/alipay/sofa/common/insight/RecorderManager.java (1)
30-55
: TheRecorderManager
class is correctly implemented with thread-safe management and initialization of recorders.src/main/java/com/alipay/sofa/common/thread/ThreadPoolGovernor.java (1)
371-373
: Validate the new methodgetAllThreadPoolWrappers
.The implementation of
getAllThreadPoolWrappers
correctly returns a collection ofThreadPoolMonitorWrapper
instances. This method provides a safe way to access all registered thread pool wrappers without exposing the internal structure.src/main/java/com/alipay/sofa/common/log/MultiAppLoggerSpaceManager.java (1)
366-368
: Validate the new methodgetLogFactoryMap
.The implementation of
getLogFactoryMap
correctly returns a copy of theLOG_FACTORY_MAP
, ensuring that the internal state is not exposed directly. This is a good practice for encapsulation and thread safety.
public RecordContext() { | ||
this.extraInfo = new ConcurrentHashMap<>(); | ||
} |
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.
Ensure thread safety for extraInfo
initialization in all constructors.
Consider initializing extraInfo
in the field declaration to ensure it's always initialized properly, regardless of the constructor used:
- private Map<String, Object> extraInfo;
+ private Map<String, Object> extraInfo = new ConcurrentHashMap<>();
Then, remove the initialization from all constructors.
Also applies to: 48-51, 59-63
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
public RecordContext() { | |
this.extraInfo = new ConcurrentHashMap<>(); | |
} | |
private Map<String, Object> extraInfo = new ConcurrentHashMap<>(); | |
public RecordContext() { | |
} |
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.
LGTM
Motivation:
Explain the context, and why you're making that change.
To make others understand what is the problem you're trying to solve.
Modification:
Describe the idea and modifications you've done.
Result:
Fixes #.
If there is no issue then describe the changes introduced by this PR.
Summary by CodeRabbit
New Features
NoopRecorder
,RecordContext
,RecordScene
, andRecorderManager
for enhanced recording and logging capabilities.SampleRecorder
for testing recording functionalities.Improvements
2.1.1-SNAPSHOT
for better performance and stability.MultiAppLoggerSpaceManager
with a method to retrieve log factory maps.ThreadPoolGovernor
with a method to get all thread pool wrappers.Tests
RecorderManagerTest
to ensure proper initialization and retrieval of recorders.