Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run collector metrics integration tests on the SDK metrics exporter #494

Merged
merged 1 commit into from Oct 4, 2022

Conversation

dashpole
Copy link
Contributor

@dashpole dashpole commented Oct 3, 2022

It does this by converting from pdata to the sdk metric exporter types.

Since it currently fails the tests (because of differences between the exporters), i've disabled all the tests. I'll reenable them once-at-a-time as I fix the differences.

@dashpole dashpole force-pushed the integration_testing branch 3 times, most recently from 4e29d99 to 1ff9083 Compare October 3, 2022 21:55
Comment on lines +136 to +153
testServerExporter, err := metric.New(
metric.WithProjectID("fakeprojectid"),
metric.WithMonitoringClientOptions(
apioption.WithEndpoint(testServer.Endpoint),
apioption.WithoutAuthentication(),
apioption.WithGRPCDialOption(grpc.WithTransportCredentials(insecure.NewCredentials())),
),
)
require.NoError(t, err)

for _, m := range testcases.ConvertResourceMetrics(metrics) {
err = testServerExporter.Export(ctx, m)
if !test.ExpectErr {
require.NoError(t, err, "Failed to export metrics to local test server")
} else {
require.Error(t, err, "Did not see expected error")
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only section that differs from TestCollectorMetrics above.

CreateTimeSeriesRequests: testServer.CreateTimeSeriesRequests(),
CreateMetricDescriptorRequests: testServer.CreateMetricDescriptorRequests(),
CreateServiceTimeSeriesRequests: testServer.CreateServiceTimeSeriesRequests(),
// Do not test self-observability metrics with SDK exporters
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also don't check self-obs metrics in SDK tests, since those are specific to the collector exporter.


// ConvertResourceMetrics converts a (collector) pdata metrics to an SDK ResourceMetrics
// This is useful for testing the SDK with the same data used to test the collector.
func ConvertResourceMetrics(pdataMetrics pmetric.Metrics) []metricdata.ResourceMetrics {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the conversion all looks pretty 1:1, but are you worried at all about maintaining these conversions? The metrics sdk is only alpha, so it could still change right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, but it is spec-compliant (and the spec is stable), and the underlying OTLP datamodel is also stable, so I don't think it is likely to change. pdata APIs are also not stable, so its also a risk. But i'm not too worried.

@dashpole dashpole merged commit 723ca6d into GoogleCloudPlatform:main Oct 4, 2022
@dashpole dashpole deleted the integration_testing branch October 4, 2022 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants