-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#10299] Adding network information for Pinpoint inspector
- Loading branch information
Showing
36 changed files
with
1,185 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...java/com/navercorp/pinpoint/collector/handler/grpc/metric/AgentProfilerMetricHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright 2023 NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.navercorp.pinpoint.collector.handler.grpc.metric; | ||
|
||
import com.google.protobuf.GeneratedMessageV3; | ||
import com.navercorp.pinpoint.collector.handler.grpc.GrpcMetricHandler; | ||
import com.navercorp.pinpoint.collector.mapper.grpc.stat.GrpcAgentProfilerMetricMapper; | ||
import com.navercorp.pinpoint.collector.service.AgentStatService; | ||
import com.navercorp.pinpoint.common.server.bo.stat.ProfilerMetricBo; | ||
import com.navercorp.pinpoint.grpc.MessageFormatUtils; | ||
import com.navercorp.pinpoint.grpc.trace.PProfilerMetric; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.Objects; | ||
|
||
@Service | ||
public class AgentProfilerMetricHandler implements GrpcMetricHandler { | ||
private final Logger logger = LogManager.getLogger(this.getClass()); | ||
private final GrpcAgentProfilerMetricMapper agentProfilerMetricMapper; | ||
private final AgentStatService[] agentStatServiceList; | ||
|
||
public AgentProfilerMetricHandler(GrpcAgentProfilerMetricMapper agentProfilerMetricMapper, | ||
AgentStatService[] agentStatServiceList) { | ||
this.agentProfilerMetricMapper = Objects.requireNonNull(agentProfilerMetricMapper, "agentProfilerMetricMapper"); | ||
this.agentStatServiceList = Objects.requireNonNull(agentStatServiceList, "agentStatServiceList"); | ||
|
||
for (AgentStatService service : this.agentStatServiceList) { | ||
logger.info("{}:{}", AgentStatService.class.getSimpleName(), service.getClass().getSimpleName()); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean accept(GeneratedMessageV3 message) { | ||
return message instanceof PProfilerMetric; | ||
} | ||
|
||
@Override | ||
public void handle(GeneratedMessageV3 message) { | ||
if (logger.isDebugEnabled()) { | ||
logger.debug("Handle PProfilerMetric={}", MessageFormatUtils.debugLog(message)); | ||
} | ||
|
||
final PProfilerMetric profilerMetric = (PProfilerMetric) message; | ||
final ProfilerMetricBo profilerMetricBo = this.agentProfilerMetricMapper.map(profilerMetric); | ||
if (profilerMetricBo == null) { | ||
return; | ||
} | ||
|
||
handleProfilerMetric(profilerMetricBo); | ||
} | ||
|
||
private void handleProfilerMetric(ProfilerMetricBo profilerMetricBo) { | ||
for (AgentStatService agentStatService : agentStatServiceList) { | ||
try { | ||
agentStatService.save(profilerMetricBo); | ||
} catch (Exception e) { | ||
logger.warn("Failed to handle service={}, AgentStatBo={}", agentStatService, profilerMetricBo, e); | ||
} | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...java/com/navercorp/pinpoint/collector/mapper/grpc/stat/GrpcAgentProfilerMetricMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright 2023 NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.navercorp.pinpoint.collector.mapper.grpc.stat; | ||
|
||
import com.navercorp.pinpoint.common.server.bo.stat.ProfilerMetricBo; | ||
import com.navercorp.pinpoint.grpc.Header; | ||
import com.navercorp.pinpoint.grpc.server.ServerContext; | ||
import com.navercorp.pinpoint.grpc.trace.PProfilerMetric; | ||
import com.navercorp.pinpoint.grpc.trace.PProfilerMetricField; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
|
||
@Component | ||
public class GrpcAgentProfilerMetricMapper { | ||
|
||
public ProfilerMetricBo map(PProfilerMetric profilerMetric) { | ||
if (profilerMetric == null) { | ||
return null; | ||
} | ||
|
||
final Header agentInfo = ServerContext.getAgentInfo(); | ||
final String agentId = agentInfo.getAgentId(); | ||
final long startTimestamp = agentInfo.getAgentStartTime(); | ||
|
||
final ProfilerMetricBo profilerMetricBo = new ProfilerMetricBo(); | ||
profilerMetricBo.setAgentId(agentId); | ||
profilerMetricBo.setStartTimestamp(startTimestamp); | ||
profilerMetricBo.setTimestamp(profilerMetric.getTimestamp()); | ||
profilerMetricBo.setMetricName(profilerMetric.getName()); | ||
|
||
List<PProfilerMetricField> tags = profilerMetric.getTagsList(); | ||
for (PProfilerMetricField tag : tags) { | ||
profilerMetricBo.addTags(tag.getName(), tag.getStringValue()); | ||
} | ||
|
||
List<PProfilerMetricField> fields = profilerMetric.getFieldsList(); | ||
for (PProfilerMetricField field : fields) { | ||
profilerMetricBo.addValues(field.getName(), field.getLongValue()); | ||
} | ||
|
||
return profilerMetricBo; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
...s-server/src/main/java/com/navercorp/pinpoint/common/server/bo/stat/ProfilerMetricBo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright 2023 NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.navercorp.pinpoint.common.server.bo.stat; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
public class ProfilerMetricBo implements AgentStatDataPoint { | ||
|
||
public static final long UNCOLLECTED_VALUE = -1; | ||
|
||
private String agentId; | ||
private long startTimestamp; | ||
private long timestamp; | ||
private String metricName; // is this necessary? | ||
private final Map<String, String> tags = new HashMap<>(); | ||
private final Map<String, Double> values = new HashMap<>(); | ||
|
||
@Override | ||
public String getAgentId() { | ||
return agentId; | ||
} | ||
|
||
@Override | ||
public void setAgentId(String agentId) { | ||
this.agentId = agentId; | ||
} | ||
|
||
@Override | ||
public long getStartTimestamp() { | ||
return startTimestamp; | ||
} | ||
|
||
@Override | ||
public void setStartTimestamp(long startTimestamp) { | ||
this.startTimestamp = startTimestamp; | ||
} | ||
|
||
@Override | ||
public long getTimestamp() { | ||
return timestamp; | ||
} | ||
|
||
@Override | ||
public void setTimestamp(long timestamp) { | ||
this.timestamp = timestamp; | ||
} | ||
|
||
@Override | ||
public AgentStatType getAgentStatType() { | ||
return AgentStatType.PROFILER_METRIC; | ||
} | ||
|
||
public void addTags(String name, String value) { | ||
tags.put(name, value); | ||
} | ||
|
||
public Map<String, String> getTags() { | ||
return tags; | ||
} | ||
|
||
public void addValues(String name, double value) { | ||
values.put(name, value); | ||
} | ||
|
||
public Map<String, Double> getValues() { | ||
return values; | ||
} | ||
|
||
public void setMetricName(String metricName) { | ||
this.metricName = Objects.requireNonNull(metricName); | ||
} | ||
|
||
public String getMetricName() { | ||
return metricName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.