Will add unique traceId per request to trace the cost time?


(黄兴海) #1

In my application, there is a global unique traceId per user request. It will be used to trace the business processes and cost time. And I want to use this traceId to trace more details of es, e.g. the cost time of query/fetch phrase on each node. Will it be possible?


(Nik Everett) #2

This is generally a great practice.

First tip: don't put it in the "stats" section of the search request. I can't find the documentation on it, but look at how we do it: https://en.wikipedia.org/wiki/Special:Search/foo%20bar%20bing?cirrusDumpQuery . The stats section makes new counters. You don't new counters for each unique id.

I thought there was a similar thing to stats that didn't make a new counter - it just sat in the query so it could be logged just in case but I can't find it. You might want to add it as a fake term query in a "should" in a "bool" query. Then the term they are searching doesn't exist they are quite low cost. I don't know if they are low cost enough for this though.


(system) #3