Skip to content

Commit

Permalink
Add node.js runtime metrics semantic conventions
Browse files Browse the repository at this point in the history
Fixes open-telemetry#990

Signed-off-by: maryliag <[email protected]>
  • Loading branch information
maryliag committed May 3, 2024
1 parent 1279742 commit 76a76b4
Show file tree
Hide file tree
Showing 8 changed files with 253 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .chloggen/nodejs-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Use this changelog template to create an entry for release notes.
#
# If your change doesn't affect end users you should instead start
# your pull request title with [chore] or use the "Skip Changelog" label.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: new_component

# The name of the area of concern in the attributes-registry, (e.g. http, cloud, db)
component: nodejs

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Introducing semantic conventions for Node.js specific metrics.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
# The values here must be integers.
issues: [990]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ body:
- area:log
- area:messaging
- area:network
- area:nodejs
- area:oci
- area:opentracing
- area:os
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/change_proposal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ body:
- area:log
- area:messaging
- area:network
- area:nodejs
- area:oci
- area:opentracing
- area:os
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/new-conventions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ body:
- area:log
- area:messaging
- area:network
- area:nodejs
- area:oci
- area:opentracing
- area:os
Expand Down
1 change: 1 addition & 0 deletions docs/runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Also consider the
semantic conventions when instrumenting runtime environments.

- [JVM](jvm-metrics.md)
- [Node.js](nodejs-metrics.md)

### Attributes

Expand Down
128 changes: 128 additions & 0 deletions docs/runtime/nodejs-metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<!--- Hugo front matter used to generate the website version of this page:
linkTitle: Node.js
--->

# Semantic Conventions for Node.js Metrics

**Status**: [Experimental][DocumentStatus]

This document describes semantic conventions for Node.js metrics in OpenTelemetry.

<!-- Re-generate TOC with `markdown-toc --no-first-h1 -i` -->

<!-- toc -->

- [Experimental](#experimental)
- [Metric: `nodejs.active_handles.count`](#metric-nodejsactive_handlescount)
- [Metric: `nodejs.active_requests.count`](#metric-nodejsactive_requestscount)
- [Metric: `nodejs.eventloop.lag`](#metric-nodejseventlooplag)
- [Metric: `nodejs.gc.duration`](#metric-nodejsgcduration)
- [Metric: `nodejs.memory.size`](#metric-nodejsmemorysize)

<!-- tocstop -->

## Experimental

**Status**: [Experimental][DocumentStatus]

**Description:** Experimental Node.js metrics captured under `nodejs.`

### Metric: `nodejs.active_handles.count`

This metric is [recommended][MetricRecommended].

<!-- semconv metric.nodejs.active_handles.count(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `nodejs.active_handles.count` | UpDownCounter | `{handles}` | Number of active handles. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->

<!-- semconv metric.nodejs.active_handles.count(full) -->
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `nodejs.version` | string | Node.js version. | `v22.0.0`; `v21.7.3` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->

### Metric: `nodejs.active_requests.count`

This metric is [recommended][MetricRecommended].

<!-- semconv metric.nodejs.active_requests.count(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `nodejs.active_requests.count` | UpDownCounter | `{requests}` | Number of active requests. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->

<!-- semconv metric.nodejs.active_requests.count(full) -->
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `nodejs.version` | string | Node.js version. | `v22.0.0`; `v21.7.3` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->

### Metric: `nodejs.eventloop.lag`

This metric is [recommended][MetricRecommended].

<!-- semconv metric.nodejs.eventloop.lag(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `nodejs.eventloop.lag` | Histogram | `s` | Event loop lag. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->

<!-- semconv metric.nodejs.eventloop.lag(full) -->
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `nodejs.version` | string | Node.js version. | `v22.0.0`; `v21.7.3` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->

### Metric: `nodejs.gc.duration`

This metric is [recommended][MetricRecommended].

<!-- semconv metric.nodejs.gc.duration(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `nodejs.gc.duration` | Histogram | `s` | Garbage collection duration. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->

<!-- semconv metric.nodejs.gc.duration(full) -->
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `nodejs.gc.name` | string | Name of the garbage collector. | `G1 Young Generation`; `G1 Old Generation` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `nodejs.version` | string | Node.js version. | `v22.0.0`; `v21.7.3` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->

### Metric: `nodejs.memory.size`

This metric is [recommended][MetricRecommended].

<!-- semconv metric.nodejs.memory.size(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `nodejs.memory.size` | UpDownCounter | `By` | Memory size. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->

<!-- semconv metric.nodejs.memory.size(full) -->
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `nodejs.memory.state` | string | The state of memory. | `total`; `used` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `nodejs.memory.type` | string | The type of memory. | `heap`; `external` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `nodejs.version` | string | Node.js version. | `v22.0.0`; `v21.7.3` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

`nodejs.memory.state` MUST be one of the following:

| Value | Description | Stability |
|---|---|---|
| `total` | Total memory. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `used` | Used memory | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

`nodejs.memory.type` MUST be one of the following:

| Value | Description | Stability |
|---|---|---|
| `heap` | Heap memory. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `external` | External memory | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->

[DocumentStatus]: https://github.com/open-telemetry/opentelemetry-specification/tree/v1.31.0/specification/document-status.md
[MetricRecommended]: /docs/general/metric-requirement-level.md#recommended
87 changes: 87 additions & 0 deletions model/metrics/nodejs-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
groups:
- id: metric.nodejs.active_handles.count
type: metric
metric_name: nodejs.active_handles.count
brief: "Number of active handles."
extends: attributes.nodejs.version
instrument: updowncounter
unit: "{handles}"
stability: experimental

- id: metric.nodejs.active_requests.count
type: metric
metric_name: nodejs.active_requests.count
brief: "Number of active requests."
extends: attributes.nodejs.version
instrument: updowncounter
unit: "{requests}"
stability: experimental

- id: metric.nodejs.eventloop.lag
type: metric
metric_name: nodejs.eventloop.lag
brief: "Event loop lag."
extends: attributes.nodejs.version
instrument: histogram
unit: "s"
stability: experimental

- id: metric.nodejs.gc.duration
type: metric
metric_name: nodejs.gc.duration
brief: "Garbage collection duration."
extends: attributes.nodejs.version
instrument: histogram
unit: "s"
stability: experimental
prefix: nodejs.gc
attributes:
- id: name
stability: experimental
type: string
requirement_level: recommended
brief: Name of the garbage collector.
examples: ["G1 Young Generation", "G1 Old Generation"]

- id: metric.nodejs.memory.size
type: metric
metric_name: nodejs.memory.size
brief: "Memory size."
extends: attributes.nodejs.version
instrument: updowncounter
unit: "By"
stability: experimental
prefix: nodejs.memory
attributes:
- id: type
stability: experimental
type:
allow_custom_values: false
members:
- id: heap
value: 'heap'
brief: 'Heap memory.'
stability: experimental
- id: external
value: 'external'
brief: 'External memory'
stability: experimental
requirement_level: recommended
brief: The type of memory.
examples: ["heap", "external"]
- id: state
stability: experimental
type:
allow_custom_values: false
members:
- id: total
value: 'total'
brief: 'Total memory.'
stability: experimental
- id: used
value: 'used'
brief: 'Used memory'
stability: experimental
requirement_level: recommended
brief: The state of memory.
examples: ["total", "used"]
12 changes: 12 additions & 0 deletions model/registry/nodejs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
groups:
- id: attributes.nodejs.version
type: attribute_group
brief: "Describes Node.js version attribute."
prefix: nodejs
attributes:
- id: version
stability: experimental
type: string
requirement_level: recommended
brief: Node.js version.
examples: ["v22.0.0", "v21.7.3"]

0 comments on commit 76a76b4

Please sign in to comment.