opentelemetry-specification icon indicating copy to clipboard operation
opentelemetry-specification copied to clipboard

Add process.threads

Open atoulme opened this issue 3 years ago • 6 comments

Changes

Adds a new metric, process.threads.count, to the process metrics available.

Related issues https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/12482

atoulme avatar Aug 02 '22 00:08 atoulme

Changelog updated, thanks!

atoulme avatar Aug 02 '22 16:08 atoulme

Here is a bit I'll present tomorrow at the spec meeting: I believe process.threads is a finite metric, and will not be used as a namespace. An other namespace, under thread.*, should be created if we ever standardize data under a thread. This is because listening to thread activity would typically be done via a different type of monitor than a monitor for processes. For threads, we would use instrumentation in-process, such as jmx, to listen to thread activity.

atoulme avatar Aug 08 '22 17:08 atoulme

@jmacd are you proposing process.runtime.thread.count?

bogdandrutu avatar Aug 09 '22 15:08 bogdandrutu

I feel that this semantic convention belongs in the process.runtime.* section. In Go, for example, there is no "thread" concept and we already have a runtime-metrics count of goroutines.

I think the fact that Golang and Node.js don't have thread is a good reason why this shouldn't be part of process.runtime.*. I feel threads is an operating system concept. Although there are indeed operating systems that don't have threads, it seems pretty common to park it under OS and process.

reyang avatar Aug 09 '22 15:08 reyang

@jmacd are you proposing process.runtime.thread.count?

process.runtime.thread.count might have a different semantic.

I'll take .NET as an example, process.thread.count could mean "how many threads does this process have (from the operating system's point of view)", while process.runtime.thread.count could mean "how many managed threads (and a better name might be process.runtime.dotnet.managed_threads because it's explicit and it doesn't make much sense to maintain the same name between .NET and Java - to avoid accidental join/merge) does the .NET runtime inside this process have" (and there could be a more complex situation where multiple instances of runtime coexist, although I've never seen that in reality except for some SQL stored procedure hosting).

reyang avatar Aug 09 '22 15:08 reyang

I agree with @reyang - as said on Slack:

the process.runtime namespace does not allow to set a threads entry in it, since it is supposed to process.runtime.{environment} as per spec: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/runtime-environment-metrics.md Second, the number of threads is the number of threads exposed at the OS level, not the level of threads or goroutines as experienced inside the program. That's the difference say between looking at Java threads and the number of threads in top -H -p <pid>.

atoulme avatar Aug 09 '22 20:08 atoulme

@jmacd and anyone - any insights or follow up?

atoulme avatar Aug 15 '22 19:08 atoulme

Let's discuss it on today's call (with whoever can make it) - hopefully we can merge this (either with minor renaming or not) today ;)

carlosalberto avatar Aug 16 '22 13:08 carlosalberto

I feel that this semantic convention belongs in the process.runtime.* section. In Go, for example, there is no "thread" concept and we already have a runtime-metrics count of goroutines.

Inside the go VM indeed cannot read threads, from outside you can actually read the number of OS threads for the go process.

bogdandrutu avatar Aug 16 '22 15:08 bogdandrutu

What is the next step here?

atoulme avatar Aug 17 '22 04:08 atoulme

@jmacd Do you have a strong instance against going with process.threads? This was briefly discussed in the past Spec call, and the Golang case was deemed as a very-specific case compared to the rest of the languages, when it comes to this item, so we could deem it as a special case (Python also has coroutines, but it also has threads - that is the closest IIRC).

carlosalberto avatar Aug 17 '22 14:08 carlosalberto