Skip to content

Commit

Permalink
Moved types for jdbc profiling to bootstrap-core
Browse files Browse the repository at this point in the history
Renamed jdbc-driver module to cubrid-jdbc
cubrid plugin uses redesinged plugin api
  • Loading branch information
lioolli committed Aug 11, 2015
1 parent a2ef009 commit 34740c2
Show file tree
Hide file tree
Showing 51 changed files with 369 additions and 268 deletions.
Expand Up @@ -14,13 +14,13 @@
*/
package com.navercorp.pinpoint.bootstrap.instrument;

import com.navercorp.pinpoint.bootstrap.plugin.ProfilerPluginContext;
import com.navercorp.pinpoint.bootstrap.plugin.ProfilerPluginInstrumentContext;

/**
* @author Jongho Moon
*
*/
public interface InstrumentClassPool {
InstrumentClass getClass(ProfilerPluginContext pluginContext, ClassLoader classLoader, String classInternalName, byte[] classFileBuffer) throws NotFoundInstrumentException;
InstrumentClass getClass(ProfilerPluginInstrumentContext pluginContext, ClassLoader classLoader, String classInternalName, byte[] classFileBuffer) throws NotFoundInstrumentException;
boolean hasClass(ClassLoader classLoader, String classBinaryName);
}
Expand Up @@ -25,7 +25,7 @@
* @author Jongho Moon
*
*/
public interface ProfilerPluginContext {
public interface ProfilerPluginInstrumentContext {
public TraceContext getTraceContext();

public InstrumentClass getInstrumentClass(ClassLoader classLoader, String className, byte[] classFileBuffer);
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.plugin.jdbc.common;
package com.navercorp.pinpoint.bootstrap.plugin.jdbc;

/**
* @author emeroad
Expand Down
@@ -0,0 +1,26 @@
/**
* Copyright 2014 NAVER Corp.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.navercorp.pinpoint.bootstrap.plugin.jdbc;

import java.util.Map;

/**
* @author Jongho Moon
*
*/
public interface BindValueAccessor {
public void _$PINPOINT$_setBindValue(Map<Integer, String> map);
public Map<Integer, String> _$PINPOINT$_getBindValue();
}
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.plugin.jdbc.common;
package com.navercorp.pinpoint.bootstrap.plugin.jdbc;

import java.lang.reflect.Method;

Expand Down
@@ -0,0 +1,26 @@
/**
* Copyright 2014 NAVER Corp.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.navercorp.pinpoint.bootstrap.plugin.jdbc;

import com.navercorp.pinpoint.bootstrap.context.DatabaseInfo;

/**
* @author Jongho Moon
*
*/
public interface DatabaseInfoAccessor {
public void _$PINPOINT$_setDatabaseInfo(DatabaseInfo info);
public DatabaseInfo _$PINPOINT$_getDatabaseInfo();
}
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.plugin.jdbc.common;
package com.navercorp.pinpoint.bootstrap.plugin.jdbc;

import com.navercorp.pinpoint.bootstrap.context.DatabaseInfo;
import com.navercorp.pinpoint.common.trace.ServiceType;
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.plugin.jdbc.common;
package com.navercorp.pinpoint.bootstrap.plugin.jdbc;

import java.lang.reflect.Method;

Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.plugin.jdbc.common;
package com.navercorp.pinpoint.bootstrap.plugin.jdbc;

import java.lang.reflect.Method;

Expand Down
Expand Up @@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.navercorp.pinpoint.plugin.jdbc.common;
package com.navercorp.pinpoint.bootstrap.plugin.jdbc;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
Expand Down
@@ -0,0 +1,26 @@
/**
* Copyright 2014 NAVER Corp.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.navercorp.pinpoint.bootstrap.plugin.jdbc;

import com.navercorp.pinpoint.bootstrap.context.ParsingResult;

/**
* @author Jongho Moon
*
*/
public interface ParsingResultAccessor {
public void _$PINPOINT$_setParsingResult(ParsingResult result);
public ParsingResult _$PINPOINT$_getParsingResult();
}
Expand Up @@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.navercorp.pinpoint.plugin.jdbc.common;
package com.navercorp.pinpoint.bootstrap.plugin.jdbc;

import java.lang.reflect.Method;
import java.util.ArrayList;
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.plugin.jdbc.common;
package com.navercorp.pinpoint.bootstrap.plugin.jdbc;


import java.lang.reflect.Method;
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.plugin.jdbc.common;
package com.navercorp.pinpoint.bootstrap.plugin.jdbc;

/**
* copy lucy 1.5
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.plugin.jdbc.common;
package com.navercorp.pinpoint.bootstrap.plugin.jdbc;

import java.util.ArrayList;
import java.util.List;
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.plugin.jdbc.common.bindvalue;
package com.navercorp.pinpoint.bootstrap.plugin.jdbc.bindvalue;

import java.util.HashMap;
import java.util.Map;
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.plugin.jdbc.common.bindvalue;
package com.navercorp.pinpoint.bootstrap.plugin.jdbc.bindvalue;

import com.navercorp.pinpoint.bootstrap.util.StringUtils;

Expand Down
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.plugin.jdbc.common.bindvalue;
package com.navercorp.pinpoint.bootstrap.plugin.jdbc.bindvalue;

import com.navercorp.pinpoint.plugin.jdbc.common.ArrayUtils;
import com.navercorp.pinpoint.bootstrap.plugin.jdbc.ArrayUtils;

/**
* @author emeroad
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.plugin.jdbc.common.bindvalue;
package com.navercorp.pinpoint.bootstrap.plugin.jdbc.bindvalue;

import com.navercorp.pinpoint.bootstrap.util.StringUtils;

Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.plugin.jdbc.common.bindvalue;
package com.navercorp.pinpoint.bootstrap.plugin.jdbc.bindvalue;

/**
* @author emeroad
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.plugin.jdbc.common.bindvalue;
package com.navercorp.pinpoint.bootstrap.plugin.jdbc.bindvalue;

/**
* @author emeroad
Expand Down
Expand Up @@ -14,16 +14,16 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.plugin.jdbc.common.bindvalue;
package com.navercorp.pinpoint.bootstrap.plugin.jdbc.bindvalue;

import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Time;
import java.sql.Timestamp;

import com.navercorp.pinpoint.bootstrap.plugin.jdbc.ArrayUtils;
import com.navercorp.pinpoint.bootstrap.util.StringUtils;
import com.navercorp.pinpoint.plugin.jdbc.common.ArrayUtils;

/**
* @author emeroad
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.plugin.jdbc.common.bindvalue;
package com.navercorp.pinpoint.bootstrap.plugin.jdbc.bindvalue;

import com.navercorp.pinpoint.bootstrap.util.StringUtils;

Expand Down
Expand Up @@ -14,38 +14,30 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.plugin.jdbc.common.interceptor;
package com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor;

import com.navercorp.pinpoint.bootstrap.MetadataAccessor;
import com.navercorp.pinpoint.bootstrap.interceptor.SimpleAroundInterceptor;
import com.navercorp.pinpoint.bootstrap.logging.PLogger;
import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory;
import com.navercorp.pinpoint.bootstrap.plugin.annotation.Name;
import com.navercorp.pinpoint.bootstrap.plugin.annotation.TargetMethod;
import com.navercorp.pinpoint.plugin.jdbc.common.JdbcDriverConstants;
import com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor;

/**
* @author emeroad
*/
@TargetMethod(name="close")
public class ConnectionCloseInterceptor implements SimpleAroundInterceptor, JdbcDriverConstants {
public class ConnectionCloseInterceptor implements SimpleAroundInterceptor {

private final PLogger logger = PLoggerFactory.getLogger(this.getClass());
private final boolean isDebug = logger.isDebugEnabled();

private final MetadataAccessor databaseInfoAccessor;

public ConnectionCloseInterceptor(@Name(DATABASE_INFO) MetadataAccessor databaseInfoAccessor) {
this.databaseInfoAccessor = databaseInfoAccessor;
}

@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
// In case of close, we have to delete data even if the invocation failed.
databaseInfoAccessor.set(target, null);
((DatabaseInfoAccessor)target)._$PINPOINT$_setDatabaseInfo(null);
}

@Override
Expand Down
Expand Up @@ -14,20 +14,18 @@
* limitations under the License.
*/

package com.navercorp.pinpoint.plugin.jdbc.common.interceptor;
package com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor;

import com.navercorp.pinpoint.bootstrap.MetadataAccessor;
import com.navercorp.pinpoint.bootstrap.context.DatabaseInfo;
import com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder;
import com.navercorp.pinpoint.bootstrap.context.TraceContext;
import com.navercorp.pinpoint.bootstrap.interceptor.MethodDescriptor;
import com.navercorp.pinpoint.bootstrap.interceptor.SpanEventSimpleAroundInterceptorForPlugin;
import com.navercorp.pinpoint.bootstrap.plugin.annotation.Name;
import com.navercorp.pinpoint.bootstrap.plugin.annotation.TargetMethod;
import com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor;
import com.navercorp.pinpoint.bootstrap.plugin.jdbc.JdbcUrlParser;
import com.navercorp.pinpoint.bootstrap.plugin.jdbc.UnKnownDatabaseInfo;
import com.navercorp.pinpoint.bootstrap.util.InterceptorUtils;
import com.navercorp.pinpoint.plugin.jdbc.common.JdbcDriverConstants;
import com.navercorp.pinpoint.plugin.jdbc.common.JdbcUrlParser;
import com.navercorp.pinpoint.plugin.jdbc.common.UnKnownDatabaseInfo;


/**
Expand All @@ -36,21 +34,19 @@
* @author emeroad
*/
@TargetMethod(name="connect", paramTypes={ "java.lang.String", "java.util.Properties" })
public class DriverConnectInterceptor extends SpanEventSimpleAroundInterceptorForPlugin implements JdbcDriverConstants {
private final MetadataAccessor databaseInfoAccessor;
public class DriverConnectInterceptor extends SpanEventSimpleAroundInterceptorForPlugin {

private final JdbcUrlParser jdbcUrlParser;
private final boolean recordConnection;


public DriverConnectInterceptor(TraceContext context, MethodDescriptor descriptor, @Name(DATABASE_INFO) MetadataAccessor databaseInfoAccessor, JdbcUrlParser jdbcUrlParser) {
this(context, descriptor, databaseInfoAccessor, jdbcUrlParser, true);
public DriverConnectInterceptor(TraceContext context, MethodDescriptor descriptor, JdbcUrlParser jdbcUrlParser) {
this(context, descriptor, jdbcUrlParser, true);
}

public DriverConnectInterceptor(TraceContext context, MethodDescriptor descriptor, @Name(DATABASE_INFO) MetadataAccessor databaseInfoAccessor, JdbcUrlParser jdbcUrlParser, boolean recordConnection) {
public DriverConnectInterceptor(TraceContext context, MethodDescriptor descriptor, JdbcUrlParser jdbcUrlParser, boolean recordConnection) {
super(context, descriptor);

this.databaseInfoAccessor = databaseInfoAccessor;
this.jdbcUrlParser = jdbcUrlParser;
// option for mysql loadbalance only. Destination is recorded at lower implementations.
this.recordConnection = recordConnection;
Expand Down Expand Up @@ -80,7 +76,7 @@ protected void prepareAfterTrace(Object target, Object[] args, Object result, Th
DatabaseInfo databaseInfo = createDatabaseInfo(driverUrl);
if (success) {
if (recordConnection) {
databaseInfoAccessor.set(result, databaseInfo);
((DatabaseInfoAccessor)result)._$PINPOINT$_setDatabaseInfo(databaseInfo);
}
}
}
Expand All @@ -89,7 +85,12 @@ protected void prepareAfterTrace(Object target, Object[] args, Object result, Th
protected void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {

if (recordConnection) {
final DatabaseInfo databaseInfo = databaseInfoAccessor.get(result, UnKnownDatabaseInfo.INSTANCE);
DatabaseInfo databaseInfo = (result instanceof DatabaseInfoAccessor) ? ((DatabaseInfoAccessor)result)._$PINPOINT$_getDatabaseInfo() : null;

if (databaseInfo == null) {
databaseInfo = UnKnownDatabaseInfo.INSTANCE;
}

// Count database connect too because it's very heavy operation
recorder.recordServiceType(databaseInfo.getType());
recorder.recordEndPoint(databaseInfo.getMultipleHost());
Expand Down

0 comments on commit 34740c2

Please sign in to comment.