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());
}
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);
}
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;
}
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]);
}
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();
}
}
Aggregations