Skip to content

Commit

Permalink
add experimental go runtime metrics semantic conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
dashpole committed May 21, 2024
1 parent 6f39cae commit 16d3a0a
Show file tree
Hide file tree
Showing 4 changed files with 284 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .chloggen/go-runtime-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: go

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add new go namespace for Go runtime 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: [535]

# (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 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)
- [Go](go-metrics.md)

### Attributes

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

# Semantic Conventions for Go Runtime Metrics

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

This document describes semantic conventions for Go runtime metrics in OpenTelemetry.

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

<!-- toc -->

- [Go Memory](#go-memory)
- [Metric: `go.memory.used`](#metric-gomemoryused)
- [Metric: `go.memory.limit`](#metric-gomemorylimit)
- [Metric: `go.memory.allocated`](#metric-gomemoryallocated)
- [Metric: `go.memory.allocations`](#metric-gomemoryallocations)
- [Go Garbage Collection](#go-garbage-collection)
- [Metric: `go.memory.gc.target`](#metric-gomemorygctarget)
- [Metric: `go.memory.gc.user_target`](#metric-gomemorygcuser_target)
- [Go Threads](#go-threads)
- [Metric: `go.thread.limit`](#metric-gothreadlimit)
- [Go Scheduler](#go-scheduler)
- [Metric: `go.schedule.duration`](#metric-goscheduleduration)

<!-- tocstop -->

## Go Memory

**Description:** Go runtime metrics captured under the namespace `go.memory.*`

### Metric: `go.memory.used`

This metric is [recommended][MetricRecommended].
This metric is obtained from Go's [`runtime/metrics`][RuntimeMetrics] package using `/memory/classes` metrics.

<!-- semconv metric.go.memory.used(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `go.memory.used` | UpDownCounter | `By` | Virtual memory mapped by the Go runtime. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->

<!-- semconv metric.go.memory.used(full) -->
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `go.memory.type` | string | The type of memory. | `released`; `stack` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

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

| Value | Description | Stability |
|---|---|---|
| `released` | Memory that is completely free and has been returned to the underlying system. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `stack` | Memory allocated from the heap that is reserved for stack space, whether or not it is currently in-use. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `other` | All memory mapped by the Go runtime into the current process as read-write, excluding other categories of memory usage. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->

### Metric: `go.memory.limit`

This metric is [recommended][MetricRecommended].
This metric is obtained from Go's [`runtime/metrics`][RuntimeMetrics] package using `/gc/gomemlimit:bytes`.

<!-- semconv metric.go.memory.limit(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `go.memory.limit` | UpDownCounter | `By` | Go runtime memory limit configured by the user, otherwise math.MaxInt64. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->

<!-- semconv metric.go.memory.limit(full) -->
<!-- endsemconv -->

### Metric: `go.memory.allocated`

This metric is [recommended][MetricRecommended].
This metric is obtained from Go's [`runtime/metrics`][RuntimeMetrics] package using `/gc/heap/allocs:bytes`.

<!-- semconv metric.go.memory.allocated(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `go.memory.allocated` | Counter | `By` | Memory allocated to the heap by the application. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->

<!-- semconv metric.go.memory.allocated(full) -->
<!-- endsemconv -->

### Metric: `go.memory.allocations`

This metric is [recommended][MetricRecommended].
This metric is obtained from Go's [`runtime/metrics`][RuntimeMetrics] package using `/gc/heap/allocs:objects`.

<!-- semconv metric.go.memory.allocations(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `go.memory.allocations` | Counter | `{allocation}` | Count of allocations to the heap by the application. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->

<!-- semconv metric.go.memory.allocations(full) -->
<!-- endsemconv -->

## Go Garbage Collection

**Description:** Go metrics captured under the namespace `go.memory.gc.*`

### Metric: `go.memory.gc.target`

This metric is [recommended][MetricRecommended].
This metric is obtained from Go's [`runtime/metrics`][RuntimeMetrics] package using `/gc/heap/goal:bytes`.

<!-- semconv metric.go.memory.gc.target(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `go.memory.gc.target` | UpDownCounter | `By` | Heap size target for the end of the GC cycle. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->

<!-- semconv metric.go.memory.gc.target(full) -->
<!-- endsemconv -->

### Metric: `go.memory.gc.user_target`

This metric is [recommended][MetricRecommended].
This metric is obtained from Go's [`runtime/metrics`][RuntimeMetrics] package using `/gc/gogc:percent`.

<!-- semconv metric.go.memory.gc.user_target(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `go.memory.gc.user_target` | UpDownCounter | `1` | Heap size target ratio for the end of the GC cycle, as configured by the user. [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

**[1]:** The value range is [0.0,1.0].
<!-- endsemconv -->

<!-- semconv metric.go.memory.gc.user_target(full) -->
<!-- endsemconv -->

## Go Threads

**Description:** Go metrics captured under the namespace `go.thread.*`

### Metric: `go.thread.limit`

This metric is [recommended][MetricRecommended].
This metric is obtained from Go's [`runtime/metrics`][RuntimeMetrics] package `/sched/gomaxprocs:threads`.

<!-- semconv metric.go.thread.limit(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `go.thread.limit` | UpDownCounter | `{thread}` | The number of OS threads that can execute user-level Go code simultaneously. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->

<!-- semconv metric.go.thread.limit(full) -->
<!-- endsemconv -->

## Go Scheduler

**Description:** Go metrics captured under the namespace `go.schedule.*`

### Metric: `go.schedule.duration`

This metric is [recommended][MetricRecommended].
This metric is obtained from Go's [`runtime/metrics`][RuntimeMetrics] package `/sched/latencies:seconds`.

<!-- semconv metric.go.schedule.duration(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `go.schedule.duration` | Histogram | `s` | The time goroutines have spent in the scheduler in a runnable state before actually running. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->

<!-- semconv metric.go.schedule.duration(full) -->
<!-- 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
[RuntimeMetrics]: https://pkg.go.dev/runtime/metrics
88 changes: 88 additions & 0 deletions model/metrics/go-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
groups:
- id: metric.go.memory.used
type: metric
metric_name: go.memory.used
brief: "Virtual memory mapped by the Go runtime."
instrument: updowncounter
prefix: go.memory
unit: "By"
attributes:
- id: type
stability: experimental
type:
allow_custom_values: false
members:
- id: released
value: 'released'
brief: 'Memory that is completely free and has been returned to the underlying system.'
stability: experimental
- id: stack
value: 'stack'
brief: 'Memory allocated from the heap that is reserved for stack space, whether or not it is currently in-use.'
stability: experimental
- id: other
value: 'other'
brief: 'All memory mapped by the Go runtime into the current process as read-write, excluding other categories of memory usage.'
stability: experimental
requirement_level: recommended
brief: The type of memory.
examples: ["released", "stack"]
stability: experimental

- id: metric.go.memory.limit
type: metric
metric_name: go.memory.limit
brief: "Go runtime memory limit configured by the user, otherwise math.MaxInt64."
instrument: updowncounter
unit: "By"
stability: experimental

- id: metric.go.memory.allocated
type: metric
metric_name: go.memory.allocated
brief: "Memory allocated to the heap by the application."
instrument: counter
unit: "By"
stability: experimental

- id: metric.go.memory.allocations
type: metric
metric_name: go.memory.allocations
brief: "Count of allocations to the heap by the application."
instrument: counter
unit: "{allocation}"
stability: experimental

- id: metric.go.memory.gc.target
type: metric
metric_name: go.memory.gc.target
brief: "Heap size target for the end of the GC cycle."
instrument: updowncounter
unit: "By"
stability: experimental

- id: metric.go.memory.gc.user_target
type: metric
metric_name: go.memory.gc.user_target
brief: "Heap size target ratio for the end of the GC cycle, as configured by the user."
instrument: updowncounter
unit: "1"
note: >
The value range is [0.0,1.0].
stability: experimental

- id: metric.go.thread.limit
type: metric
metric_name: go.thread.limit
brief: "The number of OS threads that can execute user-level Go code simultaneously."
instrument: updowncounter
unit: "{thread}"
stability: experimental

- id: metric.go.schedule.duration
type: metric
metric_name: go.schedule.duration
brief: "The time goroutines have spent in the scheduler in a runnable state before actually running."
instrument: histogram
unit: "s"
stability: experimental

0 comments on commit 16d3a0a

Please sign in to comment.