use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class SpanEventSimpleAroundInterceptorForPlugin method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logAfterInterceptor(target, args, result, throwable);
}
prepareAfterTrace(target, args, result, throwable);
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
try {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
doInAfterTrace(recorder, target, args, result, throwable);
} catch (Throwable th) {
if (logger.isWarnEnabled()) {
logger.warn("AFTER error. Caused:{}", th.getMessage(), th);
}
} finally {
trace.traceBlockEnd();
}
}
use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class DriverConnectInterceptorTest method driverConnect_return_Null_NPEtest.
@Test
public void driverConnect_return_Null_NPEtest() throws SQLException {
TraceContext traceContext = mock(TraceContext.class);
MethodDescriptor methodDescriptor = mock(MethodDescriptor.class);
JdbcUrlParser parser = mock(JdbcUrlParser.class);
when(parser.parse(anyString())).thenReturn(UnKnownDatabaseInfo.INSTANCE);
String invalidJdbcUrl = "invalidUrl";
final Driver driver = mock(Driver.class);
SpanEventRecorder spanEventRecorder = mock(SpanEventRecorder.class);
DriverConnectInterceptor driverConnectInterceptor = new DriverConnectInterceptor(traceContext, methodDescriptor, parser);
driverConnectInterceptor.prepareAfterTrace(driver, va(invalidJdbcUrl), null, null);
driverConnectInterceptor.doInAfterTrace(spanEventRecorder, driver, va(invalidJdbcUrl), null, null);
}
use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class ActiveMQMessageProducerSendInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args);
}
if (!validate(target, args)) {
return;
}
Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
try {
SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordApi(descriptor);
if (throwable == null) {
ActiveMQDestination destination = (ActiveMQDestination) args[0];
// This annotation indicates the uri to which the call is made
recorder.recordAttribute(AnnotationKey.MESSAGE_QUEUE_URI, destination.getQualifiedName());
// DestinationId is used to render the virtual queue node.
// We choose the queue/topic name as the logical name of the queue node.
recorder.recordDestinationId(destination.getPhysicalName());
ActiveMQSession session = ((ActiveMQSessionGetter) target)._$PINPOINT$_getActiveMQSession();
ActiveMQConnection connection = session.getConnection();
Transport transport = getRootTransport(((TransportGetter) connection)._$PINPOINT$_getTransport());
Socket socket = ((SocketGetter) transport)._$PINPOINT$_getSocket();
SocketAddress remoteSocketAddress = socket.getRemoteSocketAddress();
String remoteAddress = ActiveMQClientUtils.getEndPoint(remoteSocketAddress);
// Producer's endPoint should be the socket address of where the producer is actually connected to.
recorder.recordEndPoint(remoteAddress);
recorder.recordAttribute(ActiveMQClientConstants.ACTIVEMQ_BROKER_URL, remoteAddress);
} else {
recorder.recordException(throwable);
}
} catch (Throwable t) {
logger.warn("AFTER error. Cause:{}", t.getMessage(), t);
} finally {
trace.traceBlockEnd();
}
}
use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class ActiveMQMessageProducerSendInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
if (!validate(target, args)) {
return;
}
ActiveMQDestination activeMQDestination = (ActiveMQDestination) args[0];
if (filterDestination(activeMQDestination)) {
return;
}
Trace trace = traceContext.currentRawTraceObject();
if (trace == null) {
return;
}
Message message = (Message) args[1];
try {
if (trace.canSampled()) {
SpanEventRecorder recorder = trace.traceBlockBegin();
recorder.recordServiceType(ActiveMQClientConstants.ACTIVEMQ_CLIENT);
TraceId nextId = trace.getTraceId().getNextTraceId();
recorder.recordNextSpanId(nextId.getSpanId());
ActiveMQClientHeader.setTraceId(message, nextId.getTransactionId());
ActiveMQClientHeader.setSpanId(message, nextId.getSpanId());
ActiveMQClientHeader.setParentSpanId(message, nextId.getParentSpanId());
ActiveMQClientHeader.setFlags(message, nextId.getFlags());
ActiveMQClientHeader.setParentApplicationName(message, traceContext.getApplicationName());
ActiveMQClientHeader.setParentApplicationType(message, traceContext.getServerTypeCode());
} else {
ActiveMQClientHeader.setSampled(message, false);
}
} catch (Throwable t) {
logger.warn("BEFORE. Cause:{}", t.getMessage(), t);
}
}
use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class HttpRequestExecutorExecuteMethodInterceptor method recordCookie.
protected void recordCookie(HttpMessage httpMessage, Trace trace) {
org.apache.http.Header[] cookies = httpMessage.getHeaders("Cookie");
for (org.apache.http.Header header : cookies) {
final String value = header.getValue();
if (value != null && !value.isEmpty()) {
if (cookieSampler.isSampling()) {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordAttribute(AnnotationKey.HTTP_COOKIE, StringUtils.abbreviate(value, 1024));
}
// PMD complains if we use break here
return;
}
}
}
Aggregations