# How to get the trace\_id and span\_id using the OneAgent SDK for Python?

**URL:** <https://community.dynatrace.com/t/how-to-get-the-trace-id-and-span-id-using-the-oneagent-sdk-for-python/37590>\
**Category:** Extensions\
**Tags:** python, oneagent-sdk\
**Created:** [December 6, 2022, 1:22pm UTC](https://community.dynatrace.com/t/how-to-get-the-trace-id-and-span-id-using-the-oneagent-sdk-for-python/37590 "2022-12-06T13:22:04Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![AymericM](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/aymericm/32/38607_2.png) [@AymericM](https://community.dynatrace.com/u/AymericM)\
**Post date:** [December 6, 2022, 1:22pm UTC](https://community.dynatrace.com/t/how-to-get-the-trace-id-and-span-id-using-the-oneagent-sdk-for-python/37590/1 "2022-12-06T13:22:04Z")

</div>

Hi,

I see in the OneAgent SDK documentation that there is a way to get a trace\_i and span\_id from the&nbsp;TraceContextInfo&nbsp;([OneAgent-SDK/README.md at master · Dynatrace/OneAgent-SDK · GitHub](https://github.com/Dynatrace/OneAgent-SDK/blob/master/README.md#trace-context))

I may be missing something but I can’t find how to do it with the OneAgent SDK for Python.

Is there a way to enrich logs with trace\_id and span\_id dierctly from a Python script/app ?

---

_[View the full topic](https://community.dynatrace.com/t/how-to-get-the-trace-id-and-span-id-using-the-oneagent-sdk-for-python/37590)._
