-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
receiver/prometheus/internal: add createNodeAndResourcePdata for Prometheus->OTLP Pdata #3139
receiver/prometheus/internal: add createNodeAndResourcePdata for Prometheus->OTLP Pdata #3139
Conversation
bbe1e0b
to
b949055
Compare
Kindly cc-ing @alolita @Aneurysm9 @rakyll @bogdandrutu; there is a long chain of PRs coming to progressively make equivalent converters and have full tests and then when ready just switch over entirely when we have complete converters. |
@anuraaga @Aneurysm9 @rakyll can you please review? |
if diff := cmp.Diff(byDirectOTLPResource, fromOCResource, protocmp.Transform()); diff != "" { | ||
t.Fatalf("Resource mismatch: got: - want: +\n%s", diff) | ||
} |
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.
You have sort on the AttributeMap, so you can sort both resources. Also we try to avoid using cmp.Diff
and encourage github.com/stretchr/testify
to be used.
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.
I don't think we need this comparison test, just write assertions on the PData as you normally would, verifying its structure. The OC code is going to get deleted at which point these tests will need to be rewritten anyways, we should do it now. I believe all the current caveats in the PR would go away if doing so.
func TestCreateNodeAndResourceConversion(t *testing.T) { | ||
job, instance, scheme := "converter", "ocmetrics", "http" | ||
ocNode, ocResource := createNodeAndResource(job, instance, scheme) | ||
mdFromOC := internaldata.OCToMetrics(internaldata.MetricsData{ |
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.
Please avoid using deprecated methods, and deprecated OC format even in tests
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.
Well I am doing a straight up translation of what exists in the code and I need to produce the exact same result that the current code produces. This PR converts from Prometheus->OTLP instead of Prometheus->OpenCensus->OTLP, and once the entire translation is done and we are sure that we have an absolute 1-to-1 mapping, these tests will be discarded.
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.
Perhaps the test can be renamed in a way that makes it clear it is only intended to validate congruence with the outgoing implementation and will need to be removed.
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.
Sounds good @Aneurysm9, I've renamed it to TestCreateNodeAndResourceEquivalence
} | ||
resource := pdata.NewResource() | ||
attrs := resource.Attributes() | ||
attrs.UpsertString(conventions.AttributeServiceName, job) |
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.
@alolita Does anyone own the spec for prometheus mapping of the standard conventions? These seem somewhat arbitrary. If they can be excluded, I'd only add the prometheus specific attributes for now
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.
@anuraaga this is a straight up translation of what already exists in the current converter.
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.
I know - it doesn't block this PR but someone needs to be working on that.
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.
Cool!
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.
Maybe we need to open an issue to track this.
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.
Maybe we need to open an issue to track this.
Why upsert the job to service.name? Shouldn't it be better to check if service.name has been set?
if diff := cmp.Diff(byDirectOTLPResource, fromOCResource, protocmp.Transform()); diff != "" { | ||
t.Fatalf("Resource mismatch: got: - want: +\n%s", diff) | ||
} |
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.
I don't think we need this comparison test, just write assertions on the PData as you normally would, verifying its structure. The OC code is going to get deleted at which point these tests will need to be rewritten anyways, we should do it now. I believe all the current caveats in the PR would go away if doing so.
b949055
to
9e0df1b
Compare
@bogdandrutu @tigrannajaryan kind ping! |
My comment about adding normal unit tests, not just parity ones, seems to still not be addressed |
9e0df1b
to
33919a8
Compare
@anuraaga thanks, I hadn't seen your comment, but I've just answered by saying that for the very beginning let's focus on full equivalence which is currently the uphill task. |
@odeke-em Having the parity tests is fine - but this is new code. As with any new code, we add test cases and assertions for them. We'll have to do it anyways to remove the opencensus APIs which we really want to do, so we should do it now. |
I completely agree, also the parity tests will be removed when we switch to the new code so we will be left without unit-tests. |
@odeke-em can you please address @anuraaga and @bogdandrutu for adding tests cases and assertions so that this PR can be merged. ty! |
The main blocking change was fixed
Sure, I am going to add them but I predict that the amount of review time is going to be increase even more, which was the entire point of firstly mailing parity tests, then later on unit tests. |
Waiting for the author to add unit-tests. |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
…etheus->OTLP Pdata Starts the progressive effort to convert directly from Prometheus->OTLPPdata directly instead of Prometheus->OpenCensusProto->OTLPPdata by adding a converter for node+resource -> pdata.Resource. Updates #3137
Addresses feedback pointed out by Bogdan, Tigran, Jaana by using Resource.Attributes().Sort() instead and also avoid using go-cmp/cmp and instead opt to using require.Equal.
33919a8
to
6ea4b9e
Compare
@bogdandrutu @anuraaga please take a look. |
Kind ping @bogdandrutu.. |
Starts the progressive effort to convert directly from
Prometheus->OTLPPdata
directly instead of
by adding a converter for node+resource -> pdata.Resource.
Updates #3137