apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/support/ActionListenerAdapter.java [32:90]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class ActionListenerAdapter<T> implements ActionListener<T>, EnhancedInstance {

    private final RestClientCache<T> restClientCache;

    public ActionListenerAdapter(RestClientCache<T> restClientCache) {
        this.restClientCache = restClientCache;
    }

    @Override
    public void onResponse(final T o) {
        try {
            if (restClientCache.getContextSnapshot() != null) {
                continueContext(Constants.ON_RESPONSE_SUFFIX);
            }
            if (restClientCache.getActionListener() != null) {
                restClientCache.getActionListener().onResponse(o);
            }
        } catch (Throwable t) {
            ContextManager.activeSpan().log(t);
            throw t;
        } finally {
            restClientCache.setContextSnapshot(null);
            ContextManager.stopSpan();
        }
    }

    @Override
    public void onFailure(final Exception e) {
        try {
            if (restClientCache.getContextSnapshot() != null) {
                continueContext(Constants.ON_FAILURE_SUFFIX);
            }
            if (restClientCache.getActionListener() != null) {
                restClientCache.getActionListener().onFailure(e);
            }
        } catch (Throwable t) {
            ContextManager.activeSpan().log(t);
            throw t;
        } finally {
            ContextManager.stopSpan();
        }
    }

    @Override
    public Object getSkyWalkingDynamicField() {
        return restClientCache;
    }

    @Override
    public void setSkyWalkingDynamicField(final Object enhanceInfo) {

    }

    private void continueContext(String action) {
        AbstractSpan activeSpan = ContextManager.createLocalSpan(restClientCache.getOperationName() + action);
        activeSpan.setComponent(ComponentsDefine.REST_HIGH_LEVEL_CLIENT);
        Tags.DB_TYPE.set(activeSpan, DB_TYPE);
        SpanLayer.asDB(activeSpan);
        ContextManager.continued(restClientCache.getContextSnapshot());
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



apm-sniffer/apm-sdk-plugin/elasticsearch-7.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v7/support/ActionListenerAdapter.java [32:90]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class ActionListenerAdapter<T> implements ActionListener<T>, EnhancedInstance {

    private final RestClientCache<T> restClientCache;

    public ActionListenerAdapter(RestClientCache<T> restClientCache) {
        this.restClientCache = restClientCache;
    }

    @Override
    public void onResponse(final T o) {
        try {
            if (restClientCache.getContextSnapshot() != null) {
                continueContext(Constants.ON_RESPONSE_SUFFIX);
            }
            if (restClientCache.getActionListener() != null) {
                restClientCache.getActionListener().onResponse(o);
            }
        } catch (Throwable t) {
            ContextManager.activeSpan().log(t);
            throw t;
        } finally {
            restClientCache.setContextSnapshot(null);
            ContextManager.stopSpan();
        }
    }

    @Override
    public void onFailure(final Exception e) {
        try {
            if (restClientCache.getContextSnapshot() != null) {
                continueContext(Constants.ON_FAILURE_SUFFIX);
            }
            if (restClientCache.getActionListener() != null) {
                restClientCache.getActionListener().onFailure(e);
            }
        } catch (Throwable t) {
            ContextManager.activeSpan().log(t);
            throw t;
        } finally {
            ContextManager.stopSpan();
        }
    }

    @Override
    public Object getSkyWalkingDynamicField() {
        return restClientCache;
    }

    @Override
    public void setSkyWalkingDynamicField(final Object enhanceInfo) {

    }

    private void continueContext(String action) {
        AbstractSpan activeSpan = ContextManager.createLocalSpan(restClientCache.getOperationName() + action);
        activeSpan.setComponent(ComponentsDefine.REST_HIGH_LEVEL_CLIENT);
        Tags.DB_TYPE.set(activeSpan, DB_TYPE);
        SpanLayer.asDB(activeSpan);
        ContextManager.continued(restClientCache.getContextSnapshot());
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



