From c54b6c8d06f4b2105ffda444f31439370f16e2d3 Mon Sep 17 00:00:00 2001 From: David Ashpole Date: Thu, 23 May 2024 12:03:04 -0400 Subject: [PATCH] Add experimental go runtime metrics semantic conventions (#981) --- .chloggen/go-runtime-metrics.yaml | 22 ++ .github/ISSUE_TEMPLATE/bug_report.yaml | 1 + .github/ISSUE_TEMPLATE/change_proposal.yaml | 1 + .github/ISSUE_TEMPLATE/new-conventions.yaml | 1 + docs/attributes-registry/README.md | 1 + docs/attributes-registry/go.md | 24 ++ docs/runtime/README.md | 1 + docs/runtime/go-metrics.md | 418 ++++++++++++++++++++ model/metrics/go-metrics.yaml | 97 +++++ model/registry/go.yaml | 25 ++ 10 files changed, 591 insertions(+) create mode 100644 .chloggen/go-runtime-metrics.yaml create mode 100644 docs/attributes-registry/go.md create mode 100644 docs/runtime/go-metrics.md create mode 100644 model/metrics/go-metrics.yaml create mode 100644 model/registry/go.yaml diff --git a/.chloggen/go-runtime-metrics.yaml b/.chloggen/go-runtime-metrics.yaml new file mode 100644 index 000000000..72e6aafe9 --- /dev/null +++ b/.chloggen/go-runtime-metrics.yaml @@ -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: diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index af486e450..4aefd034c 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -43,6 +43,7 @@ body: - area:file - area:gcp - area:gen-ai + - area:go - area:graphql - area:heroku - area:host diff --git a/.github/ISSUE_TEMPLATE/change_proposal.yaml b/.github/ISSUE_TEMPLATE/change_proposal.yaml index 3d00899d2..2af8b08f7 100644 --- a/.github/ISSUE_TEMPLATE/change_proposal.yaml +++ b/.github/ISSUE_TEMPLATE/change_proposal.yaml @@ -36,6 +36,7 @@ body: - area:file - area:gcp - area:gen-ai + - area:go - area:graphql - area:heroku - area:host diff --git a/.github/ISSUE_TEMPLATE/new-conventions.yaml b/.github/ISSUE_TEMPLATE/new-conventions.yaml index 398592337..0753cd818 100644 --- a/.github/ISSUE_TEMPLATE/new-conventions.yaml +++ b/.github/ISSUE_TEMPLATE/new-conventions.yaml @@ -45,6 +45,7 @@ body: - area:file - area:gcp - area:gen-ai + - area:go - area:graphql - area:heroku - area:host diff --git a/docs/attributes-registry/README.md b/docs/attributes-registry/README.md index 66f750c03..a9253c650 100644 --- a/docs/attributes-registry/README.md +++ b/docs/attributes-registry/README.md @@ -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) diff --git a/docs/attributes-registry/go.md b/docs/attributes-registry/go.md new file mode 100644 index 000000000..5c47c1a4c --- /dev/null +++ b/docs/attributes-registry/go.md @@ -0,0 +1,24 @@ + + + + + +# 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`. diff --git a/docs/runtime/README.md b/docs/runtime/README.md index 6285bc2c9..9762c5ba2 100644 --- a/docs/runtime/README.md +++ b/docs/runtime/README.md @@ -48,6 +48,7 @@ Also consider the semantic conventions when instrumenting runtime environments. - [JVM](jvm-metrics.md) +- [Go](go-metrics.md) ### Attributes diff --git a/docs/runtime/go-metrics.md b/docs/runtime/go-metrics.md new file mode 100644 index 000000000..5641dc40a --- /dev/null +++ b/docs/runtime/go-metrics.md @@ -0,0 +1,418 @@ + + +# 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. + + + + + +- [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) + + + +## Go Memory + +**Description:** Go runtime metrics captured under the namespace `go.memory.*` + +### Metric: `go.memory.used` + +This metric is [recommended][MetricRecommended]. + + + + + + + + +| 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)`. + + + + + + + + + + + + + + + +| 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`. + + + + + + + + + + +### Metric: `go.memory.limit` + +This metric is [recommended][MetricRecommended]. + + + + + + + + +| 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. + + + + + + + + + + + + + + + + + + + + + +### Metric: `go.memory.allocated` + +This metric is [recommended][MetricRecommended]. + + + + + + + + +| 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`. + + + + + + + + + + + + + + + + + + + + + +### Metric: `go.memory.allocations` + +This metric is [recommended][MetricRecommended]. + + + + + + + + +| 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`. + + + + + + + + + + + + + + + + + + + + + +## Go Garbage Collection + +**Description:** Go metrics captured under the namespace `go.memory.gc.*` + +### Metric: `go.memory.gc.goal` + +This metric is [recommended][MetricRecommended]. + + + + + + + + +| 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`. + + + + + + + + + + + + + + + + + + + + + +## Go Goroutines + +**Description:** Go metrics captured under the namespace `go.goroutine.*` + +### Metric: `go.goroutine.count` + +This metric is [recommended][MetricRecommended]. + + + + + + + + +| 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`. + + + + + + + + + + + + + + + + + + + + + +## Go Processor + +**Description:** Go metrics captured under the namespace `go.processor.*` + +### Metric: `go.processor.limit` + +This metric is [recommended][MetricRecommended]. + + + + + + + + +| 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`. + + + + + + + + + + + + + + + + + + + + + +## Go Scheduler + +**Description:** Go metrics captured under the namespace `go.schedule.*` + +### Metric: `go.schedule.duration` + +This metric is [recommended][MetricRecommended]. + + + + + + + + +| 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. + + + + + + + + + + + + + + + + + + + + + +## Go Runtime Configuration + +**Description:** Go metrics captured under the namespace `go.config.*` + +### Metric: `go.config.gogc` + +This metric is [recommended][MetricRecommended]. + + + + + + + + +| 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`. + + + + + + + + + + + + + + + + + + + + + +[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 diff --git a/model/metrics/go-metrics.yaml b/model/metrics/go-metrics.yaml new file mode 100644 index 000000000..8b7c14c79 --- /dev/null +++ b/model/metrics/go-metrics.yaml @@ -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 diff --git a/model/registry/go.yaml b/model/registry/go.yaml new file mode 100644 index 000000000..d59910230 --- /dev/null +++ b/model/registry/go.yaml @@ -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"]