Skip to content

Commit 61b57cd

Browse files
committed
[mdatagen] Add semconv ref for signals
Signed-off-by: ChrsMark <[email protected]>
1 parent 6ccdc89 commit 61b57cd

File tree

11 files changed

+155
-4
lines changed

11 files changed

+155
-4
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: mdatagen
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Introduce semantic convention reference for signal in metadata schema
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [13297]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: [user]

cmd/mdatagen/internal/metadata.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ func (mvt ValueType) Primitive() string {
278278
}
279279
}
280280

281+
type SemanticConvention struct {
282+
SemanticConventionRef string `mapstructure:"semconv_ref"`
283+
}
284+
281285
type Warnings struct {
282286
// A warning that will be displayed if the field is enabled in user config.
283287
IfEnabled string `mapstructure:"if_enabled"`
@@ -353,6 +357,9 @@ type Signal struct {
353357
// Description of the signal.
354358
Description string `mapstructure:"description"`
355359

360+
// The semantic convention reference of the signal.
361+
SemanticConvention *SemanticConvention `mapstructure:"semantic_convention"`
362+
356363
// The stability level of the signal.
357364
Stability Stability `mapstructure:"stability"`
358365

cmd/mdatagen/internal/samplescraper/documentation.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ Monotonic cumulative sum int metric with string input_type enabled by default.
6060
| slice_attr | Attribute with a slice value. | Any Slice | false |
6161
| map_attr | Attribute with a map value. | Any Map | false |
6262
63+
### system.cpu.time
64+
65+
Monotonic cumulative sum int metric enabled by default.
66+
67+
The metric will be become optional soon.
68+
69+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | Stability | Semantic Convention |
70+
| ---- | ----------- | ---------- | ----------------------- | --------- | --------- | ------------------- |
71+
| s | Sum | Int | Cumulative | true | beta | [system.cpu.time](https://github.com/open-telemetry/semantic-conventions/blob/v1.35.0/docs/system/system-metrics.md#metric-systemcputime) |
72+
6373
## Optional Metrics
6474
6575
The following metrics are not emitted by default. Each of them can be enabled by applying the following configuration:

cmd/mdatagen/internal/samplescraper/internal/metadata/generated_config.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/mdatagen/internal/samplescraper/internal/metadata/generated_config_test.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/mdatagen/internal/samplescraper/internal/metadata/generated_metrics.go

Lines changed: 63 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/mdatagen/internal/samplescraper/internal/metadata/generated_metrics_test.go

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/mdatagen/internal/samplescraper/internal/metadata/testdata/config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ all_set:
1111
enabled: true
1212
optional.metric.empty_unit:
1313
enabled: true
14+
system.cpu.time:
15+
enabled: true
1416
resource_attributes:
1517
map.resource.attr:
1618
enabled: true
@@ -40,6 +42,8 @@ none_set:
4042
enabled: false
4143
optional.metric.empty_unit:
4244
enabled: false
45+
system.cpu.time:
46+
enabled: false
4347
resource_attributes:
4448
map.resource.attr:
4549
enabled: false

cmd/mdatagen/internal/samplescraper/metadata.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,19 @@ attributes:
100100
type: map
101101

102102
metrics:
103+
system.cpu.time:
104+
enabled: true
105+
stability:
106+
level: beta
107+
description: Monotonic cumulative sum int metric enabled by default.
108+
extended_documentation: The metric will be become optional soon.
109+
unit: s
110+
sum:
111+
value_type: int
112+
monotonic: true
113+
aggregation_temporality: cumulative
114+
semantic_convention:
115+
semconv_ref: https://github.com/open-telemetry/semantic-conventions/blob/v1.35.0/docs/system/system-metrics.md#metric-systemcputime
103116
default.metric:
104117
enabled: true
105118
description: Monotonic cumulative sum int metric enabled by default.

cmd/mdatagen/internal/templates/documentation.md.tmpl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212

1313
{{- end }}
1414

15-
| Unit | Metric Type | Value Type |{{ if $metric.Data.HasAggregated }} Aggregation Temporality |{{ end }}{{ if $metric.Data.HasMonotonic }} Monotonic |{{ end }}{{ if $metric.Stability.Level }} Stability |{{ end }}
16-
| ---- | ----------- | ---------- |{{ if $metric.Data.HasAggregated }} ----------------------- |{{ end }}{{ if $metric.Data.HasMonotonic }} --------- |{{ end }}{{ if $metric.Stability.Level }} --------- |{{ end }}
15+
| Unit | Metric Type | Value Type |{{ if $metric.Data.HasAggregated }} Aggregation Temporality |{{ end }}{{ if $metric.Data.HasMonotonic }} Monotonic |{{ end }}{{ if $metric.Stability.Level }} Stability |{{ end }}{{ if $metric.SemanticConvention }} Semantic Convention |{{ end }}
16+
| ---- | ----------- | ---------- |{{ if $metric.Data.HasAggregated }} ----------------------- |{{ end }}{{ if $metric.Data.HasMonotonic }} --------- |{{ end }}{{ if $metric.Stability.Level }} --------- |{{ end }}{{ if $metric.SemanticConvention }} ------------------- |{{ end }}
1717
| {{ $metric.Unit }} | {{ $metric.Data.Type }} | {{ $metric.Data.MetricValueType }} |
1818
{{- if $metric.Data.HasAggregated }} {{ $metric.Data.AggregationTemporality }} |{{ end }}
1919
{{- if $metric.Data.HasMonotonic }} {{ $metric.Data.Monotonic }} |{{ end }}
2020
{{- if $metric.Stability.Level }} {{ $metric.Stability.Level }} |{{ end }}
21+
{{- if $metric.SemanticConvention }} [{{ $metricName }}]({{ $metric.SemanticConvention.SemanticConventionRef }}) |{{ end }}
2122

2223
{{- if $metric.Attributes }}
2324

@@ -79,11 +80,12 @@
7980

8081
{{- end }}
8182

82-
| Unit | Metric Type | Value Type |{{ if $metric.Data.HasMonotonic }} Monotonic |{{ end }}{{ if $metric.Stability.Level }} Stability |{{ end }}
83-
| ---- | ----------- | ---------- |{{ if $metric.Data.HasMonotonic }} --------- |{{ end }}{{ if $metric.Stability.Level }} --------- |{{ end }}
83+
| Unit | Metric Type | Value Type |{{ if $metric.Data.HasMonotonic }} Monotonic |{{ end }}{{ if $metric.Stability.Level }} Stability |{{ end }}{{ if $metric.SemanticConvention }} Semantic Convention |{{ end }}
84+
| ---- | ----------- | ---------- |{{ if $metric.Data.HasMonotonic }} --------- |{{ end }}{{ if $metric.Stability.Level }} --------- |{{ end }}{{ if $metric.SemanticConvention }} ------------------- |{{ end }}
8485
| {{ $metric.Unit }} | {{ $metric.Data.Type }} | {{ $metric.Data.MetricValueType }} |
8586
{{- if $metric.Data.HasMonotonic }} {{ $metric.Data.Monotonic }} |{{ end }}
8687
{{- if $metric.Stability.Level }} {{ $metric.Stability.Level }} |{{ end }}
88+
{{- if $metric.SemanticConvention }} [{{ $metricName }}]({{ $metric.SemanticConvention.SemanticConventionRef }}) |{{ end }}
8789

8890
{{- if $metric.Attributes }}
8991

0 commit comments

Comments
 (0)