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 Apr 29, 2024
1 parent 4d80b4c commit 59b9652
Show file tree
Hide file tree
Showing 3 changed files with 195 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
172 changes: 172 additions & 0 deletions docs/runtime/go-metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
<!--- 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.

<!-- semconv metric.go.memory.used(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Runtime Source | Stability |
| -------- | --------------- | ----------- | -------------- | -------------- | --------- |
| `go.memory.used` | UpDownCounter | `By` | Virtual memory mapped by the Go runtime | various `memory/classes` metrics | ![Experimental][ExperimentalIcon] |
<!-- 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`; `other`; | `Recommended` | ![Experimental][ExperimentalIcon] |

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

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

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

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

<!-- semconv metric.go.memory.limit(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Runtime Source | Stability |
| -------- | --------------- | ----------- | -------------- | -------------- | --------- |
| `go.memory.limit` | UpDownCounter | `By` | Go runtime memory limit configured by the user, otherwise math.MaxInt64. | `/gc/gomemlimit:bytes` | ![Experimental][ExperimentalIcon] |
<!-- 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.

<!-- semconv metric.go.memory.allocated(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Runtime Source | Stability |
| -------- | --------------- | ----------- | -------------- | -------------- | --------- |
| `go.memory.allocated` | Counter | `By` | Memory allocated to the heap by the application | `/gc/heap/allocs:bytes` | ![Experimental][ExperimentalIcon] |
<!-- 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.

<!-- semconv metric.go.memory.allocations(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Runtime Source | Stability |
| -------- | --------------- | ----------- | -------------- | -------------- | --------- |
| `go.memory.allocations` | Counter | `{allocation}` | Count of allocations to the heap by the application | `/gc/heap/allocs:objects` | ![Experimental][ExperimentalIcon] |
<!-- 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.

<!-- semconv metric.go.memory.target(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Runtime Source | Stability |
| -------- | --------------- | ----------- | -------------- | -------------- | --------- |
| `go.memory.target` | UpDownCounter | `By` | Heap size target for the end of the GC cycle. | `/gc/heap/goal:bytes` | ![Experimental][ExperimentalIcon] |
<!-- endsemconv -->

<!-- semconv metric.go.memory.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.

<!-- semconv metric.go.memory.user_target(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Runtime Source | Stability |
| -------- | --------------- | ----------- | -------------- | -------------- | --------- |
| `go.memory.user_target` | UpDownCounter | `By` | Heap size target for the end of the GC cycle. | `/gc/gogc:percent` | ![Experimental][ExperimentalIcon] |
<!-- endsemconv -->

<!-- semconv metric.go.memory.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.

<!-- semconv go.thread.limit(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Runtime Source | Stability |
| -------- | --------------- | ----------- | -------------- | -------------- | --------- |
| `go.thread.limit` | UpDownCounter | `By` | The number of OS threads that can execute user-level Go code simultaneously. | `/sched/gomaxprocs:threads` | ![Experimental][ExperimentalIcon] |
<!-- endsemconv -->

<!-- semconv 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.

<!-- semconv metric.go.schedule.duration(metric_table) -->
| Name | Instrument Type | Unit (UCUM) | Description | Runtime Source | Stability |
| -------- | --------------- | ----------- | -------------- | -------------- | --------- |
| `go.schedule.duration` | Histogram | `s` | Distribution of the time goroutines have spent in the scheduler in a runnable state before actually running. | `/sched/latencies:seconds` | ![Experimental][ExperimentalIcon] |
<!-- 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
[ExperimentalIcon]: https://img.shields.io/badge/-experimental-blue

0 comments on commit 59b9652

Please sign in to comment.