Skip to content

Commit

Permalink
[#11050] Refactor HistogramView
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed Jun 3, 2024
1 parent d785d6c commit e8f0f49
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonValue;
import com.navercorp.pinpoint.web.applicationmap.histogram.Histogram;
import com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram;
import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram;
import com.navercorp.pinpoint.web.applicationmap.link.Link;
import com.navercorp.pinpoint.web.applicationmap.nodes.Node;
import com.navercorp.pinpoint.web.scatter.ScatterData;
Expand Down Expand Up @@ -67,20 +70,37 @@ public List<ServerHistogramView> getNodeServerHistogramData() {
public List<HistogramView> getNodeHistogramData() {
final List<HistogramView> result = new ArrayList<>();
for (Node node : applicationMap.getNodes()) {
result.add(new HistogramView(node.getNodeName(), node.getNodeHistogram()));
HistogramView view = getNodeHistogramView(node);
result.add(view);
}
return result;
}

private HistogramView getNodeHistogramView(Node node) {
String nodeName = node.getNodeName().getName();
NodeHistogram nodeHistogram = node.getNodeHistogram();
Histogram histogram = nodeHistogram.getApplicationHistogram();
List<TimeHistogram> histogramList = nodeHistogram.getApplicationTimeHistogram().getHistogramList();
return new HistogramView(nodeName, histogram, histogramList);
}

@JsonIgnore
public List<HistogramView> getLinkHistogramData() {
final List<HistogramView> result = new ArrayList<>();
for (Link link : applicationMap.getLinks()) {
result.add(new HistogramView(link.getLinkName(), link.getHistogram(), link.getLinkApplicationTimeHistogram()));
HistogramView view = getLinkHistogramView(link);
result.add(view);
}
return result;
}

private HistogramView getLinkHistogramView(Link link) {
String linkName = link.getLinkName().getName();
Histogram histogram = link.getHistogram();
List<TimeHistogram> histogramList = link.getLinkApplicationTimeHistogram().getHistogramList();
return new HistogramView(linkName, histogram, histogramList);
}

@JsonIgnore
public Map<Application, ScatterData> getApplicationScatterDataMap() {
return applicationScatterDataMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.navercorp.pinpoint.web.applicationmap.histogram.Histogram;
import com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram;
import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram;
import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogramFormat;
import com.navercorp.pinpoint.web.view.NodeHistogramSummarySerializer;
import com.navercorp.pinpoint.web.view.TimeSeries.TimeSeriesView;
Expand All @@ -27,6 +28,7 @@
import com.navercorp.pinpoint.web.view.histogram.TimeHistogramType;
import com.navercorp.pinpoint.web.vo.Application;

import java.util.List;
import java.util.Objects;

/**
Expand Down Expand Up @@ -71,7 +73,10 @@ public void setTimeHistogramFormat(TimeHistogramFormat timeHistogramFormat) {
}

public HistogramView getHistogramView() {
return new HistogramView(NodeName.of(application), nodeHistogram);
String nodeName = NodeName.toNodeName(application.getName(), application.getServiceType());
Histogram applicationHistogram = nodeHistogram.getApplicationHistogram();
List<TimeHistogram> histogramList = nodeHistogram.getApplicationTimeHistogram().getHistogramList();
return new HistogramView(nodeName, applicationHistogram, histogramList);
}

public ServerHistogramView getAgentHistogramView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.navercorp.pinpoint.common.server.util.time.RangeValidator;
import com.navercorp.pinpoint.web.applicationmap.histogram.ApplicationTimeHistogram;
import com.navercorp.pinpoint.web.applicationmap.histogram.Histogram;
import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram;
import com.navercorp.pinpoint.web.applicationmap.link.LinkHistogramSummary;
import com.navercorp.pinpoint.web.applicationmap.nodes.NodeHistogramSummary;
import com.navercorp.pinpoint.web.applicationmap.service.ResponseTimeHistogramService;
Expand Down Expand Up @@ -251,7 +252,10 @@ public HistogramView getLinkHistogramData(
}

public HistogramView newHistogramView(LinkHistogramSummary summary) {
return new HistogramView(summary.getLinkName(), summary.getHistogram(), summary.getLinkApplicationTimeHistogram());
String linkName = summary.getLinkName().getName();
Histogram histogram = summary.getHistogram();
List<TimeHistogram> appHistogram = summary.getLinkApplicationTimeHistogram().getHistogramList();
return new HistogramView(linkName, histogram, appHistogram);
}

@GetMapping(value = "/getLink/{type}/chart")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import com.navercorp.pinpoint.web.applicationmap.histogram.ApdexScore;
import com.navercorp.pinpoint.web.applicationmap.histogram.ApplicationTimeHistogram;
import com.navercorp.pinpoint.web.applicationmap.histogram.Histogram;
import com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram;
import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram;
import com.navercorp.pinpoint.web.applicationmap.link.LinkName;
import com.navercorp.pinpoint.web.applicationmap.nodes.NodeName;
import com.navercorp.pinpoint.web.view.TimeSeries.TimeSeriesView;
import com.navercorp.pinpoint.web.vo.ResponseTimeStatics;

Expand All @@ -42,15 +38,6 @@ public HistogramView(String key, Histogram histogram, List<TimeHistogram> timeHi
this.sortedTimeHistograms = Objects.requireNonNull(timeHistograms, "timeHistograms");
}

public HistogramView(NodeName nodeName, NodeHistogram nodeHistogram) {
this(nodeName.getName(), nodeHistogram.getApplicationHistogram(), nodeHistogram.getApplicationTimeHistogram().getHistogramList());
}

public HistogramView(LinkName linkName, Histogram histogram, ApplicationTimeHistogram applicationTimeHistogram) {
this(linkName.getName(), histogram, applicationTimeHistogram.getHistogramList());
}


@JsonProperty("key")
public String getKey() {
return key;
Expand Down

0 comments on commit e8f0f49

Please sign in to comment.