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

Introduce jvm.thread.daemon and jvm.thread.state attributes #297

Merged
merged 8 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ release.
([#410](https://github.com/open-telemetry/semantic-conventions/pull/410))
- BREAKING: Factor in `X-Forwarded-Host` / `Forwarded` when capturing `server.address` and `server.port`.
([#411](https://github.com/open-telemetry/semantic-conventions/pull/411))
- Remove `thread.daemon`, and introduce `jvm.thread.daemon` instead.
Introduce `jvm.thread.state` attribute and add it to `jvm.thread.count` metric.
([#297](https://github.com/open-telemetry/semantic-conventions/pull/297))

### Features

Expand Down
1 change: 0 additions & 1 deletion docs/general/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ a thread that started a span.
<!-- semconv thread -->
| Attribute | Type | Description | Examples | Requirement Level |
|---|---|---|---|---|
| `thread.daemon` | boolean | Whether the thread is daemon or not. | | Recommended |
| `thread.id` | int | Current "managed" thread ID (as opposed to OS thread ID). | `42` | Recommended |
| `thread.name` | string | Current thread name. | `main` | Recommended |
<!-- endsemconv -->
Expand Down
23 changes: 20 additions & 3 deletions docs/runtime/jvm-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,13 @@ of `[]` (single bucket histogram capturing count, sum, min, max).
### Metric: `jvm.thread.count`

This metric is [recommended][MetricRecommended].
This metric is obtained from [`ThreadMXBean#getDaemonThreadCount()`](https://docs.oracle.com/javase/8/docs/api/java/lang/management/ThreadMXBean.html#getDaemonThreadCount--) and
[`ThreadMXBean#getThreadCount()`](https://docs.oracle.com/javase/8/docs/api/java/lang/management/ThreadMXBean.html#getThreadCount--).
This metric is obtained from a combination of

* [`ThreadMXBean#getAllThreadIds()`](https://docs.oracle.com/javase/8/docs/api/java/lang/management/ThreadMXBean.html#getAllThreadIds--)
* [`ThreadMXBean#getThreadInfo()`](https://docs.oracle.com/javase/8/docs/api/java/lang/management/ThreadMXBean.html#getThreadInfo-long:A-)
* [`ThreadInfo#getThreadState()`](https://docs.oracle.com/javase/8/docs/api/java/lang/management/ThreadInfo.html#getThreadState--)
* [`ThreadInfo#isDaemon()`](https://docs.oracle.com/en/java/javase/11/docs/api/java.management/java/lang/management/ThreadInfo.html#isDaemon()) (requires Java 9+)

Note that this is the number of platform threads (as opposed to virtual threads).

<!-- semconv metric.jvm.thread.count(metric_table) -->
Expand All @@ -202,7 +207,19 @@ Note that this is the number of platform threads (as opposed to virtual threads)
<!-- semconv metric.jvm.thread.count(full) -->
| Attribute | Type | Description | Examples | Requirement Level |
|---|---|---|---|---|
| [`thread.daemon`](../general/attributes.md) | boolean | Whether the thread is daemon or not. | | Recommended |
| `jvm.thread.daemon` | boolean | Whether the thread is daemon or not. | | Recommended |
| `jvm.thread.state` | string | State of the thread. | `runnable`; `blocked` | Recommended |
jonatan-ivanov marked this conversation as resolved.
Show resolved Hide resolved

`jvm.thread.state` MUST be one of the following:

| Value | Description |
|---|---|
| `new` | A thread that has not yet started is in this state. |
| `runnable` | A thread executing in the Java virtual machine is in this state. |
| `blocked` | A thread that is blocked waiting for a monitor lock is in this state. |
| `waiting` | A thread that is waiting indefinitely for another thread to perform a particular action is in this state. |
| `timed_waiting` | A thread that is waiting for another thread to perform an action for up to a specified waiting time is in this state. |
| `terminated` | A thread that has exited is in this state. |
<!-- endsemconv -->

## JVM Classes
Expand Down
3 changes: 0 additions & 3 deletions model/general.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ groups:
brief: >
Current thread name.
examples: main
- id: daemon
brief: "Whether the thread is daemon or not."
type: boolean
- id: code
prefix: code
type: span
Expand Down
29 changes: 28 additions & 1 deletion model/metrics/jvm-metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,35 @@ groups:
instrument: updowncounter
unit: "{thread}"
attributes:
- ref: thread.daemon
- id: jvm.thread.daemon
type: boolean
requirement_level: recommended
brief: "Whether the thread is daemon or not."
- id: jvm.thread.state
requirement_level: recommended
type:
allow_custom_values: false
members:
- id: new
value: 'new'
brief: 'A thread that has not yet started is in this state.'
- id: runnable
value: 'runnable'
brief: 'A thread executing in the Java virtual machine is in this state.'
- id: blocked
value: 'blocked'
brief: 'A thread that is blocked waiting for a monitor lock is in this state.'
- id: waiting
value: 'waiting'
brief: 'A thread that is waiting indefinitely for another thread to perform a particular action is in this state.'
- id: timed_waiting
value: 'timed_waiting'
brief: 'A thread that is waiting for another thread to perform an action for up to a specified waiting time is in this state.'
- id: terminated
value: 'terminated'
brief: 'A thread that has exited is in this state.'
brief: "State of the thread."
examples: ["runnable", "blocked"]

- id: metric.jvm.class.loaded
type: metric
Expand Down
8 changes: 8 additions & 0 deletions schema-next.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ file_format: 1.1.0
schema_url: https://opentelemetry.io/schemas/next
versions:
next:
metrics:
changes:
# https://github.com/open-telemetry/semantic-conventions/pull/20
- rename_attributes:
attribute_map:
thread.daemon: jvm.thread.daemon
apply_to_metrics:
- jvm.thread.count
1.22.0:
spans:
changes:
Expand Down
Loading