Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .chloggen/mdatagen-flatten-metric-stability.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. receiver/otlp)
component: cmd/mdatagen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Flatten the metric stability field

# One or more tracking issues or pull requests related to the change
issues: [14113]

# (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: So we better match the weaver schema. Additional deprecation data can be set within the `deprecated` field.

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [api]
28 changes: 14 additions & 14 deletions cmd/mdatagen/internal/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func TestLoadMetadata(t *testing.T) {
Enabled: true,
Description: "Monotonic cumulative sum int metric enabled by default.",
ExtendedDocumentation: "The metric will be become optional soon.",
Stability: Stability{Level: component.StabilityLevelDevelopment},
Stability: component.StabilityLevelDevelopment,
Warnings: Warnings{
IfEnabledNotSet: "This metric will be disabled by default soon.",
},
Expand All @@ -268,7 +268,7 @@ func TestLoadMetadata(t *testing.T) {
Signal: Signal{
Enabled: true,
Description: "Metric for testing spacial reaggregation",
Stability: Stability{Level: component.StabilityLevelBeta},
Stability: component.StabilityLevelBeta,
Attributes: []AttributeName{"string_attr", "boolean_attr"},
},
Unit: strPtr("1"),
Expand All @@ -279,7 +279,7 @@ func TestLoadMetadata(t *testing.T) {
"system.cpu.time": {
Signal: Signal{
Enabled: true,
Stability: Stability{Level: component.StabilityLevelBeta},
Stability: component.StabilityLevelBeta,
SemanticConvention: &SemanticConvention{SemanticConventionRef: "https://github.com/open-telemetry/semantic-conventions/blob/v1.38.0/docs/system/system-metrics.md#metric-systemcputime"},
Description: "Monotonic cumulative sum int metric enabled by default.",
ExtendedDocumentation: "The metric will be become optional soon.",
Expand All @@ -295,7 +295,7 @@ func TestLoadMetadata(t *testing.T) {
Signal: Signal{
Enabled: false,
Description: "[DEPRECATED] Gauge double metric disabled by default.",
Stability: Stability{Level: component.StabilityLevelDeprecated},
Stability: component.StabilityLevelDeprecated,
Warnings: Warnings{
IfConfigured: "This metric is deprecated and will be removed soon.",
},
Expand All @@ -310,7 +310,7 @@ func TestLoadMetadata(t *testing.T) {
Signal: Signal{
Enabled: false,
Description: "[DEPRECATED] Gauge double metric disabled by default.",
Stability: Stability{Level: component.StabilityLevelDeprecated},
Stability: component.StabilityLevelDeprecated,
Warnings: Warnings{
IfConfigured: "This metric is deprecated and will be removed soon.",
},
Expand All @@ -327,7 +327,7 @@ func TestLoadMetadata(t *testing.T) {
Enabled: true,
Description: "[DEPRECATED] Non-monotonic delta sum double metric enabled by default.",
ExtendedDocumentation: "The metric will be removed soon.",
Stability: Stability{Level: component.StabilityLevelDeprecated},
Stability: component.StabilityLevelDeprecated,
Warnings: Warnings{
IfEnabled: "This metric is deprecated and will be removed soon.",
},
Expand All @@ -343,7 +343,7 @@ func TestLoadMetadata(t *testing.T) {
Signal: Signal{
Enabled: true,
Description: "Monotonic cumulative sum int metric with string input_type enabled by default.",
Stability: Stability{Level: component.StabilityLevelDevelopment},
Stability: component.StabilityLevelDevelopment,
Attributes: []AttributeName{"string_attr", "overridden_int_attr", "enum_attr", "slice_attr", "map_attr"},
},
Unit: strPtr("s"),
Expand Down Expand Up @@ -394,7 +394,7 @@ func TestLoadMetadata(t *testing.T) {
"batch_size_trigger_send": {
Signal: Signal{
Enabled: true,
Stability: Stability{Level: component.StabilityLevelDeprecated, From: "v0.110.0"},
Stability: component.StabilityLevelDeprecated,
Description: "Number of times the batch was sent due to a size trigger",
},
Unit: strPtr("{times}"),
Expand All @@ -406,7 +406,7 @@ func TestLoadMetadata(t *testing.T) {
"request_duration": {
Signal: Signal{
Enabled: true,
Stability: Stability{Level: component.StabilityLevelAlpha},
Stability: component.StabilityLevelAlpha,
Description: "Duration of request",
},
Unit: strPtr("s"),
Expand All @@ -418,7 +418,7 @@ func TestLoadMetadata(t *testing.T) {
"process_runtime_total_alloc_bytes": {
Signal: Signal{
Enabled: true,
Stability: Stability{Level: component.StabilityLevelStable},
Stability: component.StabilityLevelStable,
Description: "Cumulative bytes allocated for heap objects (see 'go doc runtime.MemStats.TotalAlloc')",
},
Unit: strPtr("By"),
Expand All @@ -433,7 +433,7 @@ func TestLoadMetadata(t *testing.T) {
"queue_length": {
Signal: Signal{
Enabled: true,
Stability: Stability{Level: component.StabilityLevelAlpha},
Stability: component.StabilityLevelAlpha,
Description: "This metric is optional and therefore not initialized in NewTelemetryBuilder.",
ExtendedDocumentation: "For example this metric only exists if feature A is enabled.",
},
Expand All @@ -450,7 +450,7 @@ func TestLoadMetadata(t *testing.T) {
Signal: Signal{
Enabled: true,
Description: "Queue capacity - sync gauge example.",
Stability: Stability{Level: component.StabilityLevelDevelopment},
Stability: component.StabilityLevelDevelopment,
},
Unit: strPtr("{items}"),
Gauge: &Gauge{
Expand Down Expand Up @@ -552,7 +552,7 @@ func TestLoadMetadata(t *testing.T) {
{
name: "testdata/invalid_metric_stability.yaml",
want: Metadata{},
wantErr: "decoding failed due to the following error(s):\n\n'metrics[default.metric]' decoding failed due to the following error(s):\n\n'stability' decoding failed due to the following error(s):\n\n'level' unsupported stability level: \"development42\"",
wantErr: "decoding failed due to the following error(s):\n\n'metrics[default.metric]' decoding failed due to the following error(s):\n\n'stability' unsupported stability level: \"development42\"",
},
{
name: "testdata/invalid_metric_semconvref.yaml",
Expand All @@ -562,7 +562,7 @@ func TestLoadMetadata(t *testing.T) {
{
name: "testdata/no_metric_stability.yaml",
want: Metadata{},
wantErr: "decoding failed due to the following error(s):\n\n'metrics[default.metric]' decoding failed due to the following error(s):\n\n'stability' missing required field: `stability.level`",
wantErr: "metric \"default.metric\": missing required field: `stability.level`",
},
{
name: "testdata/~~this file doesn't exist~~.yaml",
Expand Down
3 changes: 2 additions & 1 deletion cmd/mdatagen/internal/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"strconv"
"strings"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/filter"
"go.opentelemetry.io/collector/pdata/pcommon"
)
Expand Down Expand Up @@ -528,7 +529,7 @@ type Signal struct {
SemanticConvention *SemanticConvention `mapstructure:"semantic_convention"`

// The stability level of the signal.
Stability Stability `mapstructure:"stability"`
Stability component.StabilityLevel `mapstructure:"stability"`

// Extended documentation of the signal. If specified, this will be appended to the description used in generated documentation.
ExtendedDocumentation string `mapstructure:"extended_documentation"`
Expand Down
26 changes: 3 additions & 23 deletions cmd/mdatagen/internal/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,6 @@ type Metric struct {
Prefix string `mapstructure:"prefix"`
}

type Stability struct {
Level component.StabilityLevel `mapstructure:"level"`
From string `mapstructure:"from"`
}

func (s Stability) String() string {
if s.Level == component.StabilityLevelUndefined ||
s.Level == component.StabilityLevelStable {
return ""
}
if s.From != "" {
return fmt.Sprintf(" [%s since %s]", s.Level.String(), s.From)
}
return fmt.Sprintf(" [%s]", s.Level.String())
}

func (s *Stability) Unmarshal(parser *confmap.Conf) error {
if !parser.IsSet("level") {
return errors.New("missing required field: `stability.level`")
}
return parser.Unmarshal(s)
}

func (m *Metric) validate(metricName MetricName, semConvVersion string) error {
var errs error
if m.Sum == nil && m.Gauge == nil && m.Histogram == nil {
Expand All @@ -83,6 +60,9 @@ func (m *Metric) validate(metricName MetricName, semConvVersion string) error {
errs = errors.Join(errs, errors.New("more than one metric type keys, "+
"only one of the following has to be specified: sum, gauge, histogram"))
}
if m.Stability == component.StabilityLevelUndefined {
errs = errors.Join(errs, errors.New("missing required field: `stability.level`"))
}
if m.Description == "" {
errs = errors.Join(errs, errors.New(`missing metric description`))
}
Expand Down
20 changes: 7 additions & 13 deletions cmd/mdatagen/internal/sampleconnector/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ metrics:
enabled: true
description: Monotonic cumulative sum int metric enabled by default.
extended_documentation: The metric will be become optional soon.
stability:
level: development
stability: development
unit: s
sum:
value_type: int
Expand All @@ -131,8 +130,7 @@ metrics:
enabled: true
description: "[DEPRECATED] Non-monotonic delta sum double metric enabled by default."
extended_documentation: The metric will be removed soon.
stability:
level: deprecated
stability: deprecated
unit: s
sum:
value_type: double
Expand All @@ -144,8 +142,7 @@ metrics:
metric.input_type:
enabled: true
description: Monotonic cumulative sum int metric with string input_type enabled by default.
stability:
level: development
stability: development
unit: s
sum:
value_type: int
Expand All @@ -158,8 +155,7 @@ metrics:
optional.metric:
enabled: false
description: "[DEPRECATED] Gauge double metric disabled by default."
stability:
level: deprecated
stability: deprecated
unit: "1"
gauge:
value_type: double
Expand All @@ -170,8 +166,7 @@ metrics:
optional.metric.empty_unit:
enabled: false
description: "[DEPRECATED] Gauge double metric disabled by default."
stability:
level: deprecated
stability: deprecated
unit: ""
gauge:
value_type: double
Expand All @@ -183,8 +178,7 @@ metrics:
enabled: true
description: Metric for testing spacial reaggregation
unit: "1"
stability:
level: beta
stability: beta
gauge:
value_type: double
value_type: double
attributes: [string_attr, boolean_attr]
4 changes: 2 additions & 2 deletions cmd/mdatagen/internal/samplereceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,15 @@ The following telemetry is emitted by this component.

### otelcol_batch_size_trigger_send

Number of times the batch was sent due to a size trigger [Deprecated since v0.110.0]
Number of times the batch was sent due to a size trigger [Deprecated]

| Unit | Metric Type | Value Type | Monotonic | Stability |
| ---- | ----------- | ---------- | --------- | --------- |
| {times} | Sum | Int | true | Deprecated |

### otelcol_process_runtime_total_alloc_bytes

Cumulative bytes allocated for heap objects (see 'go doc runtime.MemStats.TotalAlloc')
Cumulative bytes allocated for heap objects (see 'go doc runtime.MemStats.TotalAlloc') [Stable]

| Unit | Metric Type | Value Type | Monotonic | Stability |
| ---- | ----------- | ---------- | --------- | --------- |
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading