-
Notifications
You must be signed in to change notification settings - Fork 99
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
Run collector metrics integration tests on the SDK metrics exporter #494
Conversation
4e29d99
to
1ff9083
Compare
1ff9083
to
bc201d0
Compare
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") | ||
} | ||
} |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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.