1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-08-10 22:31:50 +02:00

Fix semconv instrument types (#6837)

- The instrument type for `goconv.MemoryUsed` need to be an
`Int64ObservableUpDownCounter`, not an `Int64ObservableCounter`
[according to semantic
conventions](ca0c5ada95/docs/runtime/go-metrics.md (metric-gomemoryused))
- The instrument type for `systemconv.MemoryUsage` need to be an
`Int64ObservableUpDownCounter`, not an `Int64ObservableGauge` [according
to semantic
conventions](ca0c5ada95/docs/system/system-metrics.md (metric-systemmemoryusage))

All other [metric instrument type
overrides](6e90db55ca/semconv/weaver.yaml (L70-L83))
have be verified.
This commit is contained in:
Tyler Yahn
2025-05-28 11:25:40 -07:00
committed by GitHub
parent dea52958ae
commit e25861aa7b
6 changed files with 46 additions and 34 deletions

View File

@@ -2,6 +2,18 @@
The `go.opentelemetry.io/otel/semconv/v1.33.0` package should be a drop-in replacement for `go.opentelemetry.io/otel/semconv/v1.32.0` with the following exceptions.
## Metric instrument type fixes
### `goconv.MemoryUse`
The underlying metric instrument type for `goconv.MemoryUse` has been corrected be an `Int64ObservableUpDownCounter` instead of an `Int64ObservableCounter`.
This change aligns with the semantic conventions for memory usage metrics.
### `systemconv.MemoryUsage`
The underlying metric instrument type for `systemconv.MemoryUsage` has been corrected be an `Int64ObservableUpDownCounter` instead of an `Int64ObservableGauge`.
This change aligns with the semantic conventions for memory usage metrics.
## Dropped deprecations
The following declarations have been deprecated in the [OpenTelemetry Semantic Conventions].

View File

@@ -335,35 +335,35 @@ func (MemoryLimit) Description() string {
// "go.memory.used" semantic conventions. It represents the memory used by the Go
// runtime.
type MemoryUsed struct {
metric.Int64ObservableCounter
metric.Int64ObservableUpDownCounter
}
// NewMemoryUsed returns a new MemoryUsed instrument.
func NewMemoryUsed(
m metric.Meter,
opt ...metric.Int64ObservableCounterOption,
opt ...metric.Int64ObservableUpDownCounterOption,
) (MemoryUsed, error) {
// Check if the meter is nil.
if m == nil {
return MemoryUsed{noop.Int64ObservableCounter{}}, nil
return MemoryUsed{noop.Int64ObservableUpDownCounter{}}, nil
}
i, err := m.Int64ObservableCounter(
i, err := m.Int64ObservableUpDownCounter(
"go.memory.used",
append([]metric.Int64ObservableCounterOption{
append([]metric.Int64ObservableUpDownCounterOption{
metric.WithDescription("Memory used by the Go runtime."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return MemoryUsed{noop.Int64ObservableCounter{}}, err
return MemoryUsed{noop.Int64ObservableUpDownCounter{}}, err
}
return MemoryUsed{i}, nil
}
// Inst returns the underlying metric instrument.
func (m MemoryUsed) Inst() metric.Int64ObservableCounter {
return m.Int64ObservableCounter
func (m MemoryUsed) Inst() metric.Int64ObservableUpDownCounter {
return m.Int64ObservableUpDownCounter
}
// Name returns the semantic convention name of the instrument.

View File

@@ -1484,35 +1484,35 @@ func (m MemoryShared) Add(ctx context.Context, incr int64, attrs ...attribute.Ke
// "system.memory.usage" semantic conventions. It represents the reports memory
// in use by state.
type MemoryUsage struct {
metric.Int64ObservableGauge
metric.Int64ObservableUpDownCounter
}
// NewMemoryUsage returns a new MemoryUsage instrument.
func NewMemoryUsage(
m metric.Meter,
opt ...metric.Int64ObservableGaugeOption,
opt ...metric.Int64ObservableUpDownCounterOption,
) (MemoryUsage, error) {
// Check if the meter is nil.
if m == nil {
return MemoryUsage{noop.Int64ObservableGauge{}}, nil
return MemoryUsage{noop.Int64ObservableUpDownCounter{}}, nil
}
i, err := m.Int64ObservableGauge(
i, err := m.Int64ObservableUpDownCounter(
"system.memory.usage",
append([]metric.Int64ObservableGaugeOption{
append([]metric.Int64ObservableUpDownCounterOption{
metric.WithDescription("Reports memory in use by state."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return MemoryUsage{noop.Int64ObservableGauge{}}, err
return MemoryUsage{noop.Int64ObservableUpDownCounter{}}, err
}
return MemoryUsage{i}, nil
}
// Inst returns the underlying metric instrument.
func (m MemoryUsage) Inst() metric.Int64ObservableGauge {
return m.Int64ObservableGauge
func (m MemoryUsage) Inst() metric.Int64ObservableUpDownCounter {
return m.Int64ObservableUpDownCounter
}
// Name returns the semantic convention name of the instrument.

View File

@@ -335,35 +335,35 @@ func (MemoryLimit) Description() string {
// "go.memory.used" semantic conventions. It represents the memory used by the Go
// runtime.
type MemoryUsed struct {
metric.Int64ObservableCounter
metric.Int64ObservableUpDownCounter
}
// NewMemoryUsed returns a new MemoryUsed instrument.
func NewMemoryUsed(
m metric.Meter,
opt ...metric.Int64ObservableCounterOption,
opt ...metric.Int64ObservableUpDownCounterOption,
) (MemoryUsed, error) {
// Check if the meter is nil.
if m == nil {
return MemoryUsed{noop.Int64ObservableCounter{}}, nil
return MemoryUsed{noop.Int64ObservableUpDownCounter{}}, nil
}
i, err := m.Int64ObservableCounter(
i, err := m.Int64ObservableUpDownCounter(
"go.memory.used",
append([]metric.Int64ObservableCounterOption{
append([]metric.Int64ObservableUpDownCounterOption{
metric.WithDescription("Memory used by the Go runtime."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return MemoryUsed{noop.Int64ObservableCounter{}}, err
return MemoryUsed{noop.Int64ObservableUpDownCounter{}}, err
}
return MemoryUsed{i}, nil
}
// Inst returns the underlying metric instrument.
func (m MemoryUsed) Inst() metric.Int64ObservableCounter {
return m.Int64ObservableCounter
func (m MemoryUsed) Inst() metric.Int64ObservableUpDownCounter {
return m.Int64ObservableUpDownCounter
}
// Name returns the semantic convention name of the instrument.

View File

@@ -1484,35 +1484,35 @@ func (m MemoryShared) Add(ctx context.Context, incr int64, attrs ...attribute.Ke
// "system.memory.usage" semantic conventions. It represents the reports memory
// in use by state.
type MemoryUsage struct {
metric.Int64ObservableGauge
metric.Int64ObservableUpDownCounter
}
// NewMemoryUsage returns a new MemoryUsage instrument.
func NewMemoryUsage(
m metric.Meter,
opt ...metric.Int64ObservableGaugeOption,
opt ...metric.Int64ObservableUpDownCounterOption,
) (MemoryUsage, error) {
// Check if the meter is nil.
if m == nil {
return MemoryUsage{noop.Int64ObservableGauge{}}, nil
return MemoryUsage{noop.Int64ObservableUpDownCounter{}}, nil
}
i, err := m.Int64ObservableGauge(
i, err := m.Int64ObservableUpDownCounter(
"system.memory.usage",
append([]metric.Int64ObservableGaugeOption{
append([]metric.Int64ObservableUpDownCounterOption{
metric.WithDescription("Reports memory in use by state."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return MemoryUsage{noop.Int64ObservableGauge{}}, err
return MemoryUsage{noop.Int64ObservableUpDownCounter{}}, err
}
return MemoryUsage{i}, nil
}
// Inst returns the underlying metric instrument.
func (m MemoryUsage) Inst() metric.Int64ObservableGauge {
return m.Int64ObservableGauge
func (m MemoryUsage) Inst() metric.Int64ObservableUpDownCounter {
return m.Int64ObservableUpDownCounter
}
// Name returns the semantic convention name of the instrument.

View File

@@ -75,10 +75,10 @@ text_maps:
go.memory.allocations: Int64ObservableCounter
go.memory.gc.goal: Int64ObservableUpDownCounter
go.memory.limit: Int64ObservableUpDownCounter
go.memory.used: Int64ObservableCounter
go.memory.used: Int64ObservableUpDownCounter
go.processor.limit: Int64ObservableUpDownCounter
process.cpu.time: Float64ObservableCounter
system.memory.usage: Int64ObservableGauge
system.memory.usage: Int64ObservableUpDownCounter
system.memory.utilization: Float64ObservableGauge
system.network.io: Int64ObservableCounter
acronyms: