Skip to content

Commit

Permalink
[pinpoint-apm#10940] Move the class location to avoid loading the cla…
Browse files Browse the repository at this point in the history
…ss in web to fix the NoClassDefFoundError error on web startup.
  • Loading branch information
minwoo-jung committed Apr 23, 2024
1 parent 759ead1 commit 6405f04
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.navercorp.pinpoint.bootstrap.context.DatabaseInfo;
import com.navercorp.pinpoint.common.trace.ServiceType;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

Expand All @@ -27,6 +28,7 @@
*/
public class MongoDatabaseInfo implements DatabaseInfo {

public static final MongoDatabaseInfo UNKNOWN_MONGO_DATABASE_INFO = new MongoDatabaseInfo(ServiceType.UNKNOWN_DB, ServiceType.UNKNOWN_DB_EXECUTE_QUERY, "unknown", "unknown", Arrays.asList("unknown"), "unknown", "unknown", false, "unknown", "unknown");
private final ServiceType type;
private final ServiceType executeQueryType;
private final String databaseId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,13 @@
*/
package com.navercorp.pinpoint.plugin.mongo;

import com.navercorp.pinpoint.bootstrap.plugin.jdbc.MongoDatabaseInfo;
import com.navercorp.pinpoint.common.trace.AnnotationKey;
import com.navercorp.pinpoint.common.trace.AnnotationKeyFactory;
import com.navercorp.pinpoint.common.trace.ServiceType;
import com.navercorp.pinpoint.common.trace.ServiceTypeFactory;

import java.util.Arrays;

import static com.navercorp.pinpoint.common.trace.AnnotationKeyProperty.VIEW_IN_RECORD_SET;
import static com.navercorp.pinpoint.common.trace.ServiceTypeProperty.INCLUDE_DESTINATION_ID;
import static com.navercorp.pinpoint.common.trace.ServiceTypeProperty.RECORD_STATISTICS;
import static com.navercorp.pinpoint.common.trace.ServiceTypeProperty.TERMINAL;
import static com.navercorp.pinpoint.common.trace.ServiceTypeProperty.*;

/**
* @author Roy Kim
Expand Down Expand Up @@ -85,6 +80,4 @@ private MongoConstants() {
public static final ServiceType MONGODB = ServiceTypeFactory.of(2650, "MONGO", TERMINAL, INCLUDE_DESTINATION_ID);
public static final ServiceType MONGO_EXECUTE_QUERY = ServiceTypeFactory.of(2651, "MONGO_EXECUTE_QUERY", "MONGO", TERMINAL, RECORD_STATISTICS, INCLUDE_DESTINATION_ID);
public static final ServiceType MONGO_REACTIVE = ServiceTypeFactory.of(2652, "MONGO_REACTIVE", "MONGO");

public static final MongoDatabaseInfo UNKNOWN_MONGO_DATABASE_INFO = new MongoDatabaseInfo(ServiceType.UNKNOWN_DB, ServiceType.UNKNOWN_DB_EXECUTE_QUERY, "unknown", "unknown", Arrays.asList("unknown"), "unknown", "unknown", false, "unknown", "unknown");
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public MongoCollectionImplReadOperationInterceptor(TraceContext traceContext, Me
@Override
public void doInBeforeTrace(SpanEventRecorder recorder, Object target, Object[] args) {
recorder.recordApi(methodDescriptor);
MongoDatabaseInfo databaseInfo = DatabaseInfoUtils.getDatabaseInfo(target, MongoConstants.UNKNOWN_MONGO_DATABASE_INFO);
MongoDatabaseInfo databaseInfo = DatabaseInfoUtils.getDatabaseInfo(target, MongoDatabaseInfo.UNKNOWN_MONGO_DATABASE_INFO);
if (target instanceof HostListAccessor) {
final List<String> hostList = ((HostListAccessor) target)._$PINPOINT$_getHostList();
if (hostList != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public MongoCollectionImplWriteOperationInterceptor(TraceContext traceContext, M
@Override
public void doInBeforeTrace(SpanEventRecorder recorder, Object target, Object[] args) {
recorder.recordApi(methodDescriptor);
MongoDatabaseInfo databaseInfo = DatabaseInfoUtils.getDatabaseInfo(target, MongoConstants.UNKNOWN_MONGO_DATABASE_INFO);
MongoDatabaseInfo databaseInfo = DatabaseInfoUtils.getDatabaseInfo(target, MongoDatabaseInfo.UNKNOWN_MONGO_DATABASE_INFO);
if (target instanceof HostListAccessor) {
final List<String> hostList = ((HostListAccessor) target)._$PINPOINT$_getHostList();
if (hostList != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void getDatabaseInfo() {
DatabaseInfo defaultDatabaseInfo = mock(MongoDatabaseInfo.class);
when(databaseInfoAccessor._$PINPOINT$_getDatabaseInfo()).thenReturn(defaultDatabaseInfo);

DatabaseInfo databaseInfo = DatabaseInfoUtils.getDatabaseInfo(databaseInfoAccessor, MongoConstants.UNKNOWN_MONGO_DATABASE_INFO);
DatabaseInfo databaseInfo = DatabaseInfoUtils.getDatabaseInfo(databaseInfoAccessor, MongoDatabaseInfo.UNKNOWN_MONGO_DATABASE_INFO);

Assertions.assertEquals(databaseInfo, defaultDatabaseInfo);
}
Expand All @@ -47,15 +47,15 @@ public void getDatabaseInfo_return_null() {
DatabaseInfoAccessor databaseInfoAccessor = mock(DatabaseInfoAccessor.class);
when(databaseInfoAccessor._$PINPOINT$_getDatabaseInfo()).thenReturn(null);

DatabaseInfo databaseInfo = DatabaseInfoUtils.getDatabaseInfo(databaseInfoAccessor, MongoConstants.UNKNOWN_MONGO_DATABASE_INFO);
Assertions.assertEquals(databaseInfo, MongoConstants.UNKNOWN_MONGO_DATABASE_INFO);
DatabaseInfo databaseInfo = DatabaseInfoUtils.getDatabaseInfo(databaseInfoAccessor, MongoDatabaseInfo.UNKNOWN_MONGO_DATABASE_INFO);
Assertions.assertEquals(databaseInfo, MongoDatabaseInfo.UNKNOWN_MONGO_DATABASE_INFO);
}

@Test
public void getDatabaseInfo_unknown() {
DatabaseInfo databaseInfo = DatabaseInfoUtils.getDatabaseInfo(new Object(), MongoConstants.UNKNOWN_MONGO_DATABASE_INFO);
DatabaseInfo databaseInfo = DatabaseInfoUtils.getDatabaseInfo(new Object(), MongoDatabaseInfo.UNKNOWN_MONGO_DATABASE_INFO);

Assertions.assertEquals(databaseInfo, MongoConstants.UNKNOWN_MONGO_DATABASE_INFO);
Assertions.assertEquals(databaseInfo, MongoDatabaseInfo.UNKNOWN_MONGO_DATABASE_INFO);
}

}

0 comments on commit 6405f04

Please sign in to comment.