Search in sources :

Example 1 with ClusterInfoAccessor

use of com.navercorp.pinpoint.plugin.elasticsearch.accessor.ClusterInfoAccessor in project pinpoint by naver.

the class ElasticsearchExecutorInterceptor method recordeESattributes.

// TODO max dsl limit need
private void recordeESattributes(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
    if (recordESVersion) {
        if (target instanceof ClusterInfoAccessor) {
            // record elasticsearch version and cluster name.
            recorder.recordAttribute(ElasticsearchConstants.ARGS_VERSION_ANNOTATION_KEY, ((ClusterInfoAccessor) target)._$PINPOINT$_getClusterInfo());
        }
    }
    if (recordDsl) {
        if (args[0] instanceof SearchRequest) {
            SearchRequest request = (SearchRequest) args[0];
            recorder.recordAttribute(ElasticsearchConstants.ARGS_DSL_ANNOTATION_KEY, StringUtils.abbreviate(request.source().toString(), 256));
        } else if (args[0] instanceof GetRequest) {
            // GetRequest request = (GetRequest) args[0];
            recorder.recordAttribute(ElasticsearchConstants.ARGS_DSL_ANNOTATION_KEY, StringUtils.abbreviate(args[0].toString(), 256));
        } else if (args[0] instanceof IndexRequest) {
            // IndexRequest request = (IndexRequest) args[0];
            recorder.recordAttribute(ElasticsearchConstants.ARGS_DSL_ANNOTATION_KEY, StringUtils.abbreviate(args[0].toString(), 256));
        } else if (args[0] instanceof DeleteRequest) {
            // DeleteRequest request = (DeleteRequest) args[0];
            recorder.recordAttribute(ElasticsearchConstants.ARGS_DSL_ANNOTATION_KEY, StringUtils.abbreviate(args[0].toString(), 256));
        } else if (args[0] instanceof UpdateRequest) {
            // UpdateRequest request = (UpdateRequest) args[0];
            recorder.recordAttribute(ElasticsearchConstants.ARGS_DSL_ANNOTATION_KEY, StringUtils.abbreviate(args[0].toString(), 256));
        }
    }
}
Also used : SearchRequest(org.elasticsearch.action.search.SearchRequest) UpdateRequest(org.elasticsearch.action.update.UpdateRequest) ClusterInfoAccessor(com.navercorp.pinpoint.plugin.elasticsearch.accessor.ClusterInfoAccessor) GetRequest(org.elasticsearch.action.get.GetRequest) IndexRequest(org.elasticsearch.action.index.IndexRequest) DeleteRequest(org.elasticsearch.action.delete.DeleteRequest)

Aggregations

ClusterInfoAccessor (com.navercorp.pinpoint.plugin.elasticsearch.accessor.ClusterInfoAccessor)1 DeleteRequest (org.elasticsearch.action.delete.DeleteRequest)1 GetRequest (org.elasticsearch.action.get.GetRequest)1 IndexRequest (org.elasticsearch.action.index.IndexRequest)1 SearchRequest (org.elasticsearch.action.search.SearchRequest)1 UpdateRequest (org.elasticsearch.action.update.UpdateRequest)1