Search in sources :

Example 1 with IgnoredTracerContext

use of org.apache.skywalking.apm.agent.core.context.IgnoredTracerContext in project incubator-skywalking by apache.

the class TracingSegmentRunner method withAfters.

@Override
protected Statement withAfters(FrameworkMethod method, Object target, final Statement statement) {
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            if (field != null) {
                try {
                    tracingData = new SegmentStorage();
                    field.set(targetObject, tracingData);
                } catch (IllegalAccessException e) {
                }
            }
            tracingContextListener = new TracingContextListener() {

                @Override
                public void afterFinished(TraceSegment traceSegment) {
                    tracingData.addTraceSegment(traceSegment);
                }
            };
            ignoreTracerContextListener = new IgnoreTracerContextListener() {

                @Override
                public void afterFinished(IgnoredTracerContext tracerContext) {
                    tracingData.addIgnoreTraceContext(tracerContext);
                }
            };
            TracingContext.ListenerManager.add(tracingContextListener);
            IgnoredTracerContext.ListenerManager.add(ignoreTracerContextListener);
            try {
                statement.evaluate();
            } finally {
                TracingContext.ListenerManager.remove(tracingContextListener);
                IgnoredTracerContext.ListenerManager.remove(ignoreTracerContextListener);
            }
        }
    };
}
Also used : IgnoredTracerContext(org.apache.skywalking.apm.agent.core.context.IgnoredTracerContext) Statement(org.junit.runners.model.Statement) IgnoreTracerContextListener(org.apache.skywalking.apm.agent.core.context.IgnoreTracerContextListener) TracingContextListener(org.apache.skywalking.apm.agent.core.context.TracingContextListener) TraceSegment(org.apache.skywalking.apm.agent.core.context.trace.TraceSegment)

Example 2 with IgnoredTracerContext

use of org.apache.skywalking.apm.agent.core.context.IgnoredTracerContext in project incubator-skywalking by apache.

the class TracingSegmentRunner method withAfters.

@Override
protected Statement withAfters(FrameworkMethod method, Object target, final Statement statement) {
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            if (field != null) {
                try {
                    tracingData = new SegmentStorage();
                    field.set(targetObject, tracingData);
                } catch (IllegalAccessException e) {
                }
            }
            tracingContextListener = new TracingContextListener() {

                @Override
                public void afterFinished(TraceSegment traceSegment) {
                    tracingData.addTraceSegment(traceSegment);
                }
            };
            ignoreTracerContextListener = new IgnoreTracerContextListener() {

                @Override
                public void afterFinished(IgnoredTracerContext tracerContext) {
                    tracingData.addIgnoreTraceContext(tracerContext);
                }
            };
            TracingContext.ListenerManager.add(tracingContextListener);
            IgnoredTracerContext.ListenerManager.add(ignoreTracerContextListener);
            try {
                statement.evaluate();
            } finally {
                TracingContext.ListenerManager.remove(tracingContextListener);
                IgnoredTracerContext.ListenerManager.remove(ignoreTracerContextListener);
            }
        }
    };
}
Also used : IgnoredTracerContext(org.apache.skywalking.apm.agent.core.context.IgnoredTracerContext) Statement(org.junit.runners.model.Statement) IgnoreTracerContextListener(org.apache.skywalking.apm.agent.core.context.IgnoreTracerContextListener) TracingContextListener(org.apache.skywalking.apm.agent.core.context.TracingContextListener) TraceSegment(org.apache.skywalking.apm.agent.core.context.trace.TraceSegment)

Aggregations

IgnoreTracerContextListener (org.apache.skywalking.apm.agent.core.context.IgnoreTracerContextListener)2 IgnoredTracerContext (org.apache.skywalking.apm.agent.core.context.IgnoredTracerContext)2 TracingContextListener (org.apache.skywalking.apm.agent.core.context.TracingContextListener)2 TraceSegment (org.apache.skywalking.apm.agent.core.context.trace.TraceSegment)2 Statement (org.junit.runners.model.Statement)2