-
Notifications
You must be signed in to change notification settings - Fork 2.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
contrib/iinternal/coreinternal: add helpers for Pdata Metrics #5231
contrib/iinternal/coreinternal: add helpers for Pdata Metrics #5231
Conversation
Adds helper functions to help create metrics for OTLP pdata translations. The need for these helpers comes from PR #5184 in which we need to translate directly from Prometheus->Pdata instead of Prometheus->OpenCensus->Pdata, but we shall need to modify both receiver/prometheus*/internal and the base directory. This code is heavily used in the mentioned PR and thus no tests included in this change. Updates PR #5184
Kindly help me with a blind review/approval here @dashpole @alolita @bogdandrutu @Aneurysm9 @codeboten as this code is used in the linked PR. |
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.
👍
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.
To help show the value of this, can I kindly ask you to add tests to this?
In the PR subject I explain its purpose and particularly
|
If the code is heavily used in the mentioned PR then it should be tested here. Having heavily used code is not an excuse to not write 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.
Consider to make this internal to the module that needs it for the moment.
Key, Value string | ||
} | ||
|
||
func DistPointPdata(ts pdata.Timestamp, bounds []float64, counts []uint64) *pdata.HistogramDataPoint { |
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.
Do not return pointer to pdata.
Key, Value string | ||
} | ||
|
||
func DistPointPdata(ts pdata.Timestamp, bounds []float64, counts []uint64) *pdata.HistogramDataPoint { |
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.
pdata usually benefits more if instead of constructing new Metric, you append it to a MetricSlice. Less allocations.
Also +1 to @MovieStoreGuy comment about having tests. |
I appreciate the enthusiasm and time to review @MovieStoreGuy and @bogdandrutu,. but this doesn't make sense to me, and seems like it is just being pedantic without context about what's happening. This code doesn't add new core code functionality. There is nothing unique about me just copying and pasting this code allover, this isn't code for pdata construction in our libraries, this would be literal helpers in my test code. It costs me much less time to just duplicate this functionality which doesn't add any surface area except in building points effectively. With that logic, all the test helpers should also be tested -- this doesn't hold up for any library, and doesn't add value for the end goals for which these libraries are already years behind in ditching OpenCensus. |
@odeke-em , the point of adding tests and smaller PRs is that things can be reviewed in isolation and build up to the larger context as (more bottom up than top down). It helps keeps things streamed line and the community can review with confidence.
From what I can tell with this git commit, it is for the project.
Aa, I had missed that, my apologies. It wasn't clear these methods were to be only used for tests purposes since the title of the PR and the method names themselves didn't help allude to that fact. Can I ask that you comment to that affect? Making it clear that these methods are to be used for testing purposes only? |
The reality is this is generally considered good practice - test helpers combine to become a test framework basically. Then we need to catch issues that affect the framework in the framework itself. For example, perhaps some refactoring affects This code isn't in They're simple functions and can use just some simple tests so it'd be great if you can add them. I appreciate that it is annoying to write tests - but let's just write them and move on :) |
@anuraaga as suggested:
|
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
Closing this PR as inactive, since the feedback was not addressed for more than 1m. |
* receiver/prometheus: roundtrip Prometheus->Pdata direct conversion without OpenCensus Wire up and use the direct Prometheus->Pdata conversion end to end. With this change the receiver will no longer need OpenCensus. This change will involve more follow-ups that just migrate over the tests, because we don't want a super bloated/massive PR. Fixes #4892 Depends on PR open-telemetry/opentelemetry-collector#3694 Depends on PR open-telemetry/opentelemetry-collector#3695 * Retrofit top level package for pdata comparisons * Reuse for pdata metrics creators from PR #5231 * Shed all in-code direct references to OpenCensus * receiver/prometheus: fix tests Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: buffer metrics in builder to avoid issues with out-of-order exposition Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: restore prom->OC->pdata pipeline Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: add feature gate to control whether to use OpenCensus or pdata directly Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: localize metrics test helpers Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: store metrics in a map in metricbuilder to avoid issues with out-of-order exposition data Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: run component tests against both OC and pdata export paths Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: ensure OC metrics builder tests are deterministic Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: restore replace directive to ensure use of local copy of opencensus translator during development Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: fix lint issues Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: fix lint issues Signed-off-by: Anthony J Mirabella <[email protected]> * make porto Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: run e2e tests in parallel to avoid doubling test suite runtime Signed-off-by: Anthony J Mirabella <[email protected]> * Revert "receiver/prometheus: run e2e tests in parallel to avoid doubling test suite runtime" This reverts commit 7e04b44. * receiver/prometheus: address PR feedback Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: ensure test helper can extract timestamp from metrics of any type Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: tests should not be expecting empty label values Signed-off-by: Anthony J Mirabella <[email protected]> * make porto Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: remove gauge histogram pdata adjustment tests Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: remove unused gauge histogram data generator helper Signed-off-by: Anthony J Mirabella <[email protected]> * Fix lint errors Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: Add comments detailing use of locks in metrics adjuster. Signed-off-by: Anthony J Mirabella <[email protected]> Co-authored-by: Emmanuel T Odeke <[email protected]>
Adds helper functions to help create metrics for OTLP
pdata translations. The need for these helpers comes
from PR #5184 in which we need to translate directly
from Prometheus->Pdata instead of Prometheus->OpenCensus->Pdata,
but we shall need to modify both receiver/prometheus*/internal and
the base directory.
This code is heavily used in the mentioned PR and thus no
tests included in this change.
Updates PR #5184