skywalking icon indicating copy to clipboard operation
skywalking copied to clipboard

[Feature] Provide option to support auto-generate doc id by ES for insert trace record when use elasticsearch storage

Open samz-github opened this issue 2 years ago • 1 comments

Search before asking

  • [X] I had searched in the issues and found no similar feature requirement.

Description

My corporation elasticsearch DBA feedback to me that skywalking use custom doc id butnot auto-generated by ES cluster, and it makes ES performace not good. I have checked storage-eleasticsearch-plugin source code. Skywalking OAP query ES with the doc id for UI template. For query trace record, not using doc id, but other ES field, like segment_id or trace_id. Can we not to generate custom doc id when insert trace recod in ES? Instead, it just let ES auto generate doc id when inserting trace record.

`

@Override
public InsertRequest prepareBatchInsert(Model model, Record record) throws IOException {
    final ElasticSearchConverter.ToStorage toStorage = new ElasticSearchConverter.ToStorage(model.getName());
    storageBuilder.entity2Storage(record, toStorage);
    Map<String, Object> builder = IndexController.INSTANCE.appendTableColumn(model, toStorage.obtain());
    String modelName = TimeSeriesUtils.writeIndexName(model, record.getTimeBucket());
    String id = IndexController.INSTANCE.generateDocId(model, record.id().build());
    Optional<String> routingValue = RoutingUtils.getRoutingValue(model, toStorage);
    return getClient().prepareInsert(modelName, id, routingValue, builder);
}

`

Use case

It helps to improve ES performace when insert and search ES trace records, especially for huge trace records everyday .

Related issues

No response

Are you willing to submit a pull request to implement this on your own?

  • [X] Yes I am willing to submit a pull request on my own!

Code of Conduct

samz-github avatar Sep 27 '24 07:09 samz-github

This is intentional. We controlled the ID to make sure it would be updated by doc ID, rather than query condition. This improves the performance.

wu-sheng avatar Sep 27 '24 07:09 wu-sheng