forked from pinpoint-apm/pinpoint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pinpoint-apm#9380] Supports Line number and location in Callstack
Add Line number and location in APIMetaDataBO If Line number is null, value `0` location value is nullable * Warning:(91, 29) 'StringBuilder sb' can be replaced with 'String' * Hbase must save data with null because of saved data order * Add linenumber and location in TransactionInfoViewModel
- Loading branch information
Showing
24 changed files
with
1,141 additions
and
79 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
44 changes: 44 additions & 0 deletions
44
...tor/src/test/java/com/navercorp/pinpoint/collector/dao/hbase/HbaseApiMetaDataDaoTest.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,44 @@ | ||
package com.navercorp.pinpoint.collector.dao.hbase; | ||
|
||
import com.navercorp.pinpoint.common.hbase.HbaseColumnFamily; | ||
import com.navercorp.pinpoint.common.hbase.HbaseOperations2; | ||
import com.navercorp.pinpoint.common.hbase.TableNameProvider; | ||
import com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo; | ||
import com.navercorp.pinpoint.common.server.bo.MethodTypeEnum; | ||
import com.navercorp.pinpoint.common.server.hbase.DistributorConfiguration; | ||
import com.sematext.hbase.wd.RowKeyDistributorByHashPrefix; | ||
import org.apache.hadoop.hbase.Cell; | ||
import org.apache.hadoop.hbase.client.Put; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
|
||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.doAnswer; | ||
import static org.mockito.Mockito.mock; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class HbaseApiMetaDataDaoTest { | ||
|
||
// from node: ApiMetaDataBo{agentId='express-node-sample-id', startTime=1669280767548, apiId=12, apiInfo='express.Function.proto.get(path, callback)', lineNumber=169, methodTypeEnum=DEFAULT, location='/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/routes/index.js'} | ||
@Test | ||
public void testInsert() { | ||
HbaseOperations2 mockedHbaseTemplate = mock(HbaseOperations2.class); | ||
TableNameProvider mockedProvider = mock(TableNameProvider.class); | ||
DistributorConfiguration givenConfiguration = new DistributorConfiguration(); | ||
RowKeyDistributorByHashPrefix givenRowKeyDistributorByHashPrefix = givenConfiguration.getMetadataRowKeyDistributor(); | ||
HbaseApiMetaDataDao dut = new HbaseApiMetaDataDao(mockedHbaseTemplate, mockedProvider, givenRowKeyDistributorByHashPrefix); | ||
|
||
doAnswer((invocation) -> { | ||
Put actual = invocation.getArgument(1); | ||
List<Cell> actualCells = actual.get(HbaseColumnFamily.API_METADATA_API.getName(), HbaseColumnFamily.API_METADATA_API.QUALIFIER_SIGNATURE); | ||
assertThat(actualCells).hasSize(1); | ||
return null; | ||
}).when(mockedHbaseTemplate).put(any(), any(Put.class)); | ||
|
||
ApiMetaDataBo stub = new ApiMetaDataBo.Builder("express-node-sample-id", 1669280767548L, 12, 169, MethodTypeEnum.DEFAULT, "express.Function.proto.get(path, callback)") | ||
.setLocation("/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/routes/index.js") | ||
.build(); | ||
dut.insert(stub); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...c/test/java/com/navercorp/pinpoint/collector/handler/grpc/GrpcApiMetaDataHandlerTest.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,44 @@ | ||
package com.navercorp.pinpoint.collector.handler.grpc; | ||
|
||
import com.navercorp.pinpoint.collector.service.ApiMetaDataService; | ||
import com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo; | ||
import com.navercorp.pinpoint.common.server.bo.MethodTypeEnum; | ||
import com.navercorp.pinpoint.grpc.Header; | ||
import com.navercorp.pinpoint.grpc.server.ServerContext; | ||
import com.navercorp.pinpoint.grpc.trace.PApiMetaData; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.MockedStatic; | ||
import java.util.Collections; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.*; | ||
|
||
public class GrpcApiMetaDataHandlerTest { | ||
// ApiMetaDataBo{agentId='express-node-sample-id', startTime=1668495162817, apiId=11, apiInfo='express.Function.proto.get(path, callback)', lineNumber=177, methodTypeEnum=DEFAULT} | ||
// from Node agent [11, 'express.Function.proto.get(path, callback)', 24, null, '/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/routes/index.js'] | ||
@Test | ||
public void stubToApiMetaData() { | ||
ApiMetaDataService mockedService = mock(ApiMetaDataService.class); | ||
GrpcApiMetaDataHandler dut = new GrpcApiMetaDataHandler(mockedService); | ||
|
||
PApiMetaData actualStub = PApiMetaData.newBuilder() | ||
.setApiId(13) | ||
.setApiInfo("express.Function.proto.get(path, callback)") | ||
.setLine(177) | ||
.setType(MethodTypeEnum.DEFAULT.getCode()) | ||
.setLocation("/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/routes/index.js") | ||
.build(); | ||
try (MockedStatic<ServerContext> mocked = mockStatic(ServerContext.class)) { | ||
mocked.when(ServerContext::getAgentInfo).thenReturn(new Header("name", "express-node-sample-id", "agentName", "applicationName", 0, 1668495162817L, 0, Collections.emptyList())); | ||
doAnswer((invocation) -> { | ||
ApiMetaDataBo actual = invocation.getArgument(0); | ||
assertThat(actual).extracting("agentId", "startTime", "apiId", "apiInfo", "lineNumber", "methodTypeEnum", "location") | ||
.contains("express-node-sample-id", 1668495162817L, 13, "express.Function.proto.get(path, callback)", 177, MethodTypeEnum.DEFAULT, "/Users/workspace/pinpoint/@pinpoint-naver-apm/pinpoint-agent-node/samples/express/src/routes/index.js"); | ||
return null; | ||
}).when(mockedService).insert(any()); | ||
|
||
dut.handleApiMetaData(actualStub); | ||
|
||
mocked.verify(ServerContext::getAgentInfo); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
collector/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
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 @@ | ||
mock-maker-inline |
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.