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

[#11050] Remove duplicate code in TimeHistogramFormat #11143

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,12 @@
limit, range.prettyToString(), DateTimeFormatUtils.format(lastScanTime));
}

final FilterMapWrap mapWrap = new FilterMapWrap(map, getTimeHistogramFormat(useLoadHistogramFormat));
TimeHistogramFormat format = TimeHistogramFormat.format(useLoadHistogramFormat);
final FilterMapWrap mapWrap = new FilterMapWrap(map, format);

Check warning on line 157 in web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/FilteredMapController.java

View check run for this annotation

Codecov / codecov/patch

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/FilteredMapController.java#L156-L157

Added lines #L156 - L157 were not covered by tests
mapWrap.setLastFetchedTimestamp(lastScanTime);
return mapWrap;
}

private static TimeHistogramFormat getTimeHistogramFormat(boolean useLoadHistogramFormat) {
if (useLoadHistogramFormat) {
return TimeHistogramFormat.V2;
} else {
return TimeHistogramFormat.V1;
}
}

@GetMapping(value = "/getFilteredServerMapDataMadeOfDotGroupV3", params = "serviceTypeCode")
public FilterMapWrap getFilteredServerMapDataMadeOfDotGroupV3(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,8 @@
logger.info("Select applicationMap. option={}", mapServiceOption);
final ApplicationMap map = this.mapService.selectApplicationMap(mapServiceOption);

if (useLoadHistogramFormat) {
return new MapWrap(map, TimeHistogramFormat.V2);
}
return new MapWrap(map, TimeHistogramFormat.V1);
TimeHistogramFormat format = TimeHistogramFormat.format(useLoadHistogramFormat);
return new MapWrap(map, format);

Check warning on line 197 in web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/MapController.java

View check run for this annotation

Codecov / codecov/patch

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/MapController.java#L196-L197

Added lines #L196 - L197 were not covered by tests
}

@GetMapping(value = "/getResponseTimeHistogramData", params = "serviceTypeName")
Expand Down Expand Up @@ -242,18 +240,10 @@
.build();
final NodeHistogramSummary nodeHistogramSummary = responseTimeHistogramService.selectNodeHistogramData(option);

TimeHistogramFormat format = histogramFormat(useLoadHistogramFormat);

TimeHistogramFormat format = TimeHistogramFormat.format(useLoadHistogramFormat);

Check warning on line 243 in web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/MapController.java

View check run for this annotation

Codecov / codecov/patch

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/MapController.java#L243

Added line #L243 was not covered by tests
return new NodeHistogramSummaryView(nodeHistogramSummary, nodeHistogramSummary.getServerGroupList(), format);
}

private TimeHistogramFormat histogramFormat(boolean useLoadHistogramFormat) {
if (useLoadHistogramFormat) {
return TimeHistogramFormat.V2;
} else {
return TimeHistogramFormat.V1;
}
}

@GetMapping(value = "/getResponseTimeHistogramDataV2")
public NodeHistogramSummaryView getResponseTimeHistogramDataV2(
Expand Down Expand Up @@ -297,7 +287,7 @@

final NodeHistogramSummary nodeHistogramSummary = responseTimeHistogramService.selectNodeHistogramData(option);

final TimeHistogramFormat format = getTimeHistogramFormat(useLoadHistogramFormat);
final TimeHistogramFormat format = TimeHistogramFormat.format(useLoadHistogramFormat);

Check warning on line 290 in web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/MapController.java

View check run for this annotation

Codecov / codecov/patch

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/MapController.java#L290

Added line #L290 was not covered by tests
return new NodeHistogramSummaryView(nodeHistogramSummary, nodeHistogramSummary.getServerGroupList(), format);
}

Expand Down Expand Up @@ -344,17 +334,10 @@
final LinkHistogramSummary linkHistogramSummary =
responseTimeHistogramService.selectLinkHistogramData(fromApplication, toApplication, range);

TimeHistogramFormat format = getTimeHistogramFormat(useLoadHistogramFormat);
TimeHistogramFormat format = TimeHistogramFormat.format(useLoadHistogramFormat);

Check warning on line 337 in web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/MapController.java

View check run for this annotation

Codecov / codecov/patch

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/controller/MapController.java#L337

Added line #L337 was not covered by tests
return new LinkHistogramSummaryView(linkHistogramSummary, format);
}

private TimeHistogramFormat getTimeHistogramFormat(boolean useLoadHistogramFormat) {
if (useLoadHistogramFormat) {
return TimeHistogramFormat.V2;
}
return TimeHistogramFormat.V1;
}

@Nullable
private Application createApplication(@Nullable String name, Short serviceTypeCode) {
if (name == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,12 @@

public enum TimeHistogramFormat {
V1, // key is slot("1s", "3s", "5s", "Slow", "Error"), value is {timestamp : count}
V2 // key is timestamp, value is [1s, 3s, 5s, Slow, Error, Avg, Max, Sum, Tot] - LoadHistogram
V2; // key is timestamp, value is [1s, 3s, 5s, Slow, Error, Avg, Max, Sum, Tot] - LoadHistogram

public static TimeHistogramFormat format(boolean useLoadHistogramFormat) {
if (useLoadHistogramFormat) {
return V2;

Check warning on line 25 in web/src/main/java/com/navercorp/pinpoint/web/applicationmap/histogram/TimeHistogramFormat.java

View check run for this annotation

Codecov / codecov/patch

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/histogram/TimeHistogramFormat.java#L25

Added line #L25 was not covered by tests
}
return V1;

Check warning on line 27 in web/src/main/java/com/navercorp/pinpoint/web/applicationmap/histogram/TimeHistogramFormat.java

View check run for this annotation

Codecov / codecov/patch

web/src/main/java/com/navercorp/pinpoint/web/applicationmap/histogram/TimeHistogramFormat.java#L27

Added line #L27 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,8 @@

final TransactionInfoViewModel result = newTransactionInfo(spanId, transactionId, spanResult, map, recordSet);

if (useLoadHistogramFormat) {
result.setTimeHistogramFormat(TimeHistogramFormat.V2);
}
TimeHistogramFormat format = TimeHistogramFormat.format(useLoadHistogramFormat);
result.setTimeHistogramFormat(format);

Check warning on line 134 in web/src/main/java/com/navercorp/pinpoint/web/controller/BusinessTransactionController.java

View check run for this annotation

Codecov / codecov/patch

web/src/main/java/com/navercorp/pinpoint/web/controller/BusinessTransactionController.java#L133-L134

Added lines #L133 - L134 were not covered by tests
return result;
}

Expand Down