| 1 |
// Code generated by mdatagen. DO NOT EDIT. |
| 2 |
|
| 3 |
package {{ .Package }}test |
| 4 |
|
| 5 |
import ( |
| 6 |
"testing" |
| 7 |
|
| 8 |
"github.com/stretchr/testify/require" |
| 9 |
"go.opentelemetry.io/otel/sdk/metric/metricdata" |
| 10 |
"go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest" |
| 11 |
|
| 12 |
{{- if or isConnector isExporter isExtension isProcessor isReceiver isScraper }} |
| 13 |
"go.opentelemetry.io/collector/component" |
| 14 |
{{- end }} |
| 15 |
"go.opentelemetry.io/collector/component/componenttest" |
| 16 |
{{- if or isConnector isExporter isExtension isProcessor isReceiver isScraper }} |
| 17 |
"go.opentelemetry.io/collector/{{ .Status.Class }}" |
| 18 |
"go.opentelemetry.io/collector/{{ .Status.Class }}/{{ .Status.Class }}test" |
| 19 |
{{- end }} |
| 20 |
) |
| 21 |
|
| 22 |
{{ if or isConnector isExporter isExtension isProcessor isReceiver isScraper }} |
| 23 |
func NewSettings(tt *componenttest.Telemetry) {{ .Status.Class }}.Settings { |
| 24 |
set := {{ .Status.Class }}test.NewNopSettings({{ .Status.Class }}test.NopType) |
| 25 |
set.ID = component.NewID(component.MustNewType("{{ .Type }}")) |
| 26 |
set.TelemetrySettings = tt.NewTelemetrySettings() |
| 27 |
return set |
| 28 |
} |
| 29 |
{{- end }} |
| 30 |
|
| 31 |
{{ range $name, $metric := .Telemetry.Metrics }} |
| 32 |
|
| 33 |
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) { |
| 34 |
want := metricdata.Metrics{ |
| 35 |
{{ if $metric.Prefix -}} |
| 36 |
Name: "{{ $metric.Prefix }}{{ $name }}", |
| 37 |
{{ else -}} |
| 38 |
Name: "otelcol_{{ $name }}", |
| 39 |
{{ end -}} |
| 40 |
Description: "{{ $metric.Description }}{{ $metric.Stability }}", |
| 41 |
Unit: "{{ $metric.Unit }}", |
| 42 |
Data: metricdata.{{ $metric.Data.Type }}[{{ $metric.Data.BasicType }}]{ |
| 43 |
{{- if $metric.Data.HasAggregated }} |
| 44 |
Temporality: metricdata.CumulativeTemporality, |
| 45 |
{{- end }} |
| 46 |
{{- if $metric.Data.HasMonotonic }} |
| 47 |
IsMonotonic: {{ $metric.Data.Monotonic }}, |
| 48 |
{{- end }} |
| 49 |
DataPoints: dps, |
| 50 |
}, |
| 51 |
} |
| 52 |
{{ if $metric.Prefix -}} |
| 53 |
got, err := tt.GetMetric("{{ $metric.Prefix }}{{ $name }}") |
| 54 |
{{ else -}} |
| 55 |
got, err := tt.GetMetric("otelcol_{{ $name }}") |
| 56 |
{{ end -}} |
| 57 |
require.NoError(t, err) |
| 58 |
metricdatatest.AssertEqual(t, want, got, opts...) |
| 59 |
} |
| 60 |
|
| 61 |
{{- end }} |