Skip to content

Commit 6a872fd

Browse files
authored
Merge branch 'main' into pprofile-build-attributes-helper
2 parents 35f5bfd + 92c8136 commit 6a872fd

File tree

82 files changed

+2446
-2455
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+2446
-2455
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: service
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: remove custom code and instead use config package to instantiate meter provider.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [11611]
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: []
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: Generate assert function for each metric in mdatagen
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [12179]
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: [api]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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: deprecation
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: component
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Deprecate `component.TelemetrySettings.MetricsLevel` in favor of using views and 'Enabled' method.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [12159]
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+
- Components will temporarily need the service to support using views.
20+
21+
# Optional: The change log or logs in which this entry should be included.
22+
# e.g. '[user]' or '[user, api]'
23+
# Include 'user' if the change is relevant to end users.
24+
# Include 'api' if there is a change to a library API.
25+
# Default: '[user]'
26+
change_logs: [api]
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: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: component/componenttest
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Remove deprecated `CheckScraperMetrics` functions
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [12183]
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: [api]

.chloggen/telemetry-async-err-ch.yaml

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: bug_fix
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: service-telemetry
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: pass the missing async error channel into service telemetry settings
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [11417]
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: []

cmd/mdatagen/internal/samplereceiver/internal/metadatatest/generated_telemetrytest.go

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

cmd/mdatagen/internal/samplereceiver/internal/metadatatest/generated_telemetrytest_test.go

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

cmd/mdatagen/internal/samplereceiver/metrics_test.go

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,39 +30,22 @@ func TestComponentTelemetry(t *testing.T) {
3030
factory := NewFactory()
3131
receiver, err := factory.CreateMetrics(context.Background(), tt.NewSettings(), componenttest.NewNopHost(), new(consumertest.MetricsSink))
3232
require.NoError(t, err)
33-
tt.AssertMetrics(t, []metricdata.Metrics{
34-
{
35-
Name: "otelcol_batch_size_trigger_send",
36-
Description: "Number of times the batch was sent due to a size trigger [deprecated since v0.110.0]",
37-
Unit: "{times}",
38-
Data: metricdata.Sum[int64]{
39-
Temporality: metricdata.CumulativeTemporality,
40-
IsMonotonic: true,
41-
DataPoints: []metricdata.DataPoint[int64]{
42-
{
43-
Value: 1,
44-
},
45-
},
33+
metadatatest.AssertEqualBatchSizeTriggerSend(t, tt.Telemetry,
34+
[]metricdata.DataPoint[int64]{
35+
{
36+
Value: 1,
4637
},
47-
},
48-
{
49-
Name: "otelcol_process_runtime_total_alloc_bytes",
50-
Description: "Cumulative bytes allocated for heap objects (see 'go doc runtime.MemStats.TotalAlloc')",
51-
Unit: "By",
52-
Data: metricdata.Sum[int64]{
53-
Temporality: metricdata.CumulativeTemporality,
54-
IsMonotonic: true,
55-
DataPoints: []metricdata.DataPoint[int64]{
56-
{
57-
Value: 2,
58-
},
59-
},
38+
}, metricdatatest.IgnoreTimestamp())
39+
metadatatest.AssertEqualProcessRuntimeTotalAllocBytes(t, tt.Telemetry,
40+
[]metricdata.DataPoint[int64]{
41+
{
42+
Value: 2,
6043
},
61-
},
62-
}, metricdatatest.IgnoreTimestamp())
44+
}, metricdatatest.IgnoreTimestamp())
6345
rcv, ok := receiver.(nopReceiver)
6446
require.True(t, ok)
6547
rcv.initOptionalMetric()
48+
// TODO: this needs to be replaces once the optional metric is supported in AssertMetricEqual functions.
6649
tt.AssertMetrics(t, []metricdata.Metrics{
6750
{
6851
Name: "otelcol_batch_size_trigger_send",

cmd/mdatagen/internal/templates/telemetrytest.go.tmpl

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func SetupTelemetry(opts ...componenttest.TelemetryOption) Telemetry {
2828
return Telemetry{ Telemetry: componenttest.NewTelemetry(opts...) }
2929
}
3030

31-
{{- if or isConnector isExporter isExtension isProcessor isReceiver isScraper }}
31+
{{ if or isConnector isExporter isExtension isProcessor isReceiver isScraper }}
3232
func (tt *Telemetry) NewSettings() {{ .Status.Class }}.Settings {
3333
set := {{ .Status.Class }}test.NewNopSettings()
3434
set.ID = component.NewID(component.MustNewType("{{ .Type }}"))
@@ -42,15 +42,45 @@ func (tt *Telemetry) AssertMetrics(t *testing.T, expected []metricdata.Metrics,
4242
require.NoError(t, tt.Reader.Collect(context.Background(), &md))
4343
// ensure all required metrics are present
4444
for _, want := range expected {
45-
got := getMetric(want.Name, md)
45+
got := getMetricFromResource(want.Name, md)
4646
metricdatatest.AssertEqual(t, want, got, opts...)
4747
}
4848

4949
// ensure no additional metrics are emitted
5050
require.Equal(t, len(expected), lenMetrics(md))
5151
}
5252

53-
func getMetric(name string, got metricdata.ResourceMetrics) metricdata.Metrics {
53+
{{ range $name, $metric := .Telemetry.Metrics }}
54+
{{ if not $metric.Optional }}
55+
func AssertEqual{{ $name.Render }}(t *testing.T, tt componenttest.Telemetry, dps []metricdata.{{- if eq $metric.Data.Type "Histogram" }} {{$metric.Data.Type}} {{- end }}DataPoint[{{ $metric.Data.BasicType }}], opts ...metricdatatest.Option) {
56+
want := metricdata.Metrics{
57+
Name: "otelcol_{{ $name }}",
58+
Description: "{{ $metric.Description }}{{ $metric.Stability }}",
59+
Unit: "{{ $metric.Unit }}",
60+
Data: metricdata.{{ $metric.Data.Type }}[{{ $metric.Data.BasicType }}]{
61+
{{- if $metric.Data.HasAggregated }}
62+
Temporality: metricdata.CumulativeTemporality,
63+
{{- end }}
64+
{{- if $metric.Data.HasMonotonic }}
65+
IsMonotonic: {{ $metric.Data.Monotonic }},
66+
{{- end }}
67+
DataPoints: dps,
68+
},
69+
}
70+
got := getMetric(t, tt, "otelcol_{{ $name }}")
71+
metricdatatest.AssertEqual(t, want, got, opts...)
72+
}
73+
74+
{{- end }}
75+
{{- end }}
76+
77+
func getMetric(t *testing.T, tt componenttest.Telemetry, name string) metricdata.Metrics {
78+
var md metricdata.ResourceMetrics
79+
require.NoError(t, tt.Reader.Collect(context.Background(), &md))
80+
return getMetricFromResource(name, md)
81+
}
82+
83+
func getMetricFromResource(name string, got metricdata.ResourceMetrics) metricdata.Metrics {
5484
for _, sm := range got.ScopeMetrics {
5585
for _, m := range sm.Metrics {
5686
if m.Name == name {
@@ -70,4 +100,3 @@ func lenMetrics(got metricdata.ResourceMetrics) int {
70100

71101
return metricsCount
72102
}
73-

cmd/mdatagen/internal/templates/telemetrytest_test.go.tmpl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,20 @@ func TestSetupTelemetry(t *testing.T) {
6767
{{- end }}
6868
{{- end }}
6969
}, metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreValue())
70+
71+
{{- range $name, $metric := .Telemetry.Metrics }}
72+
{{ if not $metric.Optional }}
73+
AssertEqual{{ $name.Render }}(t, testTel.Telemetry,
74+
{{ if eq $metric.Data.Type "Gauge" -}}
75+
[]metricdata.DataPoint[{{ $metric.Gauge.MetricValueType.BasicType }}]{{"{{}}"}},
76+
{{- else if eq $metric.Data.Type "Sum" -}}
77+
[]metricdata.DataPoint[{{ $metric.Sum.MetricValueType.BasicType }}]{{"{{}}"}},
78+
{{- else if eq $metric.Data.Type "Histogram" -}}
79+
[]metricdata.HistogramDataPoint[{{ $metric.Histogram.MetricValueType.BasicType }}]{{"{{}}"}},
80+
{{- end }}
81+
metricdatatest.IgnoreTimestamp(), metricdatatest.IgnoreValue())
82+
{{- end }}
83+
{{- end }}
84+
7085
require.NoError(t, testTel.Shutdown(context.Background()))
7186
}
72-

0 commit comments

Comments
 (0)