use of com.navercorp.pinpoint.common.util.ApiDescription in project pinpoint by naver.
the class ApiDescriptionParserTest method parseNoArgs.
@Test
public void parseNoArgs() {
String api = "a.StandardHostValve.invoke()";
ApiDescription result = apiParser.parse(api);
Assert.assertEquals("a.StandardHostValve", result.getClassName());
Assert.assertEquals("StandardHostValve", result.getSimpleClassName());
Assert.assertEquals("a", result.getPackageNameName());
Assert.assertEquals("invoke", result.getMethodName());
Assert.assertEquals("invoke()", result.getSimpleMethodDescription());
Assert.assertEquals("StandardHostValve", result.getSimpleClassName());
Assert.assertArrayEquals(new String[] {}, result.getSimpleParameter());
}
use of com.navercorp.pinpoint.common.util.ApiDescription in project pinpoint by naver.
the class ApiDescriptionParserTest method parse.
@Test
public void parse() {
// org.springframework.web.servlet.FrameworkServlet.doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
// com.mysql.jdbc.ConnectionImpl.setAutoCommit(boolean autoCommitFlag)
// com.mysql.jdbc.ConnectionImpl.commit()
// org.apache.catalina.core.StandardHostValve.invoke(org.apache.catalina.connector.Request request, org.apache.catalina.connector.Response response):110
String api = "a.StandardHostValve.invoke(b.Request request, b.Response response)";
ApiDescription result = apiParser.parse(api);
Assert.assertEquals("a.StandardHostValve", result.getClassName());
Assert.assertEquals("StandardHostValve", result.getSimpleClassName());
Assert.assertEquals("a", result.getPackageNameName());
Assert.assertEquals("invoke", result.getMethodName());
Assert.assertEquals("invoke(Request request, Response response)", result.getSimpleMethodDescription());
Assert.assertEquals("StandardHostValve", result.getSimpleClassName());
Assert.assertArrayEquals(new String[] { "Request request", "Response response" }, result.getSimpleParameter());
}
use of com.navercorp.pinpoint.common.util.ApiDescription in project pinpoint by naver.
the class RecordFactory method getApi.
private Api getApi(final SpanAlign align) {
final AnnotationBo annotation = AnnotationUtils.findAnnotationBo(align.getAnnotationBoList(), AnnotationKey.API_METADATA);
if (annotation != null) {
final Api api = new Api();
final ApiMetaDataBo apiMetaData = (ApiMetaDataBo) annotation.getValue();
String apiInfo = getApiInfo(apiMetaData);
api.setTitle(apiInfo);
api.setDescription(apiInfo);
if (apiMetaData.getMethodTypeEnum() == MethodTypeEnum.DEFAULT) {
try {
ApiDescription apiDescription = apiDescriptionParser.parse(api.description);
api.setTitle(apiDescription.getSimpleMethodDescription());
api.setClassName(apiDescription.getSimpleClassName());
} catch (Exception e) {
logger.debug("Failed to api parse. {}", api.description, e);
}
}
api.setMethodTypeEnum(apiMetaData.getMethodTypeEnum());
return api;
} else {
final Api api = new Api();
AnnotationKey apiMetaDataError = getApiMetaDataError(align.getAnnotationBoList());
api.setTitle(apiMetaDataError.getName());
return api;
}
}
use of com.navercorp.pinpoint.common.util.ApiDescription in project pinpoint by naver.
the class ApiDescriptionParser method parse.
// org.springframework.web.servlet.FrameworkServlet.doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
// com.mysql.jdbc.ConnectionImpl.setAutoCommit(boolean autoCommitFlag)
// com.mysql.jdbc.ConnectionImpl.commit()
// org.apache.catalina.core.StandardHostValve.invoke(org.apache.catalina.connector.Request request, org.apache.catalina.connector.Response response):110
public ApiDescription parse(String apiDescriptionString) {
if (apiDescriptionString == null) {
throw new NullPointerException("apiDescriptionString must not be null");
}
final int methodStart = apiDescriptionString.lastIndexOf(METHOD_PARAM_START);
if (methodStart == -1) {
throw new IllegalArgumentException("'(' not found. invalid apiDescriptionString:" + apiDescriptionString);
}
final int methodEnd = apiDescriptionString.lastIndexOf(METHOD_PARAM_END);
if (methodEnd == -1) {
throw new IllegalArgumentException("')' not found. invalid apiDescriptionString:" + apiDescriptionString);
}
final int classIndex = apiDescriptionString.lastIndexOf(DOT, methodStart);
if (classIndex == -1) {
throw new IllegalArgumentException("'.' not found. invalid apiDescriptionString:" + apiDescriptionString);
}
String className = parseClassName(apiDescriptionString, classIndex);
ApiDescription api = new DefaultApiDescription();
api.setClassName(className);
String methodName = parseMethodName(apiDescriptionString, methodStart, classIndex);
api.setMethodName(methodName);
String parameterDescriptor = apiDescriptionString.substring(methodStart + 1, methodEnd);
String[] parameterList = parseParameter(parameterDescriptor);
String[] simpleParameterList = parseSimpleParameter(parameterList);
api.setSimpleParameter(simpleParameterList);
int lineIndex = apiDescriptionString.lastIndexOf(':');
// TODO for now, check and display the lineNumber
if (lineIndex != -1) {
try {
int line = Integer.parseInt(apiDescriptionString.substring(lineIndex + 1, apiDescriptionString.length()));
api.setLine(line);
} catch (NumberFormatException e) {
LoggerFactory.getLogger(this.getClass()).warn("line number parse error {}", e);
}
}
return api;
}
use of com.navercorp.pinpoint.common.util.ApiDescription in project pinpoint by naver.
the class ApiDescriptionParserTest method parseTag.
@Test
public void parseTag() {
final String apiDescriptionString = ".Tomcat Servlet Process()";
ApiDescription result = apiParser.parse(apiDescriptionString);
logger.debug(result.getSimpleMethodDescription());
logger.debug(result.getSimpleClassName());
}
Aggregations