Skip to content

Commit 6703484

Browse files
committed
test: fix ut
1 parent 8009f76 commit 6703484

File tree

16 files changed

+447
-186
lines changed

16 files changed

+447
-186
lines changed

pkg/applier/applier_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
"github.com/GoogleContainerTools/config-sync/pkg/syncer/syncertest"
4040
testingfake "github.com/GoogleContainerTools/config-sync/pkg/syncer/syncertest/fake"
4141
"github.com/GoogleContainerTools/config-sync/pkg/testing/testerrors"
42+
"github.com/GoogleContainerTools/config-sync/pkg/testing/testmetrics"
4243
"github.com/stretchr/testify/assert"
4344
"github.com/stretchr/testify/require"
4445
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -85,6 +86,8 @@ func (a *fakeKptApplier) Run(_ context.Context, _ inventory.Info, objsToApply ob
8586
}
8687

8788
func TestApply(t *testing.T) {
89+
_ = testmetrics.NewTestExporter()
90+
8891
syncScope := declared.Scope("test-namespace")
8992
syncName := "rs"
9093
resourceManager := declared.ResourceManager(syncScope, syncName)

pkg/declared/resources_test.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,12 @@ import (
2323
"github.com/GoogleContainerTools/config-sync/pkg/core/k8sobjects"
2424
"github.com/GoogleContainerTools/config-sync/pkg/kinds"
2525
"github.com/GoogleContainerTools/config-sync/pkg/metadata"
26-
"github.com/GoogleContainerTools/config-sync/pkg/metrics"
2726
"github.com/GoogleContainerTools/config-sync/pkg/syncer/reconcile"
2827
"github.com/GoogleContainerTools/config-sync/pkg/syncer/syncertest"
2928
"github.com/GoogleContainerTools/config-sync/pkg/testing/testmetrics"
3029
"github.com/google/go-cmp/cmp"
3130
"github.com/stretchr/testify/assert"
3231
"github.com/stretchr/testify/require"
33-
"go.opencensus.io/stats/view"
34-
"go.opencensus.io/tag"
3532
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3633
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
3734
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -53,6 +50,7 @@ func TestUpdateDeclared(t *testing.T) {
5350
objects := testSet
5451
commit := "1"
5552
expectedIDs := getIDs(objects)
53+
_ = testmetrics.NewTestExporter()
5654

5755
newObjects, err := dr.UpdateDeclared(context.Background(), objects, commit)
5856
if err != nil {
@@ -211,20 +209,27 @@ func TestGVKSet(t *testing.T) {
211209
}
212210

213211
func TestResources_InternalErrorMetricValidation(t *testing.T) {
214-
m := testmetrics.RegisterMetrics(metrics.InternalErrorsView)
212+
testmetrics.ResetGlobalMetrics()
213+
exporter := testmetrics.NewTestExporter()
215214
dr := Resources{}
216215
if _, err := dr.UpdateDeclared(context.Background(), nilSet, "unused"); err != nil {
217216
t.Fatal(err)
218217
}
219-
wantMetrics := []*view.Row{
218+
219+
expectedMetrics := []testmetrics.MetricData{
220+
{
221+
Name: "internal_errors_total",
222+
Value: 1,
223+
Labels: map[string]string{"source": "parser"},
224+
},
220225
{
221-
Data: &view.CountData{Value: 1},
222-
Tags: []tag.Tag{
223-
{Key: metrics.KeyInternalErrorSource, Value: "parser"},
224-
},
226+
Name: "declared_resources",
227+
Value: 0,
228+
Labels: map[string]string{"commit": "unused"},
225229
},
226230
}
227-
if diff := m.ValidateMetrics(metrics.InternalErrorsView, wantMetrics); diff != "" {
231+
232+
if diff := exporter.ValidateMetrics(expectedMetrics); diff != "" {
228233
t.Error(diff)
229234
}
230235
}

pkg/hydrate/controller_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/GoogleContainerTools/config-sync/pkg/importer/filesystem/cmpath"
2626
ft "github.com/GoogleContainerTools/config-sync/pkg/importer/filesystem/filesystemtest"
2727
"github.com/GoogleContainerTools/config-sync/pkg/testing/testerrors"
28+
"github.com/GoogleContainerTools/config-sync/pkg/testing/testmetrics"
2829
"github.com/stretchr/testify/assert"
2930
"k8s.io/apimachinery/pkg/util/rand"
3031
"k8s.io/apimachinery/pkg/util/wait"
@@ -211,6 +212,12 @@ func TestRunHydrate(t *testing.T) {
211212

212213
for _, tc := range testCases {
213214
t.Run(tc.name, func(t *testing.T) {
215+
// Reset metrics for this test to avoid cross-test contamination
216+
testmetrics.ResetGlobalMetrics()
217+
218+
// Initialize metrics before any test setup
219+
_ = testmetrics.NewTestExporter()
220+
214221
// create a temporary directory with a commit hash
215222
tempDir, err := os.MkdirTemp(os.TempDir(), "run-hydrate-test")
216223
if err != nil {

pkg/kmetrics/metrics.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,6 @@ func InitializeOTelKustomizeMetrics() error {
169169

170170
// RecordKustomizeFieldCountData records all data relevant to the kustomization's field counts
171171
func RecordKustomizeFieldCountData(ctx context.Context, fieldCountData *KustomizeFieldMetrics) {
172-
// Check if metric is initialized
173-
if KustomizeFieldCount == nil {
174-
klog.Errorf("KustomizeFieldCount metric is not initialized!")
175-
return
176-
}
177172

178173
klog.Infof("METRIC DEBUG: Recording KustomizeFieldCountData - FieldCount: %d, DeprecationMetrics: %d, SimplMetrics: %d",
179174
len(fieldCountData.FieldCount), len(fieldCountData.DeprecationMetrics), len(fieldCountData.SimplMetrics))

pkg/metrics/record.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,18 @@ func RecordRemediateDuration(ctx context.Context, status string, startTime time.
190190

191191
// RecordResourceConflict produces measurements for the ResourceConflicts view.
192192
func RecordResourceConflict(ctx context.Context, commit string) {
193+
attrs := []attribute.KeyValue{
194+
KeyCommit.String(commit),
195+
}
193196
klog.Infof("METRIC DEBUG: Recording ResourceConflict: commit=%s", commit)
194-
ResourceConflicts.Add(ctx, 1)
197+
ResourceConflicts.Add(ctx, 1, metric.WithAttributes(attrs...))
195198
}
196199

197200
// RecordInternalError produces measurements for the InternalErrors view.
198201
func RecordInternalError(ctx context.Context, source string) {
202+
attrs := []attribute.KeyValue{
203+
KeyInternalErrorSource.String(source),
204+
}
199205
klog.Infof("METRIC DEBUG: Recording InternalError: source=%s", source)
200-
InternalErrors.Add(ctx, 1)
206+
InternalErrors.Add(ctx, 1, metric.WithAttributes(attrs...))
201207
}

pkg/parse/root_reconciler_test.go

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import (
3737
"github.com/GoogleContainerTools/config-sync/pkg/importer/reader"
3838
"github.com/GoogleContainerTools/config-sync/pkg/kinds"
3939
"github.com/GoogleContainerTools/config-sync/pkg/metadata"
40-
"github.com/GoogleContainerTools/config-sync/pkg/metrics"
4140
"github.com/GoogleContainerTools/config-sync/pkg/remediator/conflict"
4241
remediatorfake "github.com/GoogleContainerTools/config-sync/pkg/remediator/fake"
4342
"github.com/GoogleContainerTools/config-sync/pkg/rootsync"
@@ -50,8 +49,6 @@ import (
5049
discoveryutil "github.com/GoogleContainerTools/config-sync/pkg/util/discovery"
5150
webhookconfiguration "github.com/GoogleContainerTools/config-sync/pkg/webhook/configuration"
5251
"github.com/stretchr/testify/require"
53-
"go.opencensus.io/stats/view"
54-
"go.opencensus.io/tag"
5552
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
5653
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5754
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -658,6 +655,8 @@ func TestRootReconciler_ParseAndUpdate(t *testing.T) {
658655
t.Fatal(err)
659656
}
660657

658+
_ = testmetrics.NewTestExporter()
659+
661660
for _, tc := range testCases {
662661
t.Run(tc.name, func(t *testing.T) {
663662
fakeClient := syncertest.NewClient(t, core.Scheme, tc.existingObjects...)
@@ -1289,7 +1288,7 @@ func TestRootReconciler_Parse_SourceErrorMetricValidation(t *testing.T) {
12891288
name string
12901289
parseErrors status.MultiError
12911290
expectedError status.MultiError
1292-
expectedMetrics []*view.Row
1291+
expectedMetrics []testmetrics.MetricData
12931292
}{
12941293
{
12951294
name: "single reconciler error in source component",
@@ -1299,10 +1298,11 @@ func TestRootReconciler_Parse_SourceErrorMetricValidation(t *testing.T) {
12991298
expectedError: status.Wrap(
13001299
status.SourceError.Sprintf("source error").Build(),
13011300
),
1302-
expectedMetrics: []*view.Row{
1303-
{Data: &view.LastValueData{Value: 0}, Tags: []tag.Tag{{Key: metrics.KeyComponent, Value: "source"}, {Key: metrics.KeyErrorClass, Value: "1xxx"}}},
1304-
{Data: &view.LastValueData{Value: 1}, Tags: []tag.Tag{{Key: metrics.KeyComponent, Value: "source"}, {Key: metrics.KeyErrorClass, Value: "2xxx"}}},
1305-
{Data: &view.LastValueData{Value: 0}, Tags: []tag.Tag{{Key: metrics.KeyComponent, Value: "source"}, {Key: metrics.KeyErrorClass, Value: "9xxx"}}},
1301+
expectedMetrics: []testmetrics.MetricData{
1302+
{Name: "reconciler_errors", Value: 0, Labels: map[string]string{"component": "source", "errorclass": "1xxx"}},
1303+
{Name: "reconciler_errors", Value: 1, Labels: map[string]string{"component": "source", "errorclass": "2xxx"}},
1304+
{Name: "reconciler_errors", Value: 0, Labels: map[string]string{"component": "source", "errorclass": "9xxx"}},
1305+
{Name: "pipeline_error_observed", Value: 1, Labels: map[string]string{"component": "source", "name": "", "reconciler": "root-sync"}},
13061306
},
13071307
},
13081308
{
@@ -1315,18 +1315,20 @@ func TestRootReconciler_Parse_SourceErrorMetricValidation(t *testing.T) {
13151315
status.SourceError.Sprintf("source error").Build(),
13161316
status.InternalError("internal error"),
13171317
),
1318-
expectedMetrics: []*view.Row{
1319-
{Data: &view.LastValueData{Value: 0}, Tags: []tag.Tag{{Key: metrics.KeyComponent, Value: "source"}, {Key: metrics.KeyErrorClass, Value: "1xxx"}}},
1320-
{Data: &view.LastValueData{Value: 1}, Tags: []tag.Tag{{Key: metrics.KeyComponent, Value: "source"}, {Key: metrics.KeyErrorClass, Value: "2xxx"}}},
1321-
{Data: &view.LastValueData{Value: 1}, Tags: []tag.Tag{{Key: metrics.KeyComponent, Value: "source"}, {Key: metrics.KeyErrorClass, Value: "9xxx"}}},
1318+
expectedMetrics: []testmetrics.MetricData{
1319+
{Name: "reconciler_errors", Value: 0, Labels: map[string]string{"component": "source", "errorclass": "1xxx"}},
1320+
{Name: "reconciler_errors", Value: 1, Labels: map[string]string{"component": "source", "errorclass": "2xxx"}},
1321+
{Name: "reconciler_errors", Value: 1, Labels: map[string]string{"component": "source", "errorclass": "9xxx"}},
1322+
{Name: "pipeline_error_observed", Value: 1, Labels: map[string]string{"component": "source", "name": "", "reconciler": "root-sync"}},
13221323
},
13231324
},
13241325
}
13251326

13261327
for _, tc := range testCases {
13271328
t.Run(tc.name, func(t *testing.T) {
13281329
require.Error(t, tc.parseErrors)
1329-
m := testmetrics.RegisterMetrics(metrics.ReconcilerErrorsView)
1330+
testmetrics.ResetGlobalMetrics()
1331+
exporter := testmetrics.NewTestExporter()
13301332
fakeConfigParser := &fsfake.ConfigParser{
13311333
Outputs: []fsfake.ParserOutputs{
13321334
// One Parse call, with errors
@@ -1388,7 +1390,7 @@ func TestRootReconciler_Parse_SourceErrorMetricValidation(t *testing.T) {
13881390
errs := reconciler.parse(ctx, trigger)
13891391
testerrors.AssertEqual(t, tc.expectedError, errs, "expected parse errors to match")
13901392

1391-
if diff := m.ValidateMetrics(metrics.ReconcilerErrorsView, tc.expectedMetrics); diff != "" {
1393+
if diff := exporter.ValidateMetrics(tc.expectedMetrics); diff != "" {
13921394
t.Error(diff)
13931395
}
13941396
})
@@ -1400,21 +1402,21 @@ func TestRootReconciler_Update_ApplierErrorMetricValidation(t *testing.T) {
14001402
name string
14011403
applyErrors []status.Error
14021404
expectedError status.MultiError
1403-
expectedMetrics []*view.Row
1405+
expectedMetrics []testmetrics.MetricData
14041406
}{
14051407
{
14061408
name: "single reconciler error in sync component",
14071409
applyErrors: []status.Error{
14081410
applier.Error(errors.New("sync error")),
14091411
},
14101412
expectedError: applier.Error(errors.New("sync error")),
1411-
expectedMetrics: []*view.Row{
1412-
{Data: &view.LastValueData{Value: 0}, Tags: []tag.Tag{{Key: metrics.KeyComponent, Value: "source"}, {Key: metrics.KeyErrorClass, Value: "1xxx"}}},
1413-
{Data: &view.LastValueData{Value: 0}, Tags: []tag.Tag{{Key: metrics.KeyComponent, Value: "source"}, {Key: metrics.KeyErrorClass, Value: "2xxx"}}},
1414-
{Data: &view.LastValueData{Value: 0}, Tags: []tag.Tag{{Key: metrics.KeyComponent, Value: "source"}, {Key: metrics.KeyErrorClass, Value: "9xxx"}}},
1415-
{Data: &view.LastValueData{Value: 0}, Tags: []tag.Tag{{Key: metrics.KeyComponent, Value: "sync"}, {Key: metrics.KeyErrorClass, Value: "1xxx"}}},
1416-
{Data: &view.LastValueData{Value: 1}, Tags: []tag.Tag{{Key: metrics.KeyComponent, Value: "sync"}, {Key: metrics.KeyErrorClass, Value: "2xxx"}}},
1417-
{Data: &view.LastValueData{Value: 0}, Tags: []tag.Tag{{Key: metrics.KeyComponent, Value: "sync"}, {Key: metrics.KeyErrorClass, Value: "9xxx"}}},
1413+
expectedMetrics: []testmetrics.MetricData{
1414+
{Name: "reconciler_errors", Value: 0, Labels: map[string]string{"component": "source", "errorclass": "1xxx"}},
1415+
{Name: "reconciler_errors", Value: 0, Labels: map[string]string{"component": "source", "errorclass": "2xxx"}},
1416+
{Name: "reconciler_errors", Value: 0, Labels: map[string]string{"component": "source", "errorclass": "9xxx"}},
1417+
{Name: "reconciler_errors", Value: 0, Labels: map[string]string{"component": "sync", "errorclass": "1xxx"}},
1418+
{Name: "reconciler_errors", Value: 1, Labels: map[string]string{"component": "sync", "errorclass": "2xxx"}},
1419+
{Name: "reconciler_errors", Value: 0, Labels: map[string]string{"component": "sync", "errorclass": "9xxx"}},
14181420
},
14191421
},
14201422
{
@@ -1427,20 +1429,20 @@ func TestRootReconciler_Update_ApplierErrorMetricValidation(t *testing.T) {
14271429
applier.Error(errors.New("sync error")),
14281430
status.InternalError("internal error"),
14291431
),
1430-
expectedMetrics: []*view.Row{
1431-
{Data: &view.LastValueData{Value: 0}, Tags: []tag.Tag{{Key: metrics.KeyComponent, Value: "source"}, {Key: metrics.KeyErrorClass, Value: "1xxx"}}},
1432-
{Data: &view.LastValueData{Value: 0}, Tags: []tag.Tag{{Key: metrics.KeyComponent, Value: "source"}, {Key: metrics.KeyErrorClass, Value: "2xxx"}}},
1433-
{Data: &view.LastValueData{Value: 0}, Tags: []tag.Tag{{Key: metrics.KeyComponent, Value: "source"}, {Key: metrics.KeyErrorClass, Value: "9xxx"}}},
1434-
{Data: &view.LastValueData{Value: 0}, Tags: []tag.Tag{{Key: metrics.KeyComponent, Value: "sync"}, {Key: metrics.KeyErrorClass, Value: "1xxx"}}},
1435-
{Data: &view.LastValueData{Value: 1}, Tags: []tag.Tag{{Key: metrics.KeyComponent, Value: "sync"}, {Key: metrics.KeyErrorClass, Value: "2xxx"}}},
1436-
{Data: &view.LastValueData{Value: 1}, Tags: []tag.Tag{{Key: metrics.KeyComponent, Value: "sync"}, {Key: metrics.KeyErrorClass, Value: "9xxx"}}},
1432+
expectedMetrics: []testmetrics.MetricData{
1433+
{Name: "reconciler_errors", Value: 0, Labels: map[string]string{"component": "source", "errorclass": "1xxx"}},
1434+
{Name: "reconciler_errors", Value: 0, Labels: map[string]string{"component": "source", "errorclass": "2xxx"}},
1435+
{Name: "reconciler_errors", Value: 0, Labels: map[string]string{"component": "source", "errorclass": "9xxx"}},
1436+
{Name: "reconciler_errors", Value: 0, Labels: map[string]string{"component": "sync", "errorclass": "1xxx"}},
1437+
{Name: "reconciler_errors", Value: 1, Labels: map[string]string{"component": "sync", "errorclass": "2xxx"}},
1438+
{Name: "reconciler_errors", Value: 1, Labels: map[string]string{"component": "sync", "errorclass": "9xxx"}},
14371439
},
14381440
},
14391441
}
14401442

14411443
for _, tc := range testCases {
14421444
t.Run(tc.name, func(t *testing.T) {
1443-
m := testmetrics.RegisterMetrics(metrics.ReconcilerErrorsView)
1445+
exporter := testmetrics.NewTestExporter()
14441446
fakeConfigParser := &fsfake.ConfigParser{
14451447
Outputs: []fsfake.ParserOutputs{
14461448
{}, // One Parse call, no errors
@@ -1503,7 +1505,7 @@ func TestRootReconciler_Update_ApplierErrorMetricValidation(t *testing.T) {
15031505
errs = reconciler.update(ctx, trigger)
15041506
testerrors.AssertEqual(t, tc.expectedError, errs, "expected update errors to match")
15051507

1506-
if diff := m.ValidateMetrics(metrics.ReconcilerErrorsView, tc.expectedMetrics); diff != "" {
1508+
if diff := exporter.ValidateMetrics(tc.expectedMetrics); diff != "" {
15071509
t.Error(diff)
15081510
}
15091511
})

pkg/reconcilermanager/controllers/otel_controller_test.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const (
5252
// otel-collector ConfigMap.
5353
// See `CollectorConfigGooglecloud` in `pkg/metrics/otel.go`
5454
// Used by TestOtelReconcilerGooglecloud.
55-
depAnnotationGooglecloud = "b69c46dabb96a27fbd2ea25045512953"
55+
depAnnotationGooglecloud = "ff56db904f8c0fe3b38066fc6a5a12b3"
5656
// depAnnotationGooglecloud is the expected hash of the custom
5757
// otel-collector ConfigMap test artifact.
5858
// Used by TestOtelReconcilerCustom.
@@ -67,7 +67,7 @@ data:
6767
exporters:
6868
googlecloud:
6969
metric:
70-
prefix: custom.googleapis.com/opencensus/config_sync/
70+
prefix: custom.googleapis.com/opentelemetry/config_sync/
7171
resource_filters:
7272
- prefix: cloud.account.id
7373
- prefix: cloud.availability.zone
@@ -370,8 +370,12 @@ data:
370370
- env
371371
- gcp
372372
receivers:
373-
opencensus:
374-
endpoint: 0.0.0.0:55678
373+
otlp:
374+
protocols:
375+
grpc:
376+
endpoint: 0.0.0.0:4317
377+
http:
378+
endpoint: 0.0.0.0:4318
375379
service:
376380
extensions:
377381
- health_check
@@ -385,7 +389,7 @@ data:
385389
- metricstransform/cloudmonitoring
386390
- resourcedetection
387391
receivers:
388-
- opencensus
392+
- otlp
389393
metrics/kubernetes:
390394
exporters:
391395
- googlecloud/kubernetes
@@ -395,14 +399,14 @@ data:
395399
- metricstransform/kubernetes
396400
- resourcedetection
397401
receivers:
398-
- opencensus
402+
- otlp
399403
metrics/prometheus:
400404
exporters:
401405
- prometheus
402406
processors:
403407
- batch
404408
receivers:
405-
- opencensus
409+
- otlp
406410
kind: ConfigMap
407411
metadata:
408412
labels:

pkg/reconcilermanager/controllers/reposync_controller_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
"github.com/GoogleContainerTools/config-sync/pkg/reposync"
3939
syncerFake "github.com/GoogleContainerTools/config-sync/pkg/syncer/syncertest/fake"
4040
"github.com/GoogleContainerTools/config-sync/pkg/testing/testerrors"
41+
"github.com/GoogleContainerTools/config-sync/pkg/testing/testmetrics"
4142
"github.com/GoogleContainerTools/config-sync/pkg/util"
4243
"github.com/GoogleContainerTools/config-sync/pkg/validate/rsync/validate"
4344
webhookconfiguration "github.com/GoogleContainerTools/config-sync/pkg/webhook/configuration"
@@ -360,6 +361,7 @@ func setupNSReconciler(t *testing.T, objs ...client.Object) (*syncerFake.Client,
360361
func TestCreateAndUpdateNamespaceReconcilerWithOverride(t *testing.T) {
361362
// Mock out parseDeployment for testing.
362363
parseDeployment = parsedDeployment
364+
_ = testmetrics.NewTestExporter()
363365

364366
overrideReconcilerAndGitSyncResourceLimits := []v1beta1.ContainerResourcesSpec{
365367
{

pkg/remediator/queue/deleted_test.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ import (
2020

2121
"github.com/GoogleContainerTools/config-sync/pkg/core"
2222
"github.com/GoogleContainerTools/config-sync/pkg/core/k8sobjects"
23-
"github.com/GoogleContainerTools/config-sync/pkg/metrics"
2423
"github.com/GoogleContainerTools/config-sync/pkg/testing/testmetrics"
25-
"go.opencensus.io/stats/view"
26-
"go.opencensus.io/tag"
2724
"sigs.k8s.io/controller-runtime/pkg/client"
2825
)
2926

@@ -63,13 +60,19 @@ func TestWasDeleted(t *testing.T) {
6360
}
6461

6562
func TestDeleted_InternalErrorMetricValidation(t *testing.T) {
66-
m := testmetrics.RegisterMetrics(metrics.InternalErrorsView)
63+
exporter := testmetrics.NewTestExporter()
6764
ctx := context.Background()
6865
MarkDeleted(ctx, nil)
69-
wantMetrics := []*view.Row{
70-
{Data: &view.CountData{Value: 1}, Tags: []tag.Tag{{Key: metrics.KeyInternalErrorSource, Value: "remediator"}}},
66+
67+
expectedMetrics := []testmetrics.MetricData{
68+
{
69+
Name: "internal_errors_total",
70+
Value: 1,
71+
Labels: map[string]string{"source": "remediator"},
72+
},
7173
}
72-
if diff := m.ValidateMetrics(metrics.InternalErrorsView, wantMetrics); diff != "" {
74+
75+
if diff := exporter.ValidateMetrics(expectedMetrics); diff != "" {
7376
t.Error(diff)
7477
}
7578
}

0 commit comments

Comments
 (0)