Java Code Examples for org.apache.skywalking.apm.agent.core.context.trace.SpanLayer#asCache()

The following examples show how to use org.apache.skywalking.apm.agent.core.context.trace.SpanLayer#asCache() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AsyncCommandMethodInterceptor.java    From skywalking with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
    MethodInterceptResult result) throws Throwable {
    AsyncCommand asyncCommand = (AsyncCommand) objInst;
    String operationName = "Lettuce/" + asyncCommand.getType().name();
    AbstractSpan span = ContextManager.createLocalSpan(operationName + "/onComplete");
    span.setComponent(ComponentsDefine.LETTUCE);
    Tags.DB_TYPE.set(span, "Redis");
    SpanLayer.asCache(span);
    if (allArguments[0] instanceof Consumer) {
        allArguments[0] = new SWConsumer((Consumer) allArguments[0], ContextManager.capture(), operationName);
    } else {
        allArguments[0] = new SWBiConsumer((BiConsumer) allArguments[0], ContextManager.capture(), operationName);
    }
}
 
Example 2
Source File: EhcacheLockInterceptor.java    From skywalking with Apache License 2.0 6 votes vote down vote up
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
    MethodInterceptResult result) throws Throwable {
    EhcacheEnhanceInfo enhanceInfo = (EhcacheEnhanceInfo) objInst.getSkyWalkingDynamicField();

    String operateName = method.getName()
                               .substring(0, method.getName().length() - LOCK_ENHANCE_METHOD_SUFFIX.length());

    AbstractSpan span = ContextManager.createLocalSpan("Ehcache/" + operateName + "/" + enhanceInfo.getCacheName());
    span.setComponent(ComponentsDefine.EHCACHE);
    SpanLayer.asCache(span);

    Object element = allArguments[0];
    if (element != null) {
        Tags.DB_STATEMENT.set(span, element.toString());
    }
}
 
Example 3
Source File: ClientCnxnInterceptor.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
    MethodInterceptResult result) throws Throwable {
    String peer = (String) objInst.getSkyWalkingDynamicField();
    RequestHeader header = (RequestHeader) allArguments[0];
    String operationName = ZooOpt.getOperationName(header.getType());
    AbstractSpan span = ContextManager.createExitSpan("Zookeeper/" + operationName, peer);
    span.setComponent(ComponentsDefine.ZOOKEEPER);
    Tags.DB_TYPE.set(span, "Zookeeper");
    ZooOpt.setTags(span, (Record) allArguments[2]);
    SpanLayer.asCache(span);
}
 
Example 4
Source File: SWBiConsumer.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Override
public void accept(T t, U u) {
    AbstractSpan span = ContextManager.createLocalSpan(operationName + "/accept");
    span.setComponent(ComponentsDefine.LETTUCE);
    Tags.DB_TYPE.set(span, "Redis");
    SpanLayer.asCache(span);
    try {
        ContextManager.continued(snapshot);
        biConsumer.accept(t, u);
    } catch (Throwable th) {
        ContextManager.activeSpan().errorOccurred().log(th);
    } finally {
        ContextManager.stopSpan();
    }
}
 
Example 5
Source File: SWConsumer.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Override
public void accept(T t) {
    AbstractSpan span = ContextManager.createLocalSpan(operationName + "/accept");
    span.setComponent(ComponentsDefine.LETTUCE);
    Tags.DB_TYPE.set(span, "Redis");
    SpanLayer.asCache(span);
    try {
        ContextManager.continued(snapshot);
        consumer.accept(t);
    } catch (Throwable th) {
        ContextManager.activeSpan().errorOccurred().log(th);
    } finally {
        ContextManager.stopSpan();
    }
}
 
Example 6
Source File: XMemcachedMethodInterceptor.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@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.XMEMCACHED);
    Tags.DB_TYPE.set(span, ComponentsDefine.XMEMCACHED.getName());
    SpanLayer.asCache(span);
    Tags.DB_STATEMENT.set(span, method.getName() + " " + allArguments[0]);
}
 
Example 7
Source File: JedisMethodInterceptor.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@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("Jedis/" + method.getName(), peer);
    span.setComponent(ComponentsDefine.JEDIS);
    Tags.DB_TYPE.set(span, "Redis");
    SpanLayer.asCache(span);

    if (allArguments.length > 0 && allArguments[0] instanceof String) {
        Tags.DB_STATEMENT.set(span, method.getName() + " " + allArguments[0]);
    } else if (allArguments.length > 0 && allArguments[0] instanceof byte[]) {
        Tags.DB_STATEMENT.set(span, method.getName());
    }
}
 
Example 8
Source File: MemcachedMethodInterceptor.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@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(SPY_MEMCACHE + method.getName(), peer);
    span.setComponent(ComponentsDefine.SPYMEMCACHED);
    Tags.DB_TYPE.set(span, ComponentsDefine.SPYMEMCACHED.getName());
    SpanLayer.asCache(span);
    Tags.DB_STATEMENT.set(span, getStatement(method, allArguments));
}
 
Example 9
Source File: EhcacheOperateElementInterceptor.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
    MethodInterceptResult result) throws Throwable {
    EhcacheEnhanceInfo enhanceInfo = (EhcacheEnhanceInfo) objInst.getSkyWalkingDynamicField();

    AbstractSpan span = ContextManager.createLocalSpan("Ehcache/" + method.getName() + "/" + enhanceInfo.getCacheName());
    span.setComponent(ComponentsDefine.EHCACHE);
    SpanLayer.asCache(span);

    Element element = (Element) allArguments[0];
    if (element != null && element.getObjectKey() != null) {
        Tags.DB_STATEMENT.set(span, element.getObjectKey().toString());
    }
}
 
Example 10
Source File: EhcacheOperateObjectInterceptor.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
    MethodInterceptResult result) throws Throwable {
    EhcacheEnhanceInfo enhanceInfo = (EhcacheEnhanceInfo) objInst.getSkyWalkingDynamicField();

    AbstractSpan span = ContextManager.createLocalSpan("Ehcache/" + method.getName() + "/" + enhanceInfo.getCacheName());
    span.setComponent(ComponentsDefine.EHCACHE);
    SpanLayer.asCache(span);

    Object element = allArguments[0];
    if (element != null) {
        Tags.DB_STATEMENT.set(span, element.toString());
    }
}
 
Example 11
Source File: EhcacheOperateAllInterceptor.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
    MethodInterceptResult result) throws Throwable {
    EhcacheEnhanceInfo enhanceInfo = (EhcacheEnhanceInfo) objInst.getSkyWalkingDynamicField();

    AbstractSpan span = ContextManager.createLocalSpan("Ehcache/" + method.getName() + "/" + enhanceInfo.getCacheName());
    span.setComponent(ComponentsDefine.EHCACHE);
    SpanLayer.asCache(span);
}