Skip to content

Comments

[#noissue] Refactor active agent validation to use agent ID and service type#13419

Merged
emeroad merged 1 commit intopinpoint-apm:masterfrom
emeroad:#noissue_valiation
Feb 20, 2026
Merged

[#noissue] Refactor active agent validation to use agent ID and service type#13419
emeroad merged 1 commit intopinpoint-apm:masterfrom
emeroad:#noissue_valiation

Conversation

@emeroad
Copy link
Member

@emeroad emeroad commented Feb 20, 2026

…ce type

This pull request refactors how agent activity is checked by removing the dependency on the Application object and instead using primitive parameters (agentId and agentServiceType). This simplifies method signatures and improves clarity in the agent activity validation logic across the batch and web modules.

Refactoring agent activity validation:

  • Changed BatchAgentService.isActive and its implementations to accept agentId and agentServiceType as parameters instead of an Application object, updating all usages accordingly (BatchAgentService.java, BatchAgentServiceImpl.java, AlarmProcessor.java). [1] [2] [3]
  • Updated ActiveAgentValidator interface and its implementation to replace methods using Application with methods using agentId and agentServiceType, and adjusted the validation logic to match (ActiveAgentValidator.java, DefaultActiveAgentValidator.java). [1] [2]

Code cleanup:

  • Removed unnecessary imports of Application from affected files, reflecting the updated method signatures. [1] [2] [3]

Copy link

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 pull request refactors the agent activity validation logic to use primitive parameters (agentId and agentServiceType) instead of Application objects. This simplifies method signatures across the batch and web modules and reduces coupling to the Application class.

Changes:

  • Refactored ActiveAgentValidator interface and DefaultActiveAgentValidator implementation to accept agentId (String) and agentServiceType (int) parameters instead of Application objects
  • Updated BatchAgentService interface and implementation to match the new signature pattern
  • Modified AlarmProcessor.fetchActiveAgents() to use the new API, replacing stream-based filtering with a for-loop

Reviewed changes

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

Show a summary per file
File Description
web/src/main/java/com/navercorp/pinpoint/web/service/component/ActiveAgentValidator.java Updated interface methods to accept primitive parameters and removed Application import
web/src/main/java/com/navercorp/pinpoint/web/service/component/DefaultActiveAgentValidator.java Implemented the refactored methods using agentId and agentServiceType parameters
batch/src/main/java/com/navercorp/pinpoint/batch/service/BatchAgentService.java Updated service interface to match the new signature pattern
batch/src/main/java/com/navercorp/pinpoint/batch/service/BatchAgentServiceImpl.java Implemented the new method signature delegating to ActiveAgentValidator
batch/src/main/java/com/navercorp/pinpoint/batch/alarm/AlarmProcessor.java Updated to call the new API with agentId and service type code directly

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

boolean isActiveAgent(String agentId, int agentServiceType, Range range);

boolean isActiveAgent(Application agent, String version, Range range);
boolean isActiveAgent(String agentId, int serviceType, String version, Range range);
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

Parameter name inconsistency: this method uses 'serviceType' while the overloaded method on line 8 uses 'agentServiceType' for the same semantic parameter. For consistency, this should be renamed to 'agentServiceType' to match the other overload and the implementation in DefaultActiveAgentValidator.

Suggested change
boolean isActiveAgent(String agentId, int serviceType, String version, Range range);
boolean isActiveAgent(String agentId, int agentServiceType, String version, Range range);

Copilot uses AI. Check for mistakes.
Comment on lines +38 to +43
public boolean isActiveAgent(String agentId, int agentServiceType, Range range) {
return isActiveAgent(agentId, agentServiceType, null, range);
}

@Override
public boolean isActiveAgent(Application agent, String version, Range range) {
Objects.requireNonNull(agent, "agent");
String agentId = agent.getName();
if (!agentCompatibility.isLegacyAgent(agent.getServiceTypeCode(), version)) {
public boolean isActiveAgent(String agentId, int agentServiceType, String version, Range range) {
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

The method signature change removes the overload that accepts an Application object. However, the test file DefaultActiveAgentValidatorTest.java (lines 35, 46, 54, 67) still calls isActiveAgent with an Application object, which will cause compilation failures. The tests need to be updated to use the new signature that accepts agentId (String) and agentServiceType (int) instead.

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link

@codecov
Copy link

codecov bot commented Feb 20, 2026

Codecov Report

❌ Patch coverage is 18.18182% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 33.10%. Comparing base (44659e5) to head (561ff2c).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...navercorp/pinpoint/batch/alarm/AlarmProcessor.java 0.00% 7 Missing ⚠️
.../pinpoint/batch/service/BatchAgentServiceImpl.java 0.00% 1 Missing ⚠️
...service/component/DefaultActiveAgentValidator.java 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #13419      +/-   ##
============================================
- Coverage     33.10%   33.10%   -0.01%     
  Complexity    10974    10974              
============================================
  Files          4066     4066              
  Lines         94350    94350              
  Branches       9815     9817       +2     
============================================
- Hits          31235    31231       -4     
- Misses        60432    60436       +4     
  Partials       2683     2683              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@emeroad emeroad merged commit 14d8258 into pinpoint-apm:master Feb 20, 2026
6 of 7 checks passed
@emeroad emeroad deleted the #noissue_valiation branch February 20, 2026 04:56
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.

1 participant