Search in sources :

Example 26 with AbstractSpan

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

the class JobExecutorInterceptor method beforeMethod.

@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
    ShardingContexts shardingContexts = (ShardingContexts) allArguments[0];
    Integer item = (Integer) allArguments[1];
    ShardingContext shardingContext = new ShardingContext(shardingContexts, item);
    String operateName = shardingContext.getJobName();
    if (!Strings.isNullOrEmpty(shardingContext.getShardingParameter())) {
        operateName += "-" + shardingContext.getShardingParameter();
    }
    AbstractSpan span = ContextManager.createLocalSpan(operateName);
    span.setComponent(ComponentsDefine.ELASTIC_JOB);
    span.tag("sharding_context", shardingContext.toString());
}
Also used : ShardingContexts(com.dangdang.ddframe.job.executor.ShardingContexts) ShardingContext(com.dangdang.ddframe.job.api.ShardingContext) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 27 with AbstractSpan

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

the class ConstructorWithSpanBuilderInterceptor method onConstruct.

@Override
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
    SkywalkingSpanBuilder spanBuilder = (SkywalkingSpanBuilder) allArguments[0];
    AbstractSpan span;
    if (spanBuilder.isEntry()) {
        span = ContextManager.createEntrySpan(spanBuilder.getOperationName(), null);
    } else if (spanBuilder.isExit() && (!StringUtil.isEmpty(spanBuilder.getPeer()))) {
        span = ContextManager.createExitSpan(spanBuilder.getOperationName(), buildRemotePeer(spanBuilder));
    } else {
        span = ContextManager.createLocalSpan(spanBuilder.getOperationName());
    }
    for (Tag tag : spanBuilder.getTags()) {
        span.tag(tag.getKey(), tag.getValue());
    }
    span.setComponent(spanBuilder.getComponentName());
    if (spanBuilder.isError()) {
        span.errorOccurred();
    }
    objInst.setSkyWalkingDynamicField(span);
}
Also used : SkywalkingSpanBuilder(org.apache.skywalking.apm.toolkit.opentracing.SkywalkingSpanBuilder) Tag(org.apache.skywalking.apm.toolkit.opentracing.Tag) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 28 with AbstractSpan

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

the class SpanSetTagInterceptor method afterMethod.

@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable {
    AbstractSpan activeSpan = ContextManager.activeSpan();
    String tagKey = String.valueOf(allArguments[0]);
    String tagValue = String.valueOf(allArguments[1]);
    if (Tags.COMPONENT.getKey().equals(tagKey)) {
        activeSpan.setComponent(tagValue);
    } else if (Tags.PEER_SERVICE.getKey().equals(tagKey)) {
        activeSpan.setOperationName(tagValue);
    } else {
        activeSpan.tag(tagKey, tagValue);
    }
    return ret;
}
Also used : AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 29 with AbstractSpan

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

the class XMemcachedMethodInterceptor method beforeMethod.

@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
    String peer = String.valueOf(objInst.getSkyWalkingDynamicField());
    AbstractSpan span = ContextManager.createExitSpan(XMEMCACHED + method.getName(), peer);
    span.setComponent(ComponentsDefine.MEMCACHED);
    Tags.DB_TYPE.set(span, ComponentsDefine.MEMCACHED.getName());
    SpanLayer.asCache(span);
    Tags.DB_STATEMENT.set(span, method.getName() + " " + allArguments[0]);
}
Also used : AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 30 with AbstractSpan

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

the class ExecuteEventListener method handle.

private void handle(AbstractExecutionEvent event, String operation) {
    switch(event.getEventExecutionType()) {
        case BEFORE_EXECUTE:
            AbstractSpan span = ContextManager.createExitSpan("/SJDBC/BRANCH/" + operation, event.getDataSource());
            if (ExecutorDataMap.getDataMap().containsKey(AsyncExecuteInterceptor.SNAPSHOT_DATA_KEY)) {
                ContextManager.continued((ContextSnapshot) ExecutorDataMap.getDataMap().get(AsyncExecuteInterceptor.SNAPSHOT_DATA_KEY));
            }
            Tags.DB_TYPE.set(span, "sql");
            Tags.DB_INSTANCE.set(span, event.getDataSource());
            Tags.DB_STATEMENT.set(span, event.getSql());
            if (!event.getParameters().isEmpty()) {
                Tags.DB_BIND_VARIABLES.set(span, Joiner.on(",").join(event.getParameters()));
            }
            span.setComponent(ComponentsDefine.SHARDING_JDBC);
            SpanLayer.asDB(span);
            break;
        case EXECUTE_FAILURE:
            span = ContextManager.activeSpan();
            span.errorOccurred();
            if (event.getException().isPresent()) {
                span.log(event.getException().get());
            }
        case EXECUTE_SUCCESS:
            ContextManager.stopSpan();
    }
}
Also used : AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Aggregations

AbstractSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)141 ContextCarrier (org.apache.skywalking.apm.agent.core.context.ContextCarrier)36 CarrierItem (org.apache.skywalking.apm.agent.core.context.CarrierItem)29 URI (java.net.URI)7 AbstractTracingSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan)7 TraceSegment (org.apache.skywalking.apm.agent.core.context.trace.TraceSegment)7 ConnectionInfo (org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo)7 HttpServletResponse (javax.servlet.http.HttpServletResponse)6 StatementEnhanceInfos (org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos)6 Invocation (io.servicecomb.core.Invocation)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 Invocation (org.apache.servicecomb.core.Invocation)5 SQLException (java.sql.SQLException)4 Metadata (io.grpc.Metadata)3 Field (java.lang.reflect.Field)3 List (java.util.List)3 TraceSegmentRef (org.apache.skywalking.apm.agent.core.context.trace.TraceSegmentRef)3 EnhancedInstance (org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance)3 Request (com.weibo.api.motan.rpc.Request)2 Response (com.weibo.api.motan.rpc.Response)2