Skip to content
Closed
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/make_default_dev_metric_stblty.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: enhancement

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Set default stability to development for metrics"

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

# (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:

# 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: [user]
12 changes: 12 additions & 0 deletions cmd/mdatagen/internal/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"path/filepath"
"strings"

"go.opentelemetry.io/collector/component"

"go.opentelemetry.io/collector/confmap/confmaptest"
"go.opentelemetry.io/collector/confmap/provider/fileprovider"
)
Expand Down Expand Up @@ -63,10 +65,20 @@ func LoadMetadata(filePath string) (Metadata, error) {

setAttributesFullName(md.Attributes)
setAttributesFullName(md.ResourceAttributes)
setDefaultMetricStabilityLevel(md.Metrics)

return md, nil
}

func setDefaultMetricStabilityLevel(metrics map[MetricName]Metric) {
for mName, metric := range metrics {
if metric.Stability.Level == component.StabilityLevelUndefined {
metric.Stability.Level = component.StabilityLevelDevelopment
metrics[mName] = metric
}
}
}

var componentTypes = []string{
"connector",
"exporter",
Expand Down
19 changes: 14 additions & 5 deletions cmd/mdatagen/internal/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ 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,
},
Warnings: Warnings{
IfEnabledNotSet: "This metric will be disabled by default soon.",
},
Expand All @@ -237,6 +240,7 @@ func TestLoadMetadata(t *testing.T) {
Signal: Signal{
Enabled: false,
Description: "[DEPRECATED] Gauge double metric disabled by default.",
Stability: Stability{Level: component.StabilityLevelDeprecated},
Warnings: Warnings{
IfConfigured: "This metric is deprecated and will be removed soon.",
},
Expand All @@ -251,6 +255,7 @@ func TestLoadMetadata(t *testing.T) {
Signal: Signal{
Enabled: false,
Description: "[DEPRECATED] Gauge double metric disabled by default.",
Stability: Stability{Level: component.StabilityLevelDeprecated},
Warnings: Warnings{
IfConfigured: "This metric is deprecated and will be removed soon.",
},
Expand All @@ -265,6 +270,7 @@ func TestLoadMetadata(t *testing.T) {
"default.metric.to_be_removed": {
Signal: Signal{
Enabled: true,
Stability: Stability{Level: component.StabilityLevelDeprecated},
Description: "[DEPRECATED] Non-monotonic delta sum double metric enabled by default.",
ExtendedDocumentation: "The metric will be removed soon.",
Warnings: Warnings{
Expand All @@ -280,7 +286,10 @@ func TestLoadMetadata(t *testing.T) {
},
"metric.input_type": {
Signal: Signal{
Enabled: true,
Enabled: true,
Stability: Stability{
Level: component.StabilityLevelBeta,
},
Description: "Monotonic cumulative sum int metric with string input_type enabled by default.",
Attributes: []AttributeName{"string_attr", "overridden_int_attr", "enum_attr", "slice_attr", "map_attr"},
},
Expand Down Expand Up @@ -332,7 +341,7 @@ func TestLoadMetadata(t *testing.T) {
"batch_size_trigger_send": {
Signal: Signal{
Enabled: true,
Stability: Stability{Level: "deprecated", From: "v0.110.0"},
Stability: Stability{Level: component.StabilityLevelDeprecated, From: "v0.110.0"},
Description: "Number of times the batch was sent due to a size trigger",
},
Unit: strPtr("{times}"),
Expand All @@ -344,7 +353,7 @@ func TestLoadMetadata(t *testing.T) {
"request_duration": {
Signal: Signal{
Enabled: true,
Stability: Stability{Level: "alpha"},
Stability: Stability{Level: component.StabilityLevelAlpha},
Description: "Duration of request",
},
Unit: strPtr("s"),
Expand All @@ -356,7 +365,7 @@ func TestLoadMetadata(t *testing.T) {
"process_runtime_total_alloc_bytes": {
Signal: Signal{
Enabled: true,
Stability: Stability{Level: "stable"},
Stability: Stability{Level: component.StabilityLevelStable},
Description: "Cumulative bytes allocated for heap objects (see 'go doc runtime.MemStats.TotalAlloc')",
},
Unit: strPtr("By"),
Expand All @@ -371,7 +380,7 @@ func TestLoadMetadata(t *testing.T) {
"queue_length": {
Signal: Signal{
Enabled: true,
Stability: Stability{Level: "alpha"},
Stability: Stability{Level: 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 Down
12 changes: 6 additions & 6 deletions cmd/mdatagen/internal/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package internal // import "go.opentelemetry.io/collector/cmd/mdatagen/internal"
import (
"errors"
"fmt"
"strings"

"golang.org/x/text/cases"
"golang.org/x/text/language"
Expand Down Expand Up @@ -48,18 +47,19 @@ type Metric struct {
}

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

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

func (m *Metric) validate() error {
Expand Down
30 changes: 15 additions & 15 deletions cmd/mdatagen/internal/sampleconnector/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Monotonic cumulative sum int metric enabled by default.

The metric will be become optional soon.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| s | Sum | Int | Cumulative | true |
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
| s | Sum | Int | Cumulative | true | Development |

#### Attributes

Expand All @@ -38,17 +38,17 @@ The metric will be become optional soon.

The metric will be removed soon.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| s | Sum | Double | Delta | false |
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
| s | Sum | Double | Delta | false | Deprecated |

### metric.input_type

Monotonic cumulative sum int metric with string input_type enabled by default.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| s | Sum | Int | Cumulative | true |
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
| s | Sum | Int | Cumulative | true | Beta |

#### Attributes

Expand All @@ -74,9 +74,9 @@ metrics:

[DEPRECATED] Gauge double metric disabled by default.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| 1 | Gauge | Double |
| Unit | Metric Type | Value Type | Stability |
| ---- | ----------- | ---------- | --------- |
| 1 | Gauge | Double | Deprecated |

#### Attributes

Expand All @@ -90,9 +90,9 @@ metrics:

[DEPRECATED] Gauge double metric disabled by default.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| | Gauge | Double |
| Unit | Metric Type | Value Type | Stability |
| ---- | ----------- | ---------- | --------- |
| | Gauge | Double | Deprecated |

#### Attributes

Expand Down
8 changes: 8 additions & 0 deletions cmd/mdatagen/internal/sampleconnector/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ metrics:
enabled: false
description: "[DEPRECATED] Gauge double metric disabled by default."
unit: "1"
stability:
level: deprecated
gauge:
value_type: double
attributes: [string_attr, boolean_attr, boolean_attr2]
Expand All @@ -126,6 +128,8 @@ metrics:
enabled: false
description: "[DEPRECATED] Gauge double metric disabled by default."
unit: ""
stability:
level: deprecated
gauge:
value_type: double
attributes: [string_attr, boolean_attr]
Expand All @@ -136,6 +140,8 @@ 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
unit: s
sum:
value_type: double
Expand All @@ -146,6 +152,8 @@ metrics:

metric.input_type:
enabled: true
stability:
level: beta
description: Monotonic cumulative sum int metric with string input_type enabled by default.
unit: s
sum:
Expand Down
44 changes: 22 additions & 22 deletions cmd/mdatagen/internal/samplereceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Monotonic cumulative sum int metric enabled by default.

The metric will be become optional soon.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| s | Sum | Int | Cumulative | true |
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
| s | Sum | Int | Cumulative | true | Development |

#### Attributes

Expand All @@ -40,17 +40,17 @@ The metric will be become optional soon.

The metric will be removed soon.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| s | Sum | Double | Delta | false |
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
| s | Sum | Double | Delta | false | Deprecated |

### metric.input_type

Monotonic cumulative sum int metric with string input_type enabled by default.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| s | Sum | Int | Cumulative | true |
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability |
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- |
| s | Sum | Int | Cumulative | true | Beta |

#### Attributes

Expand All @@ -76,9 +76,9 @@ metrics:

[DEPRECATED] Gauge double metric disabled by default.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| 1 | Gauge | Double |
| Unit | Metric Type | Value Type | Stability |
| ---- | ----------- | ---------- | --------- |
| 1 | Gauge | Double | Deprecated |

#### Attributes

Expand All @@ -93,9 +93,9 @@ metrics:

[DEPRECATED] Gauge double metric disabled by default.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| | Gauge | Double |
| Unit | Metric Type | Value Type | Stability |
| ---- | ----------- | ---------- | --------- |
| | Gauge | Double | Deprecated |

#### Attributes

Expand Down Expand Up @@ -190,19 +190,19 @@ 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 since v0.110.0]

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

### otelcol_process_runtime_total_alloc_bytes

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

| Unit | Metric Type | Value Type | Monotonic | Stability |
| ---- | ----------- | ---------- | --------- | --------- |
| By | Sum | Int | true | stable |
| By | Sum | Int | true | Stable |

### otelcol_queue_capacity

Expand All @@ -214,18 +214,18 @@ Queue capacity - sync gauge example.

### otelcol_queue_length

This metric is optional and therefore not initialized in NewTelemetryBuilder. [alpha]
This metric is optional and therefore not initialized in NewTelemetryBuilder. [Alpha]

For example this metric only exists if feature A is enabled.

| Unit | Metric Type | Value Type | Stability |
| ---- | ----------- | ---------- | --------- |
| {items} | Gauge | Int | alpha |
| {items} | Gauge | Int | Alpha |

### otelcol_request_duration

Duration of request [alpha]
Duration of request [Alpha]

| Unit | Metric Type | Value Type | Stability |
| ---- | ----------- | ---------- | --------- |
| s | Histogram | Double | alpha |
| s | Histogram | Double | Alpha |
Loading
Loading