Search in sources :

Example 26 with SpanRecorder

use of com.navercorp.pinpoint.bootstrap.context.SpanRecorder in project pinpoint by naver.

the class ServerRequestRecorderFactoryTest method record.

@Test
public void record() throws Exception {
    RequestAdaptor<ServerRequestWrapper> requestAdaptor = new ServerRequestWrapperAdaptor();
    final ServerRequestRecorder<ServerRequestWrapper> recorder = new ServerRequestRecorder<>(requestAdaptor);
    // SpanRecorder
    SpanRecorder spanRecorder = mock(SpanRecorder.class);
    recorder.record(spanRecorder, new MockServerRequestWrapper());
    verify(spanRecorder).recordRpcName(RPC_NAME);
    verify(spanRecorder).recordEndPoint(END_POINT);
    verify(spanRecorder).recordRemoteAddress(REMOTE_ADDRESS);
    verify(spanRecorder).recordAcceptorHost(GET_HEADER);
}
Also used : SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) ServerRequestRecorder(com.navercorp.pinpoint.bootstrap.plugin.request.ServerRequestRecorder) ServerRequestWrapper(com.navercorp.pinpoint.bootstrap.plugin.request.ServerRequestWrapper) ServerRequestWrapperAdaptor(com.navercorp.pinpoint.bootstrap.plugin.request.ServerRequestWrapperAdaptor) Test(org.junit.Test)

Example 27 with SpanRecorder

use of com.navercorp.pinpoint.bootstrap.context.SpanRecorder in project pinpoint by naver.

the class HttpServerResponseImplInterceptor method doInAfterTrace.

@Override
public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
    recorder.recordApi(methodDescriptor);
    recorder.recordServiceType(VertxConstants.VERTX_HTTP_SERVER_INTERNAL);
    recorder.recordException(throwable);
    if (target instanceof HttpServerResponse) {
        final HttpServerResponse response = (HttpServerResponse) target;
        // TODO more simple.
        final AsyncContext asyncContext = getAsyncContext(target);
        if (asyncContext != null) {
            final Trace trace = asyncContext.currentAsyncTraceObject();
            if (trace != null) {
                final SpanRecorder spanRecorder = trace.getSpanRecorder();
                this.httpStatusCodeRecorder.record(spanRecorder, response.getStatusCode());
            }
        }
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) HttpServerResponse(io.vertx.core.http.HttpServerResponse) AsyncContext(com.navercorp.pinpoint.bootstrap.context.AsyncContext)

Example 28 with SpanRecorder

use of com.navercorp.pinpoint.bootstrap.context.SpanRecorder in project pinpoint by naver.

the class ServletResponseListener method destroyed.

public void destroyed(RESP response, final Throwable throwable, final int statusCode) {
    Objects.requireNonNull(response, "response");
    if (isDebug) {
        logger.debug("Destroyed responseEvent. response={}, throwable={}, statusCode={}", response, throwable, statusCode);
    }
    final Trace trace = this.traceContext.currentRawTraceObject();
    if (trace == null) {
        return;
    }
    if (trace.canSampled()) {
        final SpanRecorder spanRecorder = trace.getSpanRecorder();
        this.httpStatusCodeRecorder.record(spanRecorder, statusCode);
        this.serverResponseHeaderRecorder.recordHeader(spanRecorder, response);
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder)

Example 29 with SpanRecorder

use of com.navercorp.pinpoint.bootstrap.context.SpanRecorder in project pinpoint by naver.

the class PinpointJUnit4ClassRunner method beginTracing.

private void beginTracing(FrameworkMethod method) {
    if (shouldCreateNewTraceObject(method)) {
        TraceContext traceContext = getTraceContext();
        Trace trace = traceContext.newTraceObject();
        SpanRecorder recorder = trace.getSpanRecorder();
        recorder.recordServiceType(ServiceType.TEST);
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) TraceContext(com.navercorp.pinpoint.bootstrap.context.TraceContext)

Example 30 with SpanRecorder

use of com.navercorp.pinpoint.bootstrap.context.SpanRecorder in project pinpoint by naver.

the class DefaultBaseTraceFactory method continueAsyncTraceObject.

// entry point async trace.
@InterfaceAudience.LimitedPrivate("vert.x")
@Override
public Trace continueAsyncTraceObject(final TraceId traceId) {
    final TraceSampler.State state = traceSampler.isContinueSampled();
    final boolean sampling = state.isSampled();
    if (sampling) {
        final TraceRoot traceRoot = traceRootFactory.continueTraceRoot(traceId, state.nextId());
        final Span span = spanFactory.newSpan(traceRoot);
        final SpanChunkFactory spanChunkFactory = new DefaultSpanChunkFactory(traceRoot);
        final Storage storage = storageFactory.createStorage(spanChunkFactory);
        final CallStack<SpanEvent> callStack = callStackFactory.newCallStack();
        final ActiveTraceHandle handle = registerActiveTrace(traceRoot);
        final SpanAsyncStateListener asyncStateListener = new SpanAsyncStateListener(span, storageFactory);
        final AsyncState asyncState = new ListenableAsyncState(asyncStateListener, handle);
        final SpanRecorder spanRecorder = recorderFactory.newSpanRecorder(span, traceId.isRoot(), sampling);
        final WrappedSpanEventRecorder wrappedSpanEventRecorder = recorderFactory.newWrappedSpanEventRecorder(traceRoot, asyncState);
        final DefaultTrace trace = new DefaultTrace(span, callStack, storage, sampling, spanRecorder, wrappedSpanEventRecorder, ActiveTraceHandle.EMPTY_HANDLE);
        final AsyncTrace asyncTrace = new AsyncTrace(traceRoot, trace, asyncState);
        return asyncTrace;
    } else {
        return newDisableTrace(state.nextId());
    }
}
Also used : TraceSampler(com.navercorp.pinpoint.bootstrap.sampler.TraceSampler) ActiveTraceHandle(com.navercorp.pinpoint.profiler.context.active.ActiveTraceHandle) ListenableAsyncState(com.navercorp.pinpoint.profiler.context.id.ListenableAsyncState) AsyncState(com.navercorp.pinpoint.bootstrap.context.AsyncState) WrappedSpanEventRecorder(com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder) ListenableAsyncState(com.navercorp.pinpoint.profiler.context.id.ListenableAsyncState) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) Storage(com.navercorp.pinpoint.profiler.context.storage.Storage) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot)

Aggregations

SpanRecorder (com.navercorp.pinpoint.bootstrap.context.SpanRecorder)38 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)23 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)10 Test (org.junit.Test)10 WrappedSpanEventRecorder (com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder)8 Storage (com.navercorp.pinpoint.profiler.context.storage.Storage)8 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)6 TraceContext (com.navercorp.pinpoint.bootstrap.context.TraceContext)4 TraceSampler (com.navercorp.pinpoint.bootstrap.sampler.TraceSampler)4 ActiveTraceHandle (com.navercorp.pinpoint.profiler.context.active.ActiveTraceHandle)4 DefaultSpanRecorder (com.navercorp.pinpoint.profiler.context.recorder.DefaultSpanRecorder)4 Span (com.navercorp.pinpoint.profiler.context.Span)3 DefaultTraceId (com.navercorp.pinpoint.profiler.context.id.DefaultTraceId)3 AsyncState (com.navercorp.pinpoint.bootstrap.context.AsyncState)2 SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)2 DefaultTraceRoot (com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot)2 ListenableAsyncState (com.navercorp.pinpoint.profiler.context.id.ListenableAsyncState)2 AMQP (com.rabbitmq.client.AMQP)2 AMQConnection (com.rabbitmq.client.impl.AMQConnection)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2