Skip to content

Commit 0d614cb

Browse files
committed
[pinpoint-apm#10882] Add ServiceName + ApplicationName based ServerMap
1 parent b16b52e commit 0d614cb

File tree

38 files changed

+2203
-19
lines changed

38 files changed

+2203
-19
lines changed

collector/src/main/java/com/navercorp/pinpoint/collector/CollectorHbaseModule.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
SchedulerConfiguration.class,
3636
})
3737
@ComponentScan({
38-
"com.navercorp.pinpoint.collector.dao.hbase"
38+
"com.navercorp.pinpoint.collector.dao.hbase",
39+
"com.navercorp.pinpoint.collector.applicationmap.dao.hbase"
3940
})
4041
@PropertySource(name = "CollectorHbaseModule", value = {
4142
"classpath:hbase-root.properties",

collector/src/main/java/com/navercorp/pinpoint/collector/PinpointCollectorModule.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"com.navercorp.pinpoint.collector.mapper",
5050
"com.navercorp.pinpoint.collector.util",
5151
"com.navercorp.pinpoint.collector.service",
52+
"com.navercorp.pinpoint.collector.applicationmap.service",
5253
})
5354
public class PinpointCollectorModule {
5455

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2024 NAVER Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.navercorp.pinpoint.collector.applicationmap.dao;
17+
18+
import com.navercorp.pinpoint.collector.dao.CachedStatisticsDao;
19+
import com.navercorp.pinpoint.common.trace.ServiceType;
20+
21+
/**
22+
* @author intr3p1d
23+
*/
24+
public interface MapStatisticsInboundDao extends CachedStatisticsDao {
25+
// src -> dest
26+
// inbound (rowKey dest <- columnName src)
27+
// outbound (rowKey src -> columnName dest)
28+
void update(
29+
String srcServiceGroupName, String srcApplicationName, ServiceType srcServiceType,
30+
String destServiceGroupName, String destApplicationName, ServiceType destServiceType,
31+
String srcHost, int elapsed, boolean isError
32+
);
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2024 NAVER Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.navercorp.pinpoint.collector.applicationmap.dao;
17+
18+
import com.navercorp.pinpoint.collector.dao.CachedStatisticsDao;
19+
import com.navercorp.pinpoint.common.trace.ServiceType;
20+
21+
/**
22+
* @author intr3p1d
23+
*/
24+
public interface MapStatisticsOutboundDao extends CachedStatisticsDao {
25+
// src -> dest
26+
// inbound (rowKey dest <- columnName src)
27+
// outbound (rowKey src -> columnName dest)
28+
void update(
29+
String srcServiceGroupName, String srcApplicationName, ServiceType srcServiceType,
30+
String destServiceGroupName, ServiceType destServiceType, String destApplicationName,
31+
String srcHost, int elapsed, boolean isError
32+
);
33+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2024 NAVER Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.navercorp.pinpoint.collector.applicationmap.dao;
17+
18+
import com.navercorp.pinpoint.collector.dao.CachedStatisticsDao;
19+
import com.navercorp.pinpoint.common.trace.ServiceType;
20+
21+
/**
22+
* @author intr3p1d
23+
*/
24+
public interface MapStatisticsSelfDao extends CachedStatisticsDao {
25+
void received(String serviceGroup, String applicationName, ServiceType serviceType, int elapsed, boolean isError);
26+
27+
void updatePing(String serviceGroup, String applicationName, ServiceType serviceType, int elapsed, boolean isError);
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/*
2+
* Copyright 2024 NAVER Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.navercorp.pinpoint.collector.applicationmap.dao.hbase;
17+
18+
import com.navercorp.pinpoint.collector.applicationmap.dao.MapStatisticsInboundDao;
19+
import com.navercorp.pinpoint.collector.dao.hbase.IgnoreStatFilter;
20+
import com.navercorp.pinpoint.collector.dao.hbase.statistics.BulkWriter;
21+
import com.navercorp.pinpoint.collector.dao.hbase.statistics.ColumnName;
22+
import com.navercorp.pinpoint.collector.dao.hbase.statistics.MapLinkConfiguration;
23+
import com.navercorp.pinpoint.collector.dao.hbase.statistics.RowKey;
24+
import com.navercorp.pinpoint.collector.applicationmap.dao.hbase.statistics.ServiceGroupColumnName;
25+
import com.navercorp.pinpoint.collector.applicationmap.dao.hbase.statistics.ServiceGroupRowKey;
26+
import com.navercorp.pinpoint.common.server.util.AcceptedTimeService;
27+
import com.navercorp.pinpoint.common.server.util.ApplicationMapStatisticsUtils;
28+
import com.navercorp.pinpoint.common.server.util.TimeSlot;
29+
import com.navercorp.pinpoint.common.trace.HistogramSchema;
30+
import com.navercorp.pinpoint.common.trace.ServiceType;
31+
import org.apache.logging.log4j.LogManager;
32+
import org.apache.logging.log4j.Logger;
33+
import org.springframework.beans.factory.annotation.Qualifier;
34+
import org.springframework.stereotype.Repository;
35+
36+
import java.util.Objects;
37+
38+
/**
39+
* @author intr3p1d
40+
*/
41+
@Repository
42+
public class HbaseMapStatisticsInboundDao implements MapStatisticsInboundDao {
43+
44+
private final Logger logger = LogManager.getLogger(this.getClass());
45+
46+
private final AcceptedTimeService acceptedTimeService;
47+
48+
private final TimeSlot timeSlot;
49+
private final IgnoreStatFilter ignoreStatFilter;
50+
private final BulkWriter bulkWriter;
51+
private final MapLinkConfiguration mapLinkConfiguration;
52+
53+
public HbaseMapStatisticsInboundDao(
54+
MapLinkConfiguration mapLinkConfiguration,
55+
IgnoreStatFilter ignoreStatFilter,
56+
AcceptedTimeService acceptedTimeService,
57+
TimeSlot timeSlot,
58+
@Qualifier("inboundBulkWriter") BulkWriter bulkWriter
59+
) {
60+
this.mapLinkConfiguration = Objects.requireNonNull(mapLinkConfiguration, "mapLinkConfiguration");
61+
this.ignoreStatFilter = Objects.requireNonNull(ignoreStatFilter, "ignoreStatFilter");
62+
this.acceptedTimeService = Objects.requireNonNull(acceptedTimeService, "acceptedTimeService");
63+
this.timeSlot = Objects.requireNonNull(timeSlot, "timeSlot");
64+
65+
this.bulkWriter = Objects.requireNonNull(bulkWriter, "inboundBulkWriter");
66+
}
67+
68+
69+
@Override
70+
public void update(
71+
String srcServiceGroupName, String srcApplicationName, ServiceType srcServiceType,
72+
String destServiceGroupName, String destApplicationName, ServiceType destServiceType,
73+
String srcHost, int elapsed, boolean isError
74+
) {
75+
Objects.requireNonNull(srcServiceGroupName, "srcServiceGroupName");
76+
Objects.requireNonNull(destServiceGroupName, "destServiceGroupName");
77+
Objects.requireNonNull(srcApplicationName, "srcApplicationName");
78+
Objects.requireNonNull(destServiceGroupName, "destApplicationName");
79+
80+
if (logger.isDebugEnabled()) {
81+
logger.debug("[Inbound] {} {}({})[{}] <- {} {}({})",
82+
destServiceGroupName, destApplicationName, destServiceType, srcHost,
83+
srcServiceGroupName, srcApplicationName, srcServiceType
84+
);
85+
}
86+
87+
88+
// TODO dest, src parameter normalization
89+
if (ignoreStatFilter.filter(srcServiceType, srcHost)) {
90+
logger.debug("[Ignore-Inbound] {} {}({})[{}] <- {} {}({})",
91+
destServiceGroupName, destApplicationName, destServiceType, srcHost,
92+
srcServiceGroupName, srcApplicationName, srcServiceType
93+
);
94+
return;
95+
}
96+
97+
final long acceptedTime = acceptedTimeService.getAcceptedTime();
98+
final long rowTimeSlot = timeSlot.getTimeSlot(acceptedTime);
99+
100+
// rowKey is dest in inbound
101+
final RowKey destRowKey = new ServiceGroupRowKey(destServiceGroupName, destServiceType.getCode(), destApplicationName, rowTimeSlot);
102+
103+
// columnName is src in outbound
104+
final short srcSlotNumber = ApplicationMapStatisticsUtils.getSlotNumber(srcServiceType, elapsed, isError);
105+
HistogramSchema histogramSchema = srcServiceType.getHistogramSchema();
106+
107+
final ColumnName srcColumnName = new ServiceGroupColumnName(srcServiceGroupName, srcServiceType.getCode(), srcApplicationName, srcSlotNumber);
108+
this.bulkWriter.increment(destRowKey, srcColumnName);
109+
110+
if (mapLinkConfiguration.isEnableAvg()) {
111+
final ColumnName sumColumnName = new ServiceGroupColumnName(srcServiceGroupName, srcServiceType.getCode(), srcApplicationName, histogramSchema.getSumStatSlot().getSlotTime());
112+
this.bulkWriter.increment(destRowKey, sumColumnName, elapsed);
113+
}
114+
if (mapLinkConfiguration.isEnableMax()) {
115+
final ColumnName maxColumnName = new ServiceGroupColumnName(srcServiceGroupName, srcServiceType.getCode(), srcApplicationName, histogramSchema.getMaxStatSlot().getSlotTime());
116+
this.bulkWriter.updateMax(destRowKey, maxColumnName, elapsed);
117+
}
118+
119+
}
120+
121+
@Override
122+
public void flushLink() {
123+
this.bulkWriter.flushLink();
124+
}
125+
126+
@Override
127+
public void flushAvgMax() {
128+
this.bulkWriter.flushAvgMax();
129+
}
130+
131+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/*
2+
* Copyright 2024 NAVER Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.navercorp.pinpoint.collector.applicationmap.dao.hbase;
17+
18+
import com.navercorp.pinpoint.collector.applicationmap.dao.MapStatisticsOutboundDao;
19+
import com.navercorp.pinpoint.collector.dao.hbase.IgnoreStatFilter;
20+
import com.navercorp.pinpoint.collector.dao.hbase.statistics.BulkWriter;
21+
import com.navercorp.pinpoint.collector.dao.hbase.statistics.ColumnName;
22+
import com.navercorp.pinpoint.collector.dao.hbase.statistics.MapLinkConfiguration;
23+
import com.navercorp.pinpoint.collector.dao.hbase.statistics.RowKey;
24+
import com.navercorp.pinpoint.collector.applicationmap.dao.hbase.statistics.ServiceGroupColumnName;
25+
import com.navercorp.pinpoint.collector.applicationmap.dao.hbase.statistics.ServiceGroupRowKey;
26+
import com.navercorp.pinpoint.common.server.util.AcceptedTimeService;
27+
import com.navercorp.pinpoint.common.server.util.ApplicationMapStatisticsUtils;
28+
import com.navercorp.pinpoint.common.server.util.TimeSlot;
29+
import com.navercorp.pinpoint.common.trace.HistogramSchema;
30+
import com.navercorp.pinpoint.common.trace.ServiceType;
31+
import org.apache.commons.lang3.StringUtils;
32+
import org.apache.logging.log4j.LogManager;
33+
import org.apache.logging.log4j.Logger;
34+
import org.springframework.beans.factory.annotation.Qualifier;
35+
import org.springframework.stereotype.Repository;
36+
37+
import java.util.Objects;
38+
39+
/**
40+
* @author intr3p1d
41+
*/
42+
@Repository
43+
public class HbaseMapStatisticsOutboundDao implements MapStatisticsOutboundDao {
44+
45+
private final Logger logger = LogManager.getLogger(this.getClass());
46+
47+
private final AcceptedTimeService acceptedTimeService;
48+
49+
private final TimeSlot timeSlot;
50+
51+
private final BulkWriter bulkWriter;
52+
private final MapLinkConfiguration mapLinkConfiguration;
53+
54+
public HbaseMapStatisticsOutboundDao(
55+
MapLinkConfiguration mapLinkConfiguration,
56+
IgnoreStatFilter ignoreStatFilter,
57+
AcceptedTimeService acceptedTimeService, TimeSlot timeSlot,
58+
@Qualifier("outboundBulkWriter") BulkWriter bulkWriter
59+
) {
60+
this.mapLinkConfiguration = Objects.requireNonNull(mapLinkConfiguration, "mapLinkConfiguration");
61+
this.acceptedTimeService = Objects.requireNonNull(acceptedTimeService, "acceptedTimeService");
62+
this.timeSlot = Objects.requireNonNull(timeSlot, "timeSlot");
63+
64+
this.bulkWriter = Objects.requireNonNull(bulkWriter, "outboundBulkWriter");
65+
}
66+
67+
68+
@Override
69+
public void update(
70+
String srcServiceGroupName, String srcApplicationName, ServiceType srcServiceType, String destServiceGroupName, ServiceType destServiceType, String destApplicationName,
71+
String srcHost, int elapsed, boolean isError
72+
) {
73+
// outbound (rowKey src -> columnName dest)
74+
Objects.requireNonNull(destServiceGroupName, "destServiceGroupName");
75+
Objects.requireNonNull(srcServiceGroupName, "srcServiceGroupName");
76+
Objects.requireNonNull(destApplicationName, "destApplicationName");
77+
Objects.requireNonNull(srcServiceGroupName, "srcApplicationName");
78+
79+
if (logger.isDebugEnabled()) {
80+
logger.debug("[Outbound] {} {}({})[{}] -> {} {}({})",
81+
srcServiceGroupName, srcApplicationName, srcServiceType, srcHost,
82+
destServiceGroupName, destApplicationName, destServiceType
83+
);
84+
}
85+
86+
// there may be no endpoint in case of httpclient
87+
srcHost = StringUtils.defaultString(srcHost);
88+
89+
final long acceptedTime = acceptedTimeService.getAcceptedTime();
90+
final long rowTimeSlot = timeSlot.getTimeSlot(acceptedTime);
91+
92+
// rowKey is src in outbound
93+
final RowKey srcRowKey = new ServiceGroupRowKey(srcServiceGroupName, srcServiceType.getCode(), srcApplicationName, rowTimeSlot);
94+
95+
// columnName is dest in outbound
96+
final short destSlotNumber = ApplicationMapStatisticsUtils.getSlotNumber(destServiceType, elapsed, isError);
97+
HistogramSchema histogramSchema = destServiceType.getHistogramSchema();
98+
99+
final ColumnName destColumnName = new ServiceGroupColumnName(destServiceGroupName, destServiceType.getCode(), destApplicationName, destSlotNumber);
100+
this.bulkWriter.increment(srcRowKey, destColumnName);
101+
102+
if (mapLinkConfiguration.isEnableAvg()) {
103+
final ColumnName sumColumnName = new ServiceGroupColumnName(destServiceGroupName, destServiceType.getCode(), destApplicationName, histogramSchema.getSumStatSlot().getSlotTime());
104+
this.bulkWriter.increment(srcRowKey, sumColumnName, elapsed);
105+
}
106+
if (mapLinkConfiguration.isEnableMax()) {
107+
final ColumnName maxColumnName = new ServiceGroupColumnName(destServiceGroupName, destServiceType.getCode(), destApplicationName, histogramSchema.getMaxStatSlot().getSlotTime());
108+
this.bulkWriter.updateMax(srcRowKey, maxColumnName, elapsed);
109+
}
110+
}
111+
112+
113+
@Override
114+
public void flushLink() {
115+
this.bulkWriter.flushLink();
116+
}
117+
118+
@Override
119+
public void flushAvgMax() {
120+
this.bulkWriter.flushAvgMax();
121+
}
122+
123+
}

0 commit comments

Comments
 (0)