Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add semantic conventions for thread.name and thread.id span attributes #788

Closed
mateuszrzeszutek opened this issue Aug 12, 2020 · 4 comments · Fixed by #789
Closed

Add semantic conventions for thread.name and thread.id span attributes #788

mateuszrzeszutek opened this issue Aug 12, 2020 · 4 comments · Fixed by #789
Labels
area:semantic-conventions Related to semantic conventions release:after-ga Not required before GA release, and not going to work on before GA spec:trace Related to the specification/trace directory

Comments

@mateuszrzeszutek
Copy link
Member

What are you trying to achieve?

Currently there's no semantic convention for adding executing thread info as span attributes. My proposition is to add two new general span attributes that may store the executing thread's id and name:

Attribute name Notes and examples
thread.id Current thread id, if exposed by the platform. E.g. 42
thread.name Current thread name. E.g. main

Additional context.

This change is mostly motivated by the Java world, but I believe that it's a language agnostic concept that may also be present in other languages, e.g.:

  • Python has both threading.current_thread().ident and threading.current_thread().name
  • Ruby can provide info about name Thread.current.name
  • In C# you can use Thread.CurrentThread.ManagedThreadId and Thread.CurrentThread.Name

Also, see related issue: open-telemetry/opentelemetry-java-instrumentation#942

@anuraaga
Copy link
Contributor

anuraaga commented Aug 12, 2020

Thanks for filing! Thread name seems like it could be quite useful, for example debugging latency issues caused by blocking event loop threads. Thread ID seems like it'd be very random though, for example, if the app restarts, the same ID could be doing something totally different I believe. Do you have a concrete example of using thread ID in a backend?

@iNikem
Copy link
Contributor

iNikem commented Aug 12, 2020

Thread id can be useful in those cases where several threads have the same name due to badly configured thread pool.

@Oberon00
Copy link
Member

Oberon00 commented Aug 12, 2020

A SpanProcessor that adds the thread info in OnStart could also be added.

@Oberon00
Copy link
Member

Note that there can be multiple IDs for the same thread. The "mangaged" thread ID, the OS thread ID (Linux LWP#), sometimes an additional thread ID (like what pthread_self() returns). Probably the managed thread ID is the most interesting, as it is also the most deterministic (often starts at 1 and increments by 1 for every thread the runtime starts), while the OS thread ID can be semi-random or increment across all processes.

@Oberon00 Oberon00 added the release:after-ga Not required before GA release, and not going to work on before GA label Aug 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:semantic-conventions Related to semantic conventions release:after-ga Not required before GA release, and not going to work on before GA spec:trace Related to the specification/trace directory
Projects
None yet
5 participants