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

**URL:** <https://discuss.elastic.co/t/will-add-unique-traceid-per-request-to-trace-the-cost-time/25231>\
**Category:** Elasticsearch\
**Created:** [July 9, 2015, 12:44pm UTC](https://discuss.elastic.co/t/will-add-unique-traceid-per-request-to-trace-the-cost-time/25231 "2015-07-09T12:44:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![11169](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/11169/32/1158_2.png) [@11169](https://discuss.elastic.co/u/11169)\
**Post date:** [July 9, 2015, 12:44pm UTC](https://discuss.elastic.co/t/will-add-unique-traceid-per-request-to-trace-the-cost-time/25231/1 "2015-07-09T12:44:06Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [July 9, 2015, 1:19pm UTC](https://discuss.elastic.co/t/will-add-unique-traceid-per-request-to-trace-the-cost-time/25231/2 "2015-07-09T13:19:06Z")

</div>

> [@11169](#):
>
> In my application, there is a global unique traceId per user request. It will be used to trace the business processes and cost time.

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](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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:02am UTC](https://discuss.elastic.co/t/will-add-unique-traceid-per-request-to-trace-the-cost-time/25231/3 "2017-07-06T00:02:34Z")

</div>


