use of com.navercorp.pinpoint.bootstrap.interceptor.scope.AttachmentFactory in project pinpoint by naver.
the class HttpEngineSendRequestMethodInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
if (!validate(target)) {
return;
}
final SpanEventRecorder recorder = trace.traceBlockBegin();
try {
final TraceId nextId = trace.getTraceId().getNextTraceId();
recorder.recordNextSpanId(nextId.getSpanId());
recorder.recordServiceType(OkHttpConstants.OK_HTTP_CLIENT);
final InterceptorScopeInvocation invocation = interceptorScope.getCurrentInvocation();
if (invocation != null) {
invocation.getOrCreateAttachment(new AttachmentFactory() {
@Override
public Object createAttachment() {
return nextId;
}
});
}
} catch (Throwable t) {
logger.warn("Failed to BEFORE process. {}", t.getMessage(), t);
}
}
use of com.navercorp.pinpoint.bootstrap.interceptor.scope.AttachmentFactory in project pinpoint by naver.
the class BridgeInterceptorInterceptMethodInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
if (!validate(args)) {
return;
}
final SpanEventRecorder recorder = trace.traceBlockBegin();
try {
final TraceId nextId = trace.getTraceId().getNextTraceId();
recorder.recordNextSpanId(nextId.getSpanId());
recorder.recordServiceType(OkHttpConstants.OK_HTTP_CLIENT);
final InterceptorScopeInvocation invocation = interceptorScope.getCurrentInvocation();
if (invocation != null) {
invocation.getOrCreateAttachment(new AttachmentFactory() {
@Override
public Object createAttachment() {
return nextId;
}
});
}
} catch (Throwable t) {
logger.warn("Failed to BEFORE process. {}", t.getMessage(), t);
}
}
use of com.navercorp.pinpoint.bootstrap.interceptor.scope.AttachmentFactory in project pinpoint by naver.
the class HttpEngineSendRequestMethodInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
final Trace trace = traceContext.currentRawTraceObject();
if (trace == null) {
return;
}
if (!validate(target)) {
return;
}
if (!trace.canSampled()) {
return;
}
SpanEventRecorder recorder = trace.traceBlockBegin();
try {
final TraceId nextId = trace.getTraceId().getNextTraceId();
recorder.recordNextSpanId(nextId.getSpanId());
recorder.recordServiceType(OkHttpConstants.OK_HTTP_CLIENT);
InterceptorScopeInvocation invocation = interceptorScope.getCurrentInvocation();
if (invocation != null) {
invocation.getOrCreateAttachment(new AttachmentFactory() {
@Override
public Object createAttachment() {
return nextId;
}
});
}
} catch (Throwable t) {
logger.warn("Failed to BEFORE process. {}", t.getMessage(), t);
}
}
use of com.navercorp.pinpoint.bootstrap.interceptor.scope.AttachmentFactory in project pinpoint by naver.
the class HttpEngineSendRequestMethodInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
if (!validate(target)) {
return;
}
final SpanEventRecorder recorder = trace.traceBlockBegin();
try {
final TraceId nextId = trace.getTraceId().getNextTraceId();
recorder.recordNextSpanId(nextId.getSpanId());
recorder.recordServiceType(OkHttpConstants.OK_HTTP_CLIENT);
final InterceptorScopeInvocation invocation = interceptorScope.getCurrentInvocation();
if (invocation != null) {
invocation.getOrCreateAttachment(new AttachmentFactory() {
@Override
public Object createAttachment() {
return nextId;
}
});
}
} catch (Throwable t) {
logger.warn("Failed to BEFORE process. {}", t.getMessage(), t);
}
}
use of com.navercorp.pinpoint.bootstrap.interceptor.scope.AttachmentFactory in project pinpoint by naver.
the class ThreadLocalScopePoolTest method testGetOrCreate.
@Test
public void testGetOrCreate() {
ScopePool pool = new ThreadLocalScopePool();
InterceptorScopeInvocation scope = pool.getScope(new DefaultInterceptorScopeDefinition("test"));
scope.tryEnter(ExecutionPolicy.BOUNDARY);
scope.tryEnter(ExecutionPolicy.BOUNDARY);
Assert.assertNull(scope.getAttachment());
Assert.assertEquals(scope.getOrCreateAttachment(new AttachmentFactory() {
@Override
public Object createAttachment() {
return "test";
}
}), "test");
scope.canLeave(ExecutionPolicy.BOUNDARY);
Assert.assertEquals(scope.getAttachment(), "test");
Assert.assertTrue(scope.canLeave(ExecutionPolicy.BOUNDARY));
scope.leave(ExecutionPolicy.BOUNDARY);
Assert.assertEquals("name", "test", scope.getName());
}
Aggregations