Add experimental go runtime metrics semantic conventions (#981)

This commit is contained in:
David Ashpole 2024-05-23 12:03:04 -04:00 committed by GitHub
parent a47ccedec2
commit c54b6c8d06
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 591 additions and 0 deletions

View File

@ -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:

View File

@ -43,6 +43,7 @@ body:
- area:file
- area:gcp
- area:gen-ai
- area:go
- area:graphql
- area:heroku
- area:host

View File

@ -36,6 +36,7 @@ body:
- area:file
- area:gcp
- area:gen-ai
- area:go
- area:graphql
- area:heroku
- area:host

View File

@ -45,6 +45,7 @@ body:
- area:file
- area:gcp
- area:gen-ai
- area:go
- area:graphql
- area:heroku
- area:host

View File

@ -55,6 +55,7 @@ Currently, the following namespaces exist:
- [File](file.md)
- [GCP](gcp.md)
- [Gen AI](gen-ai.md)
- [Go](go.md)
- [GraphQL](graphql.md)
- [Heroku](heroku.md)
- [Host](host.md)

View File

@ -0,0 +1,24 @@
<!--- Hugo front matter used to generate the website version of this page:
--->
<!-- NOTE: THIS FILE IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/attribute_namespace.md.j2 -->
# Go
## Go Attributes
This document defines Go related attributes.
| Attribute | Type | Description | Examples | Stability |
| ---------------- | ------ | ------------------- | ---------------- | ---------------------------------------------------------------- |
| `go.memory.type` | string | The type of memory. | `other`; `stack` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
`go.memory.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
| ------- | ----------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| `stack` | Memory allocated from the heap that is reserved for stack space, whether or not it is currently in-use. [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `other` | Memory used by the Go runtime, excluding other categories of memory usage described in this enumeration. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
**[1]:** Computed from `/memory/classes/heap/stacks:bytes`.

View File

@ -48,6 +48,7 @@ Also consider the
semantic conventions when instrumenting runtime environments.
- [JVM](jvm-metrics.md)
- [Go](go-metrics.md)
### Attributes

418
docs/runtime/go-metrics.md Normal file
View File

@ -0,0 +1,418 @@
<!--- 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.
These metrics are obtained from Go's [`runtime/metrics`][RuntimeMetrics] package.
<!-- 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.goal`](#metric-gomemorygcgoal)
- [Go Goroutines](#go-goroutines)
- [Metric: `go.goroutine.count`](#metric-gogoroutinecount)
- [Go Processor](#go-processor)
- [Metric: `go.processor.limit`](#metric-goprocessorlimit)
- [Go Scheduler](#go-scheduler)
- [Metric: `go.schedule.duration`](#metric-goscheduleduration)
- [Go Runtime Configuration](#go-runtime-configuration)
- [Metric: `go.config.gogc`](#metric-goconfiggogc)
<!-- tocstop -->
## Go Memory
**Description:** Go runtime metrics captured under the namespace `go.memory.*`
### Metric: `go.memory.used`
This metric is [recommended][MetricRecommended].
<!-- semconv metric.go.memory.used(metric_table) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `go.memory.used` | UpDownCounter | `By` | Memory used by the Go runtime. [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
**[1]:** Computed from `(/memory/classes/total:bytes - /memory/classes/heap/released:bytes)`.
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->
<!-- semconv metric.go.memory.used(full) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| [`go.memory.type`](/docs/attributes-registry/go.md) | string | The type of memory. | `other`; `stack` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
`go.memory.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
|---|---|---|
| `stack` | Memory allocated from the heap that is reserved for stack space, whether or not it is currently in-use. [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `other` | Memory used by the Go runtime, excluding other categories of memory usage described in this enumeration. | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
**[1]:** Computed from `/memory/classes/heap/stacks:bytes`.
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->
### Metric: `go.memory.limit`
This metric is [recommended][MetricRecommended].
<!-- semconv metric.go.memory.limit(metric_table) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `go.memory.limit` | UpDownCounter | `By` | Go runtime memory limit configured by the user, if a limit exists. [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
**[1]:** Computed from `/gc/gomemlimit:bytes`. This metric is excluded if the limit obtained from the Go runtime is math.MaxInt64.
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->
<!-- semconv metric.go.memory.limit(full) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->
### Metric: `go.memory.allocated`
This metric is [recommended][MetricRecommended].
<!-- semconv metric.go.memory.allocated(metric_table) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `go.memory.allocated` | Counter | `By` | Memory allocated to the heap by the application. [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
**[1]:** Computed from `/gc/heap/allocs:bytes`.
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->
<!-- semconv metric.go.memory.allocated(full) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->
### Metric: `go.memory.allocations`
This metric is [recommended][MetricRecommended].
<!-- semconv metric.go.memory.allocations(metric_table) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `go.memory.allocations` | Counter | `{allocation}` | Count of allocations to the heap by the application. [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
**[1]:** Computed from `/gc/heap/allocs:objects`.
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->
<!-- semconv metric.go.memory.allocations(full) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->
## Go Garbage Collection
**Description:** Go metrics captured under the namespace `go.memory.gc.*`
### Metric: `go.memory.gc.goal`
This metric is [recommended][MetricRecommended].
<!-- semconv metric.go.memory.gc.goal(metric_table) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `go.memory.gc.goal` | UpDownCounter | `By` | Heap size target for the end of the GC cycle. [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
**[1]:** Computed from `/gc/heap/goal:bytes`.
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->
<!-- semconv metric.go.memory.gc.goal(full) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->
## Go Goroutines
**Description:** Go metrics captured under the namespace `go.goroutine.*`
### Metric: `go.goroutine.count`
This metric is [recommended][MetricRecommended].
<!-- semconv metric.go.goroutine.count(metric_table) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `go.goroutine.count` | UpDownCounter | `{goroutine}` | Count of live goroutines. [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
**[1]:** Computed from `/sched/goroutines:goroutines`.
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->
<!-- semconv metric.go.goroutine.count(full) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->
## Go Processor
**Description:** Go metrics captured under the namespace `go.processor.*`
### Metric: `go.processor.limit`
This metric is [recommended][MetricRecommended].
<!-- semconv metric.go.processor.limit(metric_table) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `go.processor.limit` | UpDownCounter | `{thread}` | The number of OS threads that can execute user-level Go code simultaneously. [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
**[1]:** Computed from `/sched/gomaxprocs:threads`.
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->
<!-- semconv metric.go.processor.limit(full) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->
## Go Scheduler
**Description:** Go metrics captured under the namespace `go.schedule.*`
### Metric: `go.schedule.duration`
This metric is [recommended][MetricRecommended].
<!-- semconv metric.go.schedule.duration(metric_table) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->
| 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. [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
**[1]:** Computed from `/sched/latencies:seconds`. Bucket boundaries are provided by the runtime, and are subject to change.
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->
<!-- semconv metric.go.schedule.duration(full) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->
## Go Runtime Configuration
**Description:** Go metrics captured under the namespace `go.config.*`
### Metric: `go.config.gogc`
This metric is [recommended][MetricRecommended].
<!-- semconv metric.go.config.gogc(metric_table) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `go.config.gogc` | UpDownCounter | `%` | Heap size target percentage configured by the user, otherwise 100. [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
**[1]:** The value range is [0.0,100.0]. Computed from `/gc/gogc:percent`.
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->
<!-- semconv metric.go.config.gogc(full) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- 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

View File

@ -0,0 +1,97 @@
groups:
- id: metric.go.memory.used
type: metric
metric_name: go.memory.used
brief: "Memory used by the Go runtime."
note: >
Computed from `(/memory/classes/total:bytes - /memory/classes/heap/released:bytes)`.
instrument: updowncounter
prefix: go.memory
unit: "By"
attributes:
- ref: go.memory.type
requirement_level: recommended
stability: experimental
- id: metric.go.memory.limit
type: metric
metric_name: go.memory.limit
brief: "Go runtime memory limit configured by the user, if a limit exists."
note: >
Computed from `/gc/gomemlimit:bytes`.
This metric is excluded if the limit obtained from the Go runtime is 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."
note: >
Computed from `/gc/heap/allocs:bytes`.
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."
note: >
Computed from `/gc/heap/allocs:objects`.
instrument: counter
unit: "{allocation}"
stability: experimental
- id: metric.go.memory.gc.goal
type: metric
metric_name: go.memory.gc.goal
brief: "Heap size target for the end of the GC cycle."
note: >
Computed from `/gc/heap/goal:bytes`.
instrument: updowncounter
unit: "By"
stability: experimental
- id: metric.go.goroutine.count
type: metric
metric_name: go.goroutine.count
brief: "Count of live goroutines."
note: >
Computed from `/sched/goroutines:goroutines`.
instrument: updowncounter
unit: "{goroutine}"
stability: experimental
- id: metric.go.processor.limit
type: metric
metric_name: go.processor.limit
brief: "The number of OS threads that can execute user-level Go code simultaneously."
note: >
Computed from `/sched/gomaxprocs:threads`.
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."
note: >
Computed from `/sched/latencies:seconds`.
Bucket boundaries are provided by the runtime, and are subject to change.
instrument: histogram
unit: "s"
stability: experimental
- id: metric.go.config.gogc
type: metric
metric_name: go.config.gogc
brief: "Heap size target percentage configured by the user, otherwise 100."
note: >
The value range is [0.0,100.0].
Computed from `/gc/gogc:percent`.
instrument: updowncounter
unit: "%"
stability: experimental

25
model/registry/go.yaml Normal file
View File

@ -0,0 +1,25 @@
groups:
- id: registry.go
type: attribute_group
prefix: go
brief: >
This document defines Go related attributes.
attributes:
- id: memory.type
stability: experimental
type:
allow_custom_values: false
members:
- id: stack
value: 'stack'
brief: 'Memory allocated from the heap that is reserved for stack space, whether or not it is currently in-use.'
note: >
Computed from `/memory/classes/heap/stacks:bytes`.
stability: experimental
- id: other
value: 'other'
brief: 'Memory used by the Go runtime, excluding other categories of memory usage described in this enumeration.'
stability: experimental
requirement_level: recommended
brief: The type of memory.
examples: ["other", "stack"]