Skip to content

Commit 24976b1

Browse files
committed
[#10882] Add ServiceName + ApplicationName based ServerMap
1 parent 12985cc commit 24976b1

38 files changed

+2157
-22
lines changed

agent-module/agent-testweb/pom.xml

+2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@
9090
<module>resilience4j-plugin-testweb</module>
9191
<module>closed-module-testweb</module>
9292
<module>closed-module-testlib</module>
93+
<module>spring-boot3-testweb</module>
94+
<module>spring-boot3-webflux-plugin-testweb</module>
9395
</modules>
9496

9597
<dependencyManagement>

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

+2-1
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

+1
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
"com.navercorp.pinpoint.collector.controller",
5354
})
5455
public class PinpointCollectorModule {
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 InboundDao extends CachedStatisticsDao {
25+
// src -> dest
26+
// inbound (rowKey dest <- columnName src)
27+
// outbound (rowKey src -> columnName dest)
28+
void update(
29+
String srcServiceName, String srcApplicationName, ServiceType srcApplicationType,
30+
String destServiceName, String destApplicationName, ServiceType destApplicationType,
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 OutboundDao extends CachedStatisticsDao {
25+
// src -> dest
26+
// inbound (rowKey dest <- columnName src)
27+
// outbound (rowKey src -> columnName dest)
28+
void update(
29+
String srcServiceName, String srcApplicationName, ServiceType srcApplicationType,
30+
String destServiceName, String destApplicationName, ServiceType destApplicationType,
31+
String srcHost, int elapsed, boolean isError
32+
);
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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 SelfDao extends CachedStatisticsDao {
25+
void received(String serviceName, String applicationName, ServiceType applicationType, int elapsed, boolean isError);
26+
void updatePing(String serviceName, String applicationName, ServiceType applicationType, int elapsed, boolean isError);
27+
}
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.InboundDao;
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.ApplicationMapColumnName;
25+
import com.navercorp.pinpoint.collector.applicationmap.dao.hbase.statistics.ApplicationMapRowKey;
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 HbaseInboundDao implements InboundDao {
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 HbaseInboundDao(
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 srcServiceName, String srcApplicationName, ServiceType srcApplicationType,
72+
String destServiceName, String destApplicationName, ServiceType destApplicationType,
73+
String srcHost, int elapsed, boolean isError
74+
) {
75+
Objects.requireNonNull(srcServiceName, "srcServiceName");
76+
Objects.requireNonNull(destServiceName, "destServiceName");
77+
Objects.requireNonNull(srcApplicationName, "srcApplicationName");
78+
Objects.requireNonNull(destServiceName, "destApplicationName");
79+
80+
if (logger.isDebugEnabled()) {
81+
logger.debug("[Inbound] {} {}({}) <- {} {}({})[{}]",
82+
destServiceName, destApplicationName, destApplicationType,
83+
srcServiceName, srcApplicationName, srcApplicationType, srcHost
84+
);
85+
}
86+
87+
88+
// TODO dest, src parameter normalization
89+
if (ignoreStatFilter.filter(srcApplicationType, srcHost)) {
90+
logger.debug("[Ignore-Inbound] {} {}({}) <- {} {}({})[{}]",
91+
destServiceName, destApplicationName, destApplicationType,
92+
srcServiceName, srcApplicationName, srcApplicationType, srcHost
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 ApplicationMapRowKey(destServiceName, destApplicationType.getCode(), destApplicationName, rowTimeSlot);
102+
103+
// columnName is src in outbound
104+
final short srcSlotNumber = ApplicationMapStatisticsUtils.getSlotNumber(srcApplicationType, elapsed, isError);
105+
HistogramSchema histogramSchema = srcApplicationType.getHistogramSchema();
106+
107+
final ColumnName srcColumnName = new ApplicationMapColumnName(srcServiceName, srcApplicationType.getCode(), srcApplicationName, srcSlotNumber);
108+
this.bulkWriter.increment(destRowKey, srcColumnName);
109+
110+
if (mapLinkConfiguration.isEnableAvg()) {
111+
final ColumnName sumColumnName = new ApplicationMapColumnName(srcServiceName, srcApplicationType.getCode(), srcApplicationName, histogramSchema.getSumStatSlot().getSlotTime());
112+
this.bulkWriter.increment(destRowKey, sumColumnName, elapsed);
113+
}
114+
if (mapLinkConfiguration.isEnableMax()) {
115+
final ColumnName maxColumnName = new ApplicationMapColumnName(srcServiceName, srcApplicationType.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,120 @@
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.OutboundDao;
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.ApplicationMapColumnName;
25+
import com.navercorp.pinpoint.collector.applicationmap.dao.hbase.statistics.ApplicationMapRowKey;
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 HbaseOutboundDao implements OutboundDao {
43+
44+
private final Logger logger = LogManager.getLogger(this.getClass());
45+
46+
private final AcceptedTimeService acceptedTimeService;
47+
48+
private final TimeSlot timeSlot;
49+
50+
private final BulkWriter bulkWriter;
51+
private final MapLinkConfiguration mapLinkConfiguration;
52+
53+
public HbaseOutboundDao(
54+
MapLinkConfiguration mapLinkConfiguration,
55+
IgnoreStatFilter ignoreStatFilter,
56+
AcceptedTimeService acceptedTimeService, TimeSlot timeSlot,
57+
@Qualifier("outboundBulkWriter") BulkWriter bulkWriter
58+
) {
59+
this.mapLinkConfiguration = Objects.requireNonNull(mapLinkConfiguration, "mapLinkConfiguration");
60+
this.acceptedTimeService = Objects.requireNonNull(acceptedTimeService, "acceptedTimeService");
61+
this.timeSlot = Objects.requireNonNull(timeSlot, "timeSlot");
62+
63+
this.bulkWriter = Objects.requireNonNull(bulkWriter, "outboundBulkWriter");
64+
}
65+
66+
67+
@Override
68+
public void update(
69+
String srcServiceName, String srcApplicationName, ServiceType srcApplicationType,
70+
String destServiceName, String destApplicationName, ServiceType destApplicationType,
71+
String srcHost, int elapsed, boolean isError
72+
) {
73+
// outbound (rowKey src -> columnName dest)
74+
Objects.requireNonNull(destServiceName, "destServiceName");
75+
Objects.requireNonNull(srcServiceName, "srcServiceName");
76+
Objects.requireNonNull(destApplicationName, "destApplicationName");
77+
Objects.requireNonNull(srcServiceName, "srcApplicationName");
78+
79+
if (logger.isDebugEnabled()) {
80+
logger.debug("[Outbound] {} {}({})[{}] -> {} {}({})",
81+
srcServiceName, srcApplicationName, srcApplicationType, srcHost,
82+
destServiceName, destApplicationName, destApplicationType
83+
);
84+
}
85+
86+
final long acceptedTime = acceptedTimeService.getAcceptedTime();
87+
final long rowTimeSlot = timeSlot.getTimeSlot(acceptedTime);
88+
89+
// rowKey is src in outbound
90+
final RowKey srcRowKey = new ApplicationMapRowKey(srcServiceName, srcApplicationType.getCode(), srcApplicationName, rowTimeSlot);
91+
92+
// columnName is dest in outbound
93+
final short destSlotNumber = ApplicationMapStatisticsUtils.getSlotNumber(destApplicationType, elapsed, isError);
94+
HistogramSchema histogramSchema = destApplicationType.getHistogramSchema();
95+
96+
final ColumnName destColumnName = new ApplicationMapColumnName(destServiceName, destApplicationType.getCode(), destApplicationName, destSlotNumber);
97+
this.bulkWriter.increment(srcRowKey, destColumnName);
98+
99+
if (mapLinkConfiguration.isEnableAvg()) {
100+
final ColumnName sumColumnName = new ApplicationMapColumnName(destServiceName, destApplicationType.getCode(), destApplicationName, histogramSchema.getSumStatSlot().getSlotTime());
101+
this.bulkWriter.increment(srcRowKey, sumColumnName, elapsed);
102+
}
103+
if (mapLinkConfiguration.isEnableMax()) {
104+
final ColumnName maxColumnName = new ApplicationMapColumnName(destServiceName, destApplicationType.getCode(), destApplicationName, histogramSchema.getMaxStatSlot().getSlotTime());
105+
this.bulkWriter.updateMax(srcRowKey, maxColumnName, elapsed);
106+
}
107+
}
108+
109+
110+
@Override
111+
public void flushLink() {
112+
this.bulkWriter.flushLink();
113+
}
114+
115+
@Override
116+
public void flushAvgMax() {
117+
this.bulkWriter.flushAvgMax();
118+
}
119+
120+
}

0 commit comments

Comments
 (0)