Skip to content

[#noissue] Add Separate api to get response histogram#12489

Merged
intr3p1d merged 1 commit intopinpoint-apm:masterfrom
intr3p1d:add_histogram_api
May 27, 2025
Merged

[#noissue] Add Separate api to get response histogram#12489
intr3p1d merged 1 commit intopinpoint-apm:masterfrom
intr3p1d:add_histogram_api

Conversation

@intr3p1d
Copy link
Copy Markdown
Contributor

No description provided.

@intr3p1d intr3p1d added this to the 3.1.0 milestone May 26, 2025
@intr3p1d intr3p1d requested a review from Copilot May 26, 2025 08:51
@intr3p1d intr3p1d self-assigned this May 26, 2025
Copy link
Copy Markdown

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 introduces a separate API to obtain response histograms by adding a new HistogramService and its implementation, along with updating the controller and configuration to integrate the new service.

  • Added HistogramService interface and HistogramServiceImpl for handling application map selection and extraction of application endpoints.
  • Extended MapHistogramController with a new endpoint (getOnlyResponseTimeHistogramDataV2) and updated dependency injection in ApplicationMapModule.
  • Introduced a getter in LinkDataMap to support the new usage.

Reviewed Changes

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

Show a summary per file
File Description
web/src/main/java/com/navercorp/pinpoint/web/applicationmap/service/HistogramServiceImpl.java New implementation for application map histogram selection.
web/src/main/java/com/navercorp/pinpoint/web/applicationmap/service/HistogramService.java New service interface to support histogram API calls.
web/src/main/java/com/navercorp/pinpoint/web/applicationmap/rawdata/LinkDataMap.java Added getter for accessing linkDataMap.
web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/MapHistogramController.java New endpoint added and necessary updates to support histogram API.
web/src/main/java/com/navercorp/pinpoint/web/applicationmap/config/ApplicationMapModule.java Updated dependency injection for the histogram controller.
Comments suppressed due to low confidence (1)

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/MapHistogramController.java:101

  • The null-check error message for applicationValidator incorrectly uses 'applicationFactory'. This should be updated to 'applicationValidator' for clarity.
this.applicationValidator = Objects.requireNonNull(applicationValidator, "applicationFactory");

@intr3p1d intr3p1d force-pushed the add_histogram_api branch from e9d4af6 to b75ad8a Compare May 26, 2025 08:55
@intr3p1d intr3p1d requested a review from Copilot May 26, 2025 09:00
Copy link
Copy Markdown

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

Adds a standalone API to fetch response-time histograms alongside the existing map data by introducing a new service and controller endpoint.

  • Introduces HistogramService interface and its implementation to select application-link histograms.
  • Exposes internal link data via a new getter in LinkDataMap.
  • Adds a /getOnlyResponseTimeHistogramDataV2 endpoint in MapHistogramController and wires HistogramService in the module.

Reviewed Changes

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

Show a summary per file
File Description
web/src/main/java/com/navercorp/pinpoint/web/applicationmap/service/HistogramService.java New interface defining histogram-specific methods
web/src/main/java/com/navercorp/pinpoint/web/applicationmap/service/HistogramServiceImpl.java Implementation of the histogram service
web/src/main/java/com/navercorp/pinpoint/web/applicationmap/rawdata/LinkDataMap.java Added getLinkDataMap() to expose the internal map
web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/MapHistogramController.java Added new endpoint /getOnlyResponseTimeHistogramDataV2 and depth form
web/src/main/java/com/navercorp/pinpoint/web/applicationmap/config/ApplicationMapModule.java Injected HistogramService into the controller bean definition
Comments suppressed due to low confidence (3)

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/MapHistogramController.java:210

  • The method name matches the existing endpoint rather than the new /getOnlyResponseTimeHistogramDataV2 mapping; rename it to getOnlyResponseTimeHistogramDataV2 to avoid confusion.
public NodeHistogramSummaryView getResponseTimeHistogramDataV2(

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/service/HistogramServiceImpl.java:37

  • No unit or integration tests accompany this new service and its controller endpoint; add tests to validate key behaviors and guard against regressions.
/*

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/MapHistogramController.java:216

  • Depth parameters are bound from the form but no explicit field constraints are shown; ensure SearchDepthForm has validation annotations to prevent out-of-range values.
@Valid @ModelAttribute SearchDepthForm depthForm,

}

public Map<LinkKey, LinkData> getLinkDataMap() {
return linkDataMap;
Copy link

Copilot AI May 26, 2025

Choose a reason for hiding this comment

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

Returning the internal mutable map exposes implementation details and allows external mutation; consider wrapping with Collections.unmodifiableMap(linkDataMap) to preserve encapsulation.

Suggested change
return linkDataMap;
return Collections.unmodifiableMap(linkDataMap);

Copilot uses AI. Check for mistakes.

TimeWindow timeWindow = option.getTimeWindow();
LinkDataDuplexMap linkDataDuplexMap = linkSelector.select(Collections.singletonList(option.getSourceApplication()), timeWindow, outSearchDepth, inSearchDepth, timeAggregate);
watch.stop();
Copy link

Copilot AI May 26, 2025

Choose a reason for hiding this comment

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

[nitpick] You stop the stopwatch but never log its elapsed time; consider logging watch.getTotalTimeMillis() or using watch.prettyPrint() for better observability.

Suggested change
watch.stop();
watch.stop();
logger.debug("Elapsed time for ApplicationMap Link Fetch: {} ms", watch.getTotalTimeMillis());

Copilot uses AI. Check for mistakes.
return new NodeHistogramSummaryView(nodeHistogramSummary, serverGroupListView, format);
}

@GetMapping(value = "/getOnlyResponseTimeHistogramDataV2")
Copy link

Copilot AI May 26, 2025

Choose a reason for hiding this comment

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

[nitpick] The path includes an HTTP verb and version in camelCase; consider using RESTful, resource-oriented naming (e.g., /v2/histograms/response-time/only).

Suggested change
@GetMapping(value = "/getOnlyResponseTimeHistogramDataV2")
@GetMapping(value = "/v2/histograms/response-time/only")

Copilot uses AI. Check for mistakes.
Comment on lines +24 to +28
* @author intr3p1d
*/
public interface HistogramService {
LinkDataDuplexMap selectApplicationMap(MapServiceOption option);
List<Application> getFromApplications(LinkDataDuplexMap linkDataDuplexMap);
Copy link

Copilot AI May 26, 2025

Choose a reason for hiding this comment

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

[nitpick] The new service interface lacks Javadoc; please add class- and method-level comments to explain its responsibility and usage.

Suggested change
* @author intr3p1d
*/
public interface HistogramService {
LinkDataDuplexMap selectApplicationMap(MapServiceOption option);
List<Application> getFromApplications(LinkDataDuplexMap linkDataDuplexMap);
* The {@code HistogramService} interface provides methods for retrieving and processing
* application map data, including histograms and related application information.
* <p>
* Implementations of this interface are responsible for querying and transforming
* data into a format suitable for application map visualizations.
* </p>
*
* @see com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap
* @see com.navercorp.pinpoint.web.vo.Application
*/
public interface HistogramService {
/**
* Retrieves the application map data based on the specified options.
*
* @param option the options for querying the application map
* @return a {@link LinkDataDuplexMap} containing the application map data
*/
LinkDataDuplexMap selectApplicationMap(MapServiceOption option);
/**
* Extracts the list of source applications from the given application map data.
*
* @param linkDataDuplexMap the application map data
* @return a list of {@link Application} objects representing the source applications
*/
List<Application> getFromApplications(LinkDataDuplexMap linkDataDuplexMap);
/**
* Extracts the list of destination applications from the given application map data.
*
* @param linkDataDuplexMap the application map data
* @return a list of {@link Application} objects representing the destination applications
*/

Copilot uses AI. Check for mistakes.
@intr3p1d intr3p1d force-pushed the add_histogram_api branch from b75ad8a to 2155d69 Compare May 27, 2025 10:03
@codecov
Copy link
Copy Markdown

codecov bot commented May 27, 2025

Codecov Report

Attention: Patch coverage is 0% with 62 lines in your changes missing coverage. Please review.

Project coverage is 33.57%. Comparing base (3a54f98) to head (2155d69).
Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
...b/applicationmap/service/HistogramServiceImpl.java 0.00% 37 Missing ⚠️
...licationmap/controller/MapHistogramController.java 0.00% 23 Missing ⚠️
...eb/applicationmap/config/ApplicationMapModule.java 0.00% 1 Missing ⚠️
...npoint/web/applicationmap/rawdata/LinkDataMap.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #12489      +/-   ##
============================================
- Coverage     33.59%   33.57%   -0.02%     
- Complexity    10738    10741       +3     
============================================
  Files          3941     3943       +2     
  Lines         91809    91872      +63     
  Branches       9553     9558       +5     
============================================
+ Hits          30844    30847       +3     
- Misses        58329    58386      +57     
- Partials       2636     2639       +3     

☔ 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.

@intr3p1d intr3p1d merged commit 5aa4639 into pinpoint-apm:master May 27, 2025
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants