Skip to content

Commit

Permalink
[pinpoint-apm#10704] deleted the logic operating based on a single ta…
Browse files Browse the repository at this point in the history
…ble and improved the multi-table operation to be the default
  • Loading branch information
minwoo-jung committed May 14, 2024
1 parent 1a66dbc commit 3162a68
Show file tree
Hide file tree
Showing 16 changed files with 93 additions and 503 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,11 @@
@Component
public class InspectorCollectorProperties {

@Value("${kafka.inspector.agent.topic.name}")
private String agentStatTopicName;
@Value("${kafka.inspector.agent.topic.count}")
private int agentStatTopicCount;
@Value("${kafka.inspector.application.topic.name}")
private String applicationStatTopicName;

public String getAgentStatTopicName() {
return agentStatTopicName;
}

public int getAgentStatTopicCount() {
return agentStatTopicCount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ public KafkaTemplate<String, AgentStat> kafkaAgentStatTemplate(@Qualifier("kafka
return new KafkaTemplate<>(producerFactory);
}

@Bean
public KafkaTemplate<String, AgentStat> kafkaAgentStatV2Template(@Qualifier("kafkaProducerFactory") ProducerFactory producerFactory) {
return new KafkaTemplate<>(producerFactory);
}

@Bean
public KafkaTemplate<String, ApplicationStat> kafkaApplicationStatTemplate(@Qualifier("kafkaProducerFactory") ProducerFactory producerFactory) {
return new KafkaTemplate<>(producerFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,25 @@ public class DefaultAgentStatDao <T extends AgentStatDataPoint> implements Agent
private final BiFunction<List<T>, String, List<AgentStat>> convertToKafkaAgentStatModelFunction;
private final Function<List<AgentStat>, List<ApplicationStat>> convertToKafkaApplicationStatModelFunction;
private final KafkaTemplate<String, AgentStat> kafkaAgentStatTemplate;
private final KafkaTemplate<String, AgentStat> kafkaAgentStatV2Template;
private final KafkaTemplate<String, ApplicationStat> kafkaApplicationStatTemplate;
private final String agentStatTopicName;
private final int agentStatTopicCount;
private final String applicationStatTopicName;
private final TenantProvider tenantProvider;

public DefaultAgentStatDao(Function<AgentStatBo,
List<T>> dataPointFunction,
KafkaTemplate<String, AgentStat> kafkaAgentStatTemplate,
KafkaTemplate<String, AgentStat> kafkaAgentStatV2Template,
KafkaTemplate<String, ApplicationStat> kafkaApplicationStatTemplate,
BiFunction<List<T>, String, List<AgentStat>> convertToKafkaAgentStatModelFunction,
Function<List<AgentStat>, List<ApplicationStat>> convertToKafkaApplicationStatModelFunction,
String agentStatTopicName,
int agentStatTopicCount,
String applicationStatTopicName,
TenantProvider tenantProvider) {
this.dataPointFunction = Objects.requireNonNull(dataPointFunction, "dataPointFunction");
this.kafkaAgentStatTemplate = Objects.requireNonNull(kafkaAgentStatTemplate, "kafkaAgentStatTemplate");
this.kafkaAgentStatV2Template = Objects.requireNonNull(kafkaAgentStatV2Template, "kafkaAgentStatV2Template");
this.kafkaApplicationStatTemplate = Objects.requireNonNull(kafkaApplicationStatTemplate, "kafkaApplicationStatTemplate");
this.convertToKafkaAgentStatModelFunction = Objects.requireNonNull(convertToKafkaAgentStatModelFunction, "convertToKafkaAgentStatModelFunction");
this.convertToKafkaApplicationStatModelFunction = Objects.requireNonNull(convertToKafkaApplicationStatModelFunction, "convertToKafkaApplicationStatModelFunction");
this.agentStatTopicName = StringPrecondition.requireHasLength(agentStatTopicName, "agentStatTopic");
this.agentStatTopicCount = agentStatTopicCount;
this.applicationStatTopicName = StringPrecondition.requireHasLength(applicationStatTopicName, "applicationStatTopic");
this.tenantProvider = Objects.requireNonNull(tenantProvider, "tenantProvider");
Expand All @@ -84,14 +78,10 @@ public void insert(String applicationName, String agentId, List<T> agentStatData
};

List<AgentStat> agentStatList = convertToKafkaAgentStatModel(agentStatData);
for (AgentStat agentStat : agentStatList) {
kafkaAgentStatTemplate.send(agentStatTopicName, agentStat.getSortKey(), agentStat);
}


String topicName = AgentStatTopicAndTableNameManager.getAgentStatTopicName(applicationName, agentStatTopicCount);

for (AgentStat agentStat : agentStatList) {
kafkaAgentStatV2Template.send(topicName, agentStat.getSortKey(), agentStat);
kafkaAgentStatTemplate.send(topicName, agentStat.getSortKey(), agentStat);
}

List<ApplicationStat> applicationStatList = convertToKafkaApplicationStatModel(agentStatList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,22 @@
public class PinotDaoConfiguration {

private final KafkaTemplate<String, AgentStat> kafkaAgentStatTemplate;
private final KafkaTemplate<String, AgentStat> kafkaAgentStatV2Template;
private final KafkaTemplate<String, ApplicationStat> kafkaApplicationStatTemplate;
private final String agentStatTopicName;
private final int agentStatTopicCount;
private final String applicationStatTopicName;
private final TenantProvider tenantProvider;

public PinotDaoConfiguration(KafkaTemplate<String, AgentStat> kafkaAgentStatTemplate, KafkaTemplate<String, AgentStat> kafkaAgentStatV2Template, KafkaTemplate<String, ApplicationStat> kafkaApplicationStatTemplate, InspectorCollectorProperties inspectorCollectorProperties, TenantProvider tenantProvider) {
public PinotDaoConfiguration(KafkaTemplate<String, AgentStat> kafkaAgentStatTemplate, KafkaTemplate<String, ApplicationStat> kafkaApplicationStatTemplate, InspectorCollectorProperties inspectorCollectorProperties, TenantProvider tenantProvider) {
this.kafkaAgentStatTemplate = Objects.requireNonNull(kafkaAgentStatTemplate, "kafkaAgentStatTemplate");
this.kafkaAgentStatV2Template = Objects.requireNonNull(kafkaAgentStatV2Template, "kafkaAgentStatV2Template");
this.kafkaApplicationStatTemplate = Objects.requireNonNull(kafkaApplicationStatTemplate, "kafkaApplicationStatTemplate");
Objects.requireNonNull(inspectorCollectorProperties, "inspectorCollectorProperties");
this.agentStatTopicName = inspectorCollectorProperties.getAgentStatTopicName();
this.agentStatTopicCount = inspectorCollectorProperties.getAgentStatTopicCount();
this.applicationStatTopicName = inspectorCollectorProperties.getApplicationStatTopicName();
this.tenantProvider = Objects.requireNonNull(tenantProvider, "tenantProvider");
}

private <T extends AgentStatDataPoint> AgentStatDao<T> newAgentStatDao(Function<AgentStatBo, List<T>> dataPointFunction, BiFunction<List<T>, String, List<AgentStat>> convertToAgentStat, Function<List<AgentStat>, List<ApplicationStat>> convertToKafkaApplicationStat) {
return new DefaultAgentStatDao(dataPointFunction, kafkaAgentStatTemplate, kafkaAgentStatV2Template, kafkaApplicationStatTemplate, convertToAgentStat, convertToKafkaApplicationStat, agentStatTopicName, agentStatTopicCount, applicationStatTopicName, tenantProvider);
return new DefaultAgentStatDao(dataPointFunction, kafkaAgentStatTemplate, kafkaApplicationStatTemplate, convertToAgentStat, convertToKafkaApplicationStat, agentStatTopicCount, applicationStatTopicName, tenantProvider);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
kafka.inspector.agent.topic.name=inspector-stat

kafka.inspector.application.topic.name=inspector-stat-app
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.navercorp.pinpoint.common.model.TagInformation;
import com.navercorp.pinpoint.common.dao.pinot.MultiValueTagTypeHandler;
import com.navercorp.pinpoint.inspector.web.dao.model.InspectorQueryParameter;
import com.navercorp.pinpoint.inspector.web.dao.model.InspectorQueryParameterV2;
import com.navercorp.pinpoint.metric.common.config.CommonRegistryHandler;
import com.navercorp.pinpoint.metric.common.model.Tag;
import com.navercorp.pinpoint.metric.common.model.chart.AvgMinMaxMetricPoint;
Expand Down Expand Up @@ -52,7 +51,6 @@ public void registerTypeAlias(TypeAliasRegistry typeAliasRegistry) {
typeAliasRegistry.registerAlias(MinMaxMetricPoint.class);
typeAliasRegistry.registerAlias(AvgMinMetricPoint.class);
typeAliasRegistry.registerAlias(InspectorQueryParameter.class);
typeAliasRegistry.registerAlias(InspectorQueryParameterV2.class);
typeAliasRegistry.registerAlias("DoubleHandler", DoubleTypeHandler.class);
typeAliasRegistry.registerAlias(TagInformation.class);
typeAliasRegistry.registerAlias(MultiValueTagTypeHandler.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,13 @@ public InspectorMetricView getAgentStatChart(
@RequestParam("agentId") String agentId,
@RequestParam("metricDefinitionId") String metricDefinitionId,
@RequestParam("from") long from,
@RequestParam("to") long to,
@RequestParam(value = "version", defaultValue = "1") int version) {
@RequestParam("to") long to) {
Range range = Range.between(from, to);
rangeValidator.validate(range.getFromInstant(), range.getToInstant());

String tenantId = tenantProvider.getTenantId();
TimeWindow timeWindow = getTimeWindow(range);
InspectorDataSearchKey inspectorDataSearchKey = new InspectorDataSearchKey(tenantId, applicationName, agentId, metricDefinitionId, timeWindow, version);
InspectorDataSearchKey inspectorDataSearchKey = new InspectorDataSearchKey(tenantId, applicationName, agentId, metricDefinitionId, timeWindow);

InspectorMetricData inspectorMetricData = agentStatService.selectAgentStat(inspectorDataSearchKey, timeWindow);
return new InspectorMetricView(inspectorMetricData);
Expand All @@ -85,8 +84,7 @@ public InspectorMetricView getApdexStatChart(
@RequestParam("agentId") String agentId,
@RequestParam("metricDefinitionId") String metricDefinitionId,
@RequestParam("from") long from,
@RequestParam("to") long to,
@RequestParam(value = "version", defaultValue = "1") int version) {
@RequestParam("to") long to) {
Range range = Range.between(from, to);
rangeValidator.validate(range.getFromInstant(), range.getToInstant());

Expand All @@ -100,14 +98,13 @@ public InspectorMetricGroupDataView getAgentStatChartList(
@RequestParam("agentId") String agentId,
@RequestParam("metricDefinitionId") String metricDefinitionId,
@RequestParam("from") long from,
@RequestParam("to") long to,
@RequestParam(value = "version", defaultValue = "1") int version) {
@RequestParam("to") long to) {
Range range = Range.between(from, to);
rangeValidator.validate(range.getFromInstant(), range.getToInstant());

String tenantId = tenantProvider.getTenantId();
TimeWindow timeWindow = getTimeWindow(range);
InspectorDataSearchKey inspectorDataSearchKey = new InspectorDataSearchKey(tenantId, applicationName, agentId, metricDefinitionId, timeWindow, version);
InspectorDataSearchKey inspectorDataSearchKey = new InspectorDataSearchKey(tenantId, applicationName, agentId, metricDefinitionId, timeWindow);

InspectorMetricGroupData inspectorMetricGroupData = agentStatService.selectAgentStatWithGrouping(inspectorDataSearchKey, timeWindow);
return new InspectorMetricGroupDataView(inspectorMetricGroupData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.navercorp.pinpoint.inspector.web.dao.model;

import com.navercorp.pinpoint.common.server.util.StringPrecondition;
import com.navercorp.pinpoint.common.server.util.time.Range;
import com.navercorp.pinpoint.inspector.web.model.InspectorDataSearchKey;
import com.navercorp.pinpoint.metric.common.model.Tag;
Expand All @@ -31,33 +32,43 @@
// TODO : (minwoo) Need to integrate with com.navercorp.pinpoint.metric.web.dao.model.SystemMetricDataSearchKey of metric module
public class InspectorQueryParameter {

private final static String DEFAULT_TABLE_NAME = "tableName";
private final String tenantId;
private final String tableName;
private final String applicationName;
private final String sortKey;
private final String agentId;
private final String metricName;
private final String fieldName;
private final List<Tag> tagList;

private final Range range;
private final TimePrecision timePrecision;
private final long limit;

private final String sortKey;

public InspectorQueryParameter(InspectorDataSearchKey inspectorDataSearchKey, String sortKey, String metricName, String fieldName) {
this(inspectorDataSearchKey, sortKey, metricName, fieldName, Collections.emptyList());
this(inspectorDataSearchKey, DEFAULT_TABLE_NAME, sortKey, metricName, fieldName, Collections.emptyList());
}

public InspectorQueryParameter(InspectorDataSearchKey inspectorDataSearchKey, String tableName, String sortKey, String metricName, String fieldName) {
this(inspectorDataSearchKey, tableName, sortKey, metricName, fieldName, Collections.emptyList());
}

public InspectorQueryParameter(InspectorDataSearchKey inspectorDataSearchKey, String sortKey, String metricName, String fieldName, List<Tag> tagList) {
this(inspectorDataSearchKey, DEFAULT_TABLE_NAME, sortKey, metricName, fieldName, tagList);
}

public InspectorQueryParameter(InspectorDataSearchKey inspectorDataSearchKey, String tableName, String sortKey, String metricName, String fieldName, List<Tag> tagList) {
Objects.requireNonNull(inspectorDataSearchKey, "inspectorDataSearchKey");

this.tenantId = inspectorDataSearchKey.getTenantId();
this.sortKey = sortKey;
this.tableName = StringPrecondition.requireHasLength(tableName, "tableName");
this.sortKey = StringPrecondition.requireHasLength(sortKey, "sortKey");
this.applicationName = inspectorDataSearchKey.getApplicationName();
this.agentId = inspectorDataSearchKey.getAgentId();
this.metricName = metricName;
this.fieldName = fieldName;
this.tagList = tagList;
this.metricName = StringPrecondition.requireHasLength(metricName, "metricName");
this.fieldName = StringPrecondition.requireHasLength(fieldName, "fieldName");
this.tagList = Objects.requireNonNull(tagList, "tagList");
this.range = inspectorDataSearchKey.getRange();
this.timePrecision = inspectorDataSearchKey.getTimePrecision();
this.limit = inspectorDataSearchKey.getLimit();
Expand All @@ -67,6 +78,10 @@ public String getTenantId() {
return tenantId;
}

public String getTableName() {
return tableName;
}

public String getAgentId() {
return agentId;
}
Expand Down Expand Up @@ -103,11 +118,26 @@ public String getSortKey() {
return sortKey;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
InspectorQueryParameter that = (InspectorQueryParameter) o;
return limit == that.limit && Objects.equals(tenantId, that.tenantId) && Objects.equals(tableName, that.tableName) && Objects.equals(applicationName, that.applicationName) && Objects.equals(sortKey, that.sortKey) && Objects.equals(agentId, that.agentId) && Objects.equals(metricName, that.metricName) && Objects.equals(fieldName, that.fieldName) && Objects.equals(tagList, that.tagList) && Objects.equals(range, that.range) && Objects.equals(timePrecision, that.timePrecision);
}

@Override
public int hashCode() {
return Objects.hash(tenantId, tableName, applicationName, sortKey, agentId, metricName, fieldName, tagList, range, timePrecision, limit);
}

@Override
public String toString() {
return "InspectorQueryParameter{" +
return "InspectorQueryParameterV2{" +
"tenantId='" + tenantId + '\'' +
", tableName='" + tableName + '\'' +
", applicationName='" + applicationName + '\'' +
", sortKey='" + sortKey + '\'' +
", agentId='" + agentId + '\'' +
", metricName='" + metricName + '\'' +
", fieldName='" + fieldName + '\'' +
Expand All @@ -117,12 +147,6 @@ public String toString() {
", rangeTo=" + range.getTo() +
", timePrecision=" + timePrecision +
", limit=" + limit +
", sortKey='" + sortKey + '\'' +
'}';
}

@Override
public int hashCode() {
return Objects.hash(tenantId, applicationName, agentId, metricName, fieldName, tagList, range, timePrecision, limit, sortKey);
}
}
Loading

0 comments on commit 3162a68

Please sign in to comment.